 esote.net

# math-consts

library for calculating many mathematical constants

My mathematical constants project is a library of C++ templates that work to calculate certain mathematical constants. I use Boost for mathematical functions (such as the Riemann zeta function) and basic constants (such as π). The list of mathematical constants is from this website.

Program was tested with g++. I recommend compiling with the -O3 flag. The library has been tested with C++17, C++14, and C++11. To call a constant, use the following syntax:

• constant::constant_name<T>() for most constants
• ex: constant::euler_mascheroni<double>()
• constant::func::champernowne<T>(b) and constant::func::favard<T>(r) for Champernowne and Favard constants

All constants have been verified to be accurate to 100 digits with two digits of rounding error, except the following constants:

• Gauss constant: 1 extra digit error
• Niven constant: 3 extra digits error
• Sierpinski constant K: 2 extra digits error
• Sierpinski constant S: 1 extra digit error
• Weierstrass constant: 1 extra digit error

To avoid rounding error, increase the accuracy of your type. Rounding error does not increase linearly, but rather sub-linearly: going from 100 to 500 digits of accuracy does not quintuple the rounding error, instead it goes from 2 digits to 3 for most constants. Most constants extend to many digits of accuracy without issue, except the Alladi-Grinstead constant, which becomes very slow at higher accuracy (greater than ~100).

I use Catch for unit testing.

### The Unfinished Constants

• Artin's constant
• Backhouse constant
• Inverse of Backhouse constant
• Barban's constant
• Bernstein's constant
• Besicovitch constant
• Blazys constant
• Boling's constant
• Brun's constant B2
• Brun's constant B4
• Brun's constant B'4
• Cahen's constant
• Copeland-Erdös constant
• Conway's constant
• Dottie number
• Efimov's scaling constant
• Embree-Trefethen constant
• Feigenbaum reduction parameter α
• Feigenbaum bifurcation velocity δ
• Feller-Tornier constant
• Flajolet-Odlyzko constant
• Foias constant
• Foias-Ewing constant
• Fransén-Robinson constant
• Gauss-Kuzmin-Wirsing constant
• Gerver's moving sofa constant
• Gibbs constant G
• Wilbraham-Gibbs constant G'
• Golomb–Dickman constant
• Gompertz constant
• Graham's constant G(3)
• Grossman's constant
• Heath-Brown–Moroz constant
• Kempner-Mahler number
• Kolakoski constant
• Komornik-Loreti constant
• Landau-Ramanujan constant
• Lagrange numbers
• Laplace limit constant
• Linnik's constant
• Liouville's constant
• Meissel-Mertens constant
• Mills' constant
• Minkowski-Bower constant
• MRB constant
• Oscillatory-integral MRB constant, modulus
• Oscillatory-integral MRB constant, real part
• Oscillatory-integral MRB constant, imag part
• Murata's constant
• Odlyzko-Wilf constant
• Otter's constant
• Otter's asymptotic constant βu
• Otter's asymptotic constant βr
• Plouffe's constant
• Prévost's constant
• Reciprocal even Fibonacci constant
• Reciprocal odd Fibonacci constant
• Rényi's parking constant
• Salem number
• Sarnak's constant
• Schwarzschild constant
• Shall-Wilson constant
• Soldner's constant