Files
multiprecision/doc/tutorial_float_eg.qbk
ivanpanch 55bf069621 Fix mistakes (#729)
* Update Jamfile.v2

* Update introduction.qbk

* Update tutorial.qbk

* Update tutorial_cpp_int.qbk

* Update tutorial_gmp_int.qbk

* Update tutorial_tommath.qbk

* Update integer_examples.cpp

* Update tutorial_cpp_bin_float.qbk

* Update tutorial_cpp_dec_float.qbk

* Update tutorial_gmp_float.qbk

* Update tutorial_mpfr_float.qbk

* Update tutorial_float128.qbk

* Update tutorial_float_builtin_ctor.qbk

* Update big_seventh.cpp

* Update tutorial_float_eg.qbk

* Update floating_point_examples.cpp

* Update mpfr_precision.cpp

* Update gauss_laguerre_quadrature.cpp

* Update tutorial_interval_mpfi.qbk

* Update tutorial_cpp_complex.qbk

* Update tutorial_mpc_complex.qbk

* Update tutorial_float128_complex.qbk

* Update tutorial_complex_adaptor.qbk

* Update tutorial_rational.qbk

* Update tutorial_tommath_rational.qbk

* Update tutorial_logged_adaptor.qbk

* Update tutorial_debug_adaptor.qbk

* Update tutorial_visualizers.qbk

* Update tutorial_fwd.qbk

* Update tutorial_conversions.qbk

* Update tutorial_random.qbk

* Update random_snips.cpp

* Update tutorial_constexpr.qbk

* Update tutorial_import_export.qbk

* Update cpp_int_import_export.cpp

* Update tutorial_mixed_precision.qbk

* Update tutorial_variable_precision.qbk

* Update scoped_precision_example.cpp

* Update tutorial_numeric_limits.qbk

* Update tutorial_numeric_limits.qbk

* Update numeric_limits_snips.cpp

* Update numeric_limits_snips.cpp

* Update tutorial_numeric_limits.qbk

* Update numeric_limits_snips.cpp

* Update numeric_limits_snips.cpp

* Update tutorial_io.qbk

* Update reference_number.qbk

* Update reference_cpp_bin_float.qbk

* Update reference_cpp_double_fp_backend.qbk

* Update reference_internal_support.qbk

* Update reference_backend_requirements.qbk

* Update performance.qbk

* Update performance_overhead.qbk

* Update performance_real_world.qbk

* Update performance_integer_real_world.qbk

* Update performance_rational_real_world.qbk

* Update reference_number.qbk

* Update tutorial_numeric_limits.qbk

* Update reference_backend_requirements.qbk
2025-08-18 13:14:39 +02:00

138 lines
4.4 KiB
Plaintext

[/
Copyright 2011 - 2020 John Maddock.
Copyright 2013 - 2019 Paul A. Bristow.
Copyright 2013 Christopher Kormanyos.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:fp_eg Examples]
[include tutorial_float_builtin_ctor.qbk]
[import ../example/floating_point_examples.cpp]
[section:aos Area of Circle]
[/I:\boost\libs\multiprecision\example\floating_point_examples.cpp]
[AOS1]
[AOS2]
[AOS3]
[endsect] [/section:aos Area of Circle]
[section:caveats Drop-in Caveats]
[import ../example/big_seventh.cpp]
[big_seventh_example_1]
[big_seventh_example_2]
[big_seventh_example_3]
[big_seventh_example_constexpr] [/ Hopefully a temporary restriction.]
[big_seventh_example_4]
Typical output is:
[big_seventh_example_output]
[endsect] [/section:caveats Caveats]
[section:jel Defining a Special Function]
[JEL]
[endsect] [/section:jel Defining a Special Function]
[section:nd Calculating a Derivative]
[ND1]
[ND2]
[ND3]
[endsect] [/section:nd Calculating a Derivative]
[section:gi Calculating an Integral]
[GI1]
[GI2]
[endsect] [/section:gi Calculating an Integral]
[section:poly_eg Polynomial Evaluation]
[POLY]
[endsect] [/section:poly_eg Polynomial Evaluation]
[section:variable_precision Variable-Precision Newton Evaluation]
[mpfr_variable]
[endsect] [/section:variable_precision Variable-Precision Newton Evaluation]
[section:gauss_lagerre_quadrature Gauss-Laguerre quadrature]
[import ../example/gauss_laguerre_quadrature.cpp]
This example uses __Boost_Multiprecision to implement a high-precision Gauss-Laguerre quadrature integration.
The quadrature is used to calculate the `airy_ai(x)` function for real-valued `x` on the positive axis with `x >= 1`.
In this way, the integral representation could be seen as part of a scheme to calculate
real-valued Airy functions on the positive axis for medium to large argument.
A Taylor series or hypergeometric function (not part of this example) could be used for smaller arguments.
This example has been tested with decimal digits counts ranging from 21...301, by adjusting the parameter
`local::my_digits10` at compile time.
The quadrature integral representaion of `airy_ai(x)` used in this example can be found in:
A. Gil, J. Segura, N.M. Temme, "Numerical Methods for Special Functions"
(SIAM Press 2007), ISBN 9780898717822, Sect. 5.3.3, in particular Eq. 5.110, page 145.
Subsequently, Gil et al's book cites the another work:
W. Gautschi, "Computation of Bessel and Airy functions and of related Gaussian quadrature formulae",
BIT, 42 (2002), pp. 110-118, [@https://doi.org/10.1023/A:1021974203359] that is also available as
[@https://www.cs.purdue.edu/homes/wxg/selected_works/section_02/169.pdf Gautschi_169.pdf].
This Gauss-Laguerre quadrature is designed for `airy_ai(x)` with real-valued `x >= 1`.
The example uses Gauss-Laguerre quadrature integration to compute `airy_ai(x / 7)`
with `7 <= x <= 120` and where `x` is incremented in steps of 1.
During development of this example, we have empirically found the numbers of Gauss-Laguerre coefficients
needed for convergence when using various counts of base-10 digits.
Let's calibrate, for instance, the number of coefficients needed at the point `x = 1`.
Empirical data were used with __WolframAlphaGLCoefs :
``
Fit[{{21.0, 3.5}, {51.0, 11.1}, {101.0, 22.5}, {201.0, 46.8}}, {1, d, d^2}, d] FullSimplify[%]
0.0000178915 d^2 + 0.235487 d - 1.28301
or
-1.28301 + (0.235487 + 0.0000178915 d) d
``
We need significantly more coefficients at smaller real values than are needed
at larger real values because the slope derivative of `airy_ai(x)` gets more
steep as x approaches zero. `laguerre_order` is calculated using this equation.
Snippets from (copious) output from a progress bar during calculation of approximate root estimates
followed by calculation of accurate abscissa and weights is:
[gauss_laguerre_quadrature_output_1]
Finally the result using Gauss-Laguerre quadrature is compared with a calculation using `cyl_bessel_k`,
and both are listed, conclusively confirming that none differ by more than a small tolerance.
[gauss_laguerre_quadrature_output_2]
For more detail see comments in the source code for this example at [@../../example/gauss_laguerre_quadrature.cpp gauss_laguerre_quadrature.cpp].
[endsect] [/section:gauss_lagerre_quadrature Gauss-Laguerre quadrature]
[endsect] [/section:fp_eg Examples]