Mathematical constants
- Cost
- for the hypergeometric constants by binary splitting and for the reciprocal Fibonacci constant; Khinchin's constant and Glaisher's constant (below about to bits, depending on the number of threads) use sums of many full-precision terms and are much slower; Glaisher's constant at higher precision costs .
Most of the mathematical constants provided by arb are sums of hypergeometric series, series whose term ratio is a rational function of the index, and are evaluated by binary splitting. The series for , , , , , Catalan's constant, and are summed by the mp_real module, and the arb_const_ functions call it through _mp_real_const_arb; the formulas were chosen as the fastest among those collected by y-cruncher [Yee2025]. The implementation side (splitting trees, threads, the shared cache of exact floors) is described in Constants in mp_real; the sections below give the mathematics and the remaining constants.
Binary splitting#
Consider a sum with polynomials with integer coefficients. For define , , and , the partial sum scaled to an integer. Then for
(with the obvious extension for ), so the exact sum is obtained by a balanced recursion and one final division .
Proposition 1. If the series converges geometrically, so that terms give bits, and the integers have bits, binary splitting computes to bits in bit operations, which is .
Proof. At each of the levels of the recursion, the numbers multiplied have a total size of bits, and multiplication is superadditive, so each level costs . The final division costs .
The series below add between 2 and 47 bits per term. The constant factor is what distinguishes the formulas, and it is governed by the number of bits per term and the size of the coefficients [HP1998] [BZ2011].
Caching#
Each arb_const_ function keeps a thread-local cached ball. A request at precision above the cached precision recomputes the constant at bits; the result is then rounded to bits, and later requests at precision at most only round the cached value. , and are moreover read from static tables (of and to 4608 bits, of to 3456 bits) below these sizes, correctly rounded to nearest with a radius of half a unit in the last place. The caches are freed by flint_cleanup.
#
is computed by the Chudnovsky series [CC1988]
which adds about 47 bits (14 digits) per term. In the hypergeometric form used by mp_real, with , and . Methods based on the arithmetic-geometric mean [Sal1976] [Bre1976agm] have a better asymptotic complexity, , but are about three times slower in practice. arb_const_sqrt_pi and arb_const_log_sqrt2pi are computed from arb_const_pi with arb_sqrt and arb_log.
#
is summed by binary splitting, with and ; this is the simplest hypergeometric series and its cost is dominated by the final division.
Logarithms of integers#
is computed by Zuniga's series [Zun2025]
which adds 11.9 bits per term. (Earlier versions used another series of Zuniga [Zun2023b], with terms decreasing like .) uses the Machin-type formulas for the first three primes in terms of
for example , with the three series evaluated in parallel. The logarithms of more primes, used by the elementary functions (Elementary functions), come from larger sets of such formulas (arb_log_primes_vec_bsplit).
Euler's constant#
Euler's constant is computed by the Brent-McMillan formula [BM1980] [MPFR2012]
where is a free parameter and
The first two series are summed together up to with , where satisfies , and the asymptotic series up to . With these parameters the error is bounded by [BJ2013]. The current implementation sums and in one binary splitting over dual numbers, and chooses smooth over so that is cheap; see Constants in mp_real.
Catalan's constant#
Catalan's constant is computed by the series of Pilehrood and Pilehrood [PP2010]
which adds about 5.4 bits per term and was measured to be the fastest available formula.
and #
Apéry's constant is computed by a hypergeometric series found by Zuniga [Zun2023],
with a polynomial of degree 11 given in the source. is computed from Z.-W. Sun's identity
with the three parts , and computed in parallel when threads are available.
Khinchin's constant#
Khinchin's constant is computed from the formula [BBC1997]
where is a free parameter (arb_const_khinchin uses ). The finite sum has a minus sign: each product of logarithms is negative.
Proposition 2 (Truncation error). If the series over is truncated after , the error inside the brackets is at most .
Proof. The inner alternating sums lie in , so the remainder is bounded in absolute value by . By the integral bound,
and since , this is at most .
For an error of it therefore suffices to take . The Hurwitz zeta values are computed as , with arb_zeta_ui and a vector of powers that is updated from one to the next.
Glaisher's constant#
The Glaisher-Kinkelin constant is computed directly from this formula, with from acb_dirichlet_zeta_jet (see Zeta functions, polylogarithms and L-functions). Up to a cutoff (_acb_dirichlet_l_jet_use_afe: bits with one thread, about bits with 8 threads), this uses Euler-Maclaurin summation directly at ; the reflection formula is not used for , since the arithmetic of Euler-Maclaurin summation is cheaper at than at (by a factor 1.3–1.7 for ).
Euler-Maclaurin summation needs terms and Bernoulli numbers at precision , which costs time and bits of memory (several gigabytes at ). Above the cutoff, acb_dirichlet_zeta_jet instead computes to with the approximate functional equation (acb_dirichlet_l_fmpq_afe_jet), a sum of incomplete gamma function jets evaluated by binary splitting, in time and with memory.
The reciprocal Fibonacci constant#
is computed from Gosper's series [Gos1974], corrected in [Arn2012],
where is a Lucas number. The truncation error after terms is bounded by , so terms give bits. The series is not hypergeometric, but factoring out the multiplicative recurrence for turns it into a product of matrices with -bit entries, which binary splitting evaluates in quasilinear time.
Use in FLINT#
void arb_const_pi(arb_t z, slong prec)void arb_const_e(arb_t z, slong prec)void arb_const_log2(arb_t z, slong prec)void arb_const_log10(arb_t z, slong prec)void arb_const_euler(arb_t z, slong prec)void arb_const_catalan(arb_t z, slong prec)void arb_const_apery(arb_t s, slong prec)void arb_const_zeta5(arb_t s, slong prec)void arb_const_khinchin(arb_t z, slong prec)void arb_const_glaisher(arb_t z, slong prec)void arb_const_reciprocal_fibonacci(arb_t res, slong prec)void arb_const_sqrt_pi(arb_t z, slong prec)void arb_const_log_sqrt2pi(arb_t z, slong prec)The complex versions in acb (for example acb_const_pi) call these functions. The constants and , used by arb_hypgeom_gamma_fmpq, are also computed by mp_real; see Constants in mp_real and the gamma function at rational arguments.
The tutorial Computing π and other constants computes and other constants to many digits in complete programs.
Referenced from#
- Constants in mp_real (algorithm)
- Hypergeometric functions (algorithm)
- Evaluating special functions (overview)
- arb.h (module)
- Computing π and other constants (tutorial)
References#
- [Yee2025] A. J. Yee. y-cruncher: a multi-threaded pi-program, and its formula collection. http://www.numberworld.org/y-cruncher/ and https://github.com/Mysticial/y-cruncher-Formulas
- [HP1998] B. Haible and T. Papanikolaou, "Fast multiprecision evaluation of series of rational numbers", Algorithmic Number Theory (ANTS-III), LNCS 1423 (1998), 338–350
- [BZ2011] R. P. Brent and P. Zimmermann, Modern Computer Arithmetic, Cambridge University Press (2011), http://www.loria.fr/~zimmerma/mca/pub226.html
- [CC1988] D. V. Chudnovsky and G. V. Chudnovsky. Approximations and complex multiplication according to Ramanujan. In Ramanujan Revisited, Academic Press, 1988, 375–472.
- [Sal1976] E. Salamin. Computation of π using arithmetic-geometric mean. Mathematics of Computation 30:135 (1976), 565–570. https://doi.org/10.2307/2005327
- [Bre1976agm] R. P. Brent. Fast multiple-precision evaluation of elementary functions. Journal of the ACM 23:2 (1976), 242–251. https://doi.org/10.1145/321941.321944
- [Zun2025] J. Zuniga, "Fast Ramanujan-type Series for Logarithms. Part I", 2025, https://arxiv.org/abs/2506.08245
- [Zun2023b] J. Zuniga, "Are these fast convergent series for log(2) and log(3) already known and proven?", https://math.stackexchange.com/q/4854073
- [BM1980] R. P. Brent and E. M. McMillan, "Some new algorithms for high-precision computation of Euler's constant", Mathematics of Computation 34 (1980) 305-312.
- [MPFR2012] The MPFR team, "MPFR Algorithms" (2012), https://www.mpfr.org/algo.html
- [BJ2013] R. P. Brent and F. Johansson, "A bound for the error term in the Brent-McMillan algorithm", preprint (2013), https://arxiv.org/abs/1312.0039
- [PP2010] K. H. Pilehrood and T. H. Pilehrood. "Series acceleration formulas for beta values", Discrete Mathematics and Theoretical Computer Science, DMTCS, 12 (2) (2010), 223-236, https://hal.inria.fr/hal-00990465/
- [Zun2023] J. Zuniga, "Catalan's constant fast convergent series", https://mathoverflow.net/q/424055
- [BBC1997] D. H. Bailey, J. M. Borwein and R. E. Crandall, "On the Khintchine constant", Mathematics of Computation 66 (1997) 417-431
- [Gos1974] R. W. Gosper, "Acceleration of series", MIT AI Memo no.304, (March-1974). https://dspace.mit.edu/handle/1721.1/6088
- [Arn2012] J. Arndt, "On computing the generalized Lambert series", https://arxiv.org/abs/1202.6525
The FLINT team, “Mathematical constants,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/constants.html (generated 2026-11-02).
@misc{flint-doc-algorithms-special-functions-constants,
author = {{The FLINT team}},
title = {{Mathematical constants}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/special-functions/constants.html},
note = {Generated 2026-11-02}
}