A collection of advanced mathematical special functions, defined by ISO/IEC IS 29124 and then added to ISO C++ 2017.
Introduction and History
The first significant library upgrade on the road to C++2011, TR1, included a set of 23 mathematical functions that significantly extended the standard transcendental functions inherited from C and declared in <cmath>.
cyl_neumann - Cylindrical Neumann functions or Cylindrical Bessel functions of the second kind
ellint_1 - Incomplete elliptic functions of the first kind
ellint_2 - Incomplete elliptic functions of the second kind
ellint_3 - Incomplete elliptic functions of the third kind
expint - The exponential integral
hermite - Hermite polynomials
laguerre - Laguerre functions
legendre - Legendre polynomials
riemann_zeta - The Riemann zeta function
sph_bessel - Spherical Bessel functions
sph_legendre - Spherical Legendre functions
sph_neumann - Spherical Neumann functions
The hypergeometric functions were stricken from the TR29124 and C++17 versions of this math library because of implementation concerns. However, since they were in the TR1 version and since they are popular we kept them as an extension in namespace __gnu_cxx:
The arguments suppled to the non-suffixed functions will be promoted according to the following rules:
If any argument intended to be floating point is given an integral value That integral value is promoted to double.
All floating point arguments are promoted up to the largest floating point precision among them.
NaN Arguments
If any of the floating point arguments supplied to these functions is invalid or NaN (std::numeric_limits<Tp>::quiet_NaN), the value NaN is returned.
Implementation
We strive to implement the underlying math with type generic algorithms to the greatest extent possible. In practice, the functions are thin wrappers that dispatch to function templates. Type dependence is controlled with std::numeric_limits and functions thereof.
We don't promote float to double or double to long double reflexively. The goal is for float functions to operate more quickly, at the cost of float accuracy and possibly a smaller domain of validity. Similaryly, long double should give you more dynamic range and slightly more pecision than double on many systems.
Testing
These functions have been tested against equivalent implementations from the Gnu Scientific Library, GSL and Boost and the ratio
is generally found to be within 10-15 for 64-bit double on linux-x86_64 systems over most of the ranges of validity.
Provide accuracy comparisons on a per-function basis for a small number of targets.
General Bibliography
See also
Abramowitz and Stegun: Handbook of Mathematical Functions, with Formulas, Graphs, and Mathematical Tables Edited by Milton Abramowitz and Irene A. Stegun, National Bureau of Standards Applied Mathematics Series - 55 Issued June 1964, Tenth Printing, December 1972, with corrections Electronic versions of A&S abound including both pdf and navigable html.
The old A&S has been redone as the NIST Digital Library of Mathematical Functions: http://dlmf.nist.gov/ This version is far more navigable and includes more recent work.
An Atlas of Functions: with Equator, the Atlas Function Calculator 2nd Edition, by Oldham, Keith B., Myland, Jan, Spanier, Jerome
Asymptotics and Special Functions by Frank W. J. Olver, Academic Press, 1974
Numerical Recipes in C, The Art of Scientific Computing, by William H. Press, Second Ed., Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery, Cambridge University Press, 1992
The Special Functions and Their Approximations: Volumes 1 and 2, by Yudell L. Luke, Academic Press, 1969