fredrikj.net / blog /

Khinchin's constant and many others in subquadratic time

November 28, 2026

How many bit operations should it take to compute a $p$-digit approximation of a real number given by an infinite series $$\sum_{k=1}^{\infty} F(k)?$$ My new preprint Computing infinite sums of holonomic functions describes an algorithm that for a large class of analytic functions $F$ solves this problem in $\widetilde O(p^{3/2})$. The best previous algorithms for the same class were quadratic in $p$ except for very special summands like rational functions of $k$. The method in the paper gives, for example, the first known subquadratic algorithms to calculate Khinchin's constant, a number which in the words of Eric Weisstein is "notoriously difficult to calculate to high precision".

The paper is accompanied by a git repository containing demonstration code, million-digit values of various constants computed with the method, Lean proofs, and supplementary notes. The research was heavily AI-assisted (mainly Claude Opus 5.5), as explained further below, and much of the paper's text was AI-generated (interactively over the course of two weeks and with substantial manual editing, I should say). Thanks to Drew Sutherland for providing me with a Claude subscription that made this work possible.

Contents

Algorithm

The method works for any holonomic function $F$, i.e. any solution of a linear ODE with polynomial coefficients, satisfying an additional regularity condition at infinity (see below).

Infinite series in this class include every sum $\sum_{k=1}^{\infty} A(k)$ where $A$ is an algebraic function, and more generally sums like $\sum_{k=1}^{\infty} G(A(k))$, where $G$ is a logarithm, arctangent, ${}_2F_1$, ${}_3F_2$, complete elliptic integral, dilogarithm, or other suitably regular holonomic function, and for sums over polynomial expressions of such functions. The class of summands is closed under integration, and thus contains periods of families of algebraic curves depending algebraically on $k$. The method also admits sums of such functions $F$ with a periodic, power or exponential prefactor like $(-1)^k F(k) / k^s$, $z^k F(k)$, or $e^{-t k^r} F(k)$.

To be precise, the subquadratic complexity bound requires that the coefficient data encoding $F$ (its differential equation and generalized initial values at infinity) consists of algebraic numbers and that the extra parameters $s$, $z$, $t$, $r$ above are algebraic. For sums with stretched-exponential prefactor $e^{-t k^r}$ the result is only sketched and only for restricted values of $r$ (in general only for $r = 1 / q$ for integer $q \ge 1$). If some coefficients are transcendental numbers given by $p$-bit approximations, the method still works but the complexity degenerates to quadratic.

The idea is to construct a Dirichlet series $$\zeta_F(s) = \sum_{k=1}^{\infty} \frac{F(k)}{k^s}$$ of which the sum is a special value, e.g. $\sum_{k=1}^{\infty} F(k) = \zeta_F(0)$. The classical Riemann zeta function $\zeta(s)$ is the trivial case $F = 1$ and the general $\zeta_F$ can be viewed as a deformation of $\zeta$. We now use a generalization of the theta splitting from Riemann's second proof of the functional equation. For a splitting parameter $u_0 > 0$, we can write (slightly simplified) $$ \zeta_F(s) = \sum_{k=1}^{\infty}I_k(s) + \sqrt\pi\sum_{m=1}^{\infty}J_m(s) + M(s), $$ where $M(s)$ is a simple explicit function and the terms of the two infinite series are given by $$I_k(s) = \int_{u_0}^\infty e^{-k^2u}h_s(u) du, \quad J_m(s) = \int_0^{u_0}u^{-1/2}e^{-\pi^2m^2/u}h_s(u) du$$ where $$h_s(u) = \sum_{n=0}^{\infty} a_n \frac{u^{(s+n)/2-1}}{\Gamma(\frac{s+n}{2})}, \quad F(1/x) = \sum_{n=0}^{\infty} a_n x^n.$$ When $F = 1$, the terms $I_k$ and $J_m$ become incomplete gamma functions with Gaussian decay $I_k \approx e^{-u_0 k^2}$, $J_m \approx e^{-\pi^2 m^2/u_0}$. This method of computing $\zeta(s)$ essentially costs $O(p^{1/2})$ incomplete gamma functions, each of which can be computed in quasilinear time when $s$ is an algebraic number, yielding the subquadratic complexity bound.

The new observation is that when $F$ is holonomic, the terms $I_k$ and $J_m$ are also holonomic (as functions of $k$ and $m$), with the same Gaussian decay as in the Riemann zeta case, and they can be evaluated rapidly using the bit-burst algorithm. The steps to prove this and to turn it into a concrete algorithm are quite technical: $I_k$ and $J_m$ are not simple expressions of $F$ but defined by their own systems of differential and recurrence relations. We also need some more machinery to handle summands with a (regular) singularity at infinity (for which the power series expansion $F(1/x) = \sum_{n=0}^{\infty} a_n x^n$ given above must be replaced by a generalized series expansion with non-integer powers and logarithms), and summands with exponential prefactors (see below). Working out and writing down all the details here is where Claude came in very handy.

The theta splitting technique makes many appearances in the number theory and physics literature, notably in the work of the late Richard Crandall, but to my knowledge it has not been applied to holonomic summands as such. The same kind of splitting is classical for sequences $c_k$ defining $L$-functions $L(s) = \sum_k c_k k^{-s}$, and is used in the $L$-function algorithms of Rubinstein, Dokchitser and others. Such functions satisfy an "approximate functional equation" similar to the above with two series of holonomic functions defined by inverse Mellin transforms, and the construction gives subquadratic complexity for degree-1 $L$-functions at algebraic points. The overlap with the family $\zeta_F$ is small; our $\zeta_F$ is generally not an $L$-function (it will not generally have an Euler product or a functional equation).

Khinchin's constant

The background: I was recently looking for a fast way to compute Khinchin's constant $K$, one of the famous (if slightly-less-famous-than-$\pi$) constants of classical analysis. For almost every real number $x$, the coefficients of the continued fraction $$x = a_0+\cfrac{1}{a_1+\cfrac{1}{a_2+\cfrac{1}{a_3+\cfrac{1}{\ddots}}}},$$ have geometric mean $\lim_{n \rightarrow \infty } \left( a_1 a_2 \cdots a_n \right) ^{1/n} = K \approx 2.68545$. This constant is not known to be representable in terms of any familiar special functions, but it has the simple series representation $$\log K\,\log 2 = -\sum_{k=2}^{\infty}\log\Bigl(1-\frac1k\Bigr)\log\Bigl(1+\frac1k\Bigr).$$ If one takes the glasses off, this looks vaguely like Euler's constant $$\gamma = \sum_{k=1}^{\infty}\Bigl(\frac1k - \log\Bigl(1+\frac1k\Bigr)\Bigr)$$ which of course is a particular value (or technically a Laurent coefficient) of the Riemann zeta function.

I had recently looked a bit at multidimensional generalizations of $\zeta$. For example, as a benchmark problem, the new Epstein zeta function in FLINT easily gives the Madelung constant for NaCl $$M = -\sum_{(i,j,k) \ne 0} \frac{(-1)^{i+j+k}}{\sqrt{i^2+j^2+k^2}} = 1.7475645946331821906\ldots,$$ to one million digits, here via the Epstein zeta value $-Z_{(\mathbb{Z}^3,1)}\bigl(0; (\tfrac12,\tfrac12,\tfrac12)\bigr)$ and a theta splitting expansion due to Crandall. This gave me the idea that $K$ might be expressed in terms of some kind of zeta-like function too and computed via theta splitting. So I asked Claude to construct such an algorithm, which it promptly did!

In fact, the paper presents three subquadratic algorithms for Khinchin's constant, called K1, K2 and K3. The first one (K1) is the most mathematically elegant: it expresses $K$ as $\exp(-Z'(0))$ where $$Z(s) = \zeta_{\mu}(s) = \sum_{k=1}^{\infty} \frac{\mu_k}{k^s}, \quad \mu_k = \log_2\left(1 + \frac{1}{k(k+2)}\right)$$ is a function named the "Khinchin zeta function" in the paper. The quantity $\mu_k$ is the mass function of the Gauss-Kuzmin distribution. The discrete moments $K_q = Z(-q)^{1/q}$ ($q < 1$) give the corresponding Hölder means of the partial quotients of a generic real number, with $K_{-1} = 1/Z(1)$ the harmonic mean. Computing $K$ as a derivative of $Z$ is somewhat analogous to computing $\gamma$ as a Laurent coefficient of $\zeta$.

Algorithm K2 computes $\log K \log 2 = -\zeta_F(0)$ where the summand is that of the "simple series representation", $F(k) = \log(1-1/k)\log(1+1/k)$, $k \ge 2$. This is analogous to computing $\gamma$ as $\zeta_H(0)$ where $H(k) = (1/k - \log(1+1/k))$. Although K1 and K2 give the same number, the holonomic functions $F$ being summed differ and lead to entirely different systems of terms $I_k$ and $J_m$. In practice, algorithm K2 is about 4x faster than K1.

Algorithm K3 uses an entirely different series. This seemed like a long shot, but I asked Claude to also work out the theta splitting for the series $$\log K \log 2 = \log^2 2 + \operatorname{Li}_2(-\tfrac12) + \frac12\sum_{k=2}^{\infty}(-1)^k \operatorname{Li}_2\Bigl(\frac{4}{k^2}\Bigr)$$ where $\operatorname{Li}_2$ is the dilogarithm (Bailey, Borwein and Crandall attribute this formula to Zagier and derive it from an integral representation; the paper contains a self-contained proof based on telescoping and functional equations). In the notation of the paper, this is $$\log K\log 2 = \log^22 + \operatorname{Li}_2(-\tfrac12) + \tfrac12 L_G(0,\chi)$$ where $L_G(s,\chi) = \sum_{k} \chi(k) G(k) k^{-s}$ is a twisted zeta function, here twisted by the alternating sign $\chi(k) = (-1)^{k}$, for the holonomic function $$G(k) = \operatorname{Li}_2\Bigl(\frac{4}{k^2}\Bigr) \quad (k \ge 2).$$ Although this non-elementary summand at first looks more complicated, amazingly, the holonomic functions in the theta splitting become even simpler than those for both K1 and K2, and algorithm K3 runs about 5x faster than K2 (19x faster than K1). Here is the complete formula behind algorithm K3: for a tuning parameter $u_0 > 0$, $$\log K\log 2 = \log^2 2 + \operatorname{Li}_2(-\tfrac12) + \frac{\pi^2}{12} + \frac12\Bigl(M + \sum_{k=3}^{\infty}(-1)^kI_k + \sum_{m=0}^{\infty}J_m\Bigr),$$ where, with $x_k = k^2u_0$, $c_m = \pi^2(m+\frac12)^2$, $y_m = c_m/u_0$, and using the notation $e_n(x) = \sum_{i=0}^{n-1} x^i / i!$, $$I_k = e^{-x_k}\sum_{n=1}^{\infty}\Bigl(\frac{4}{k^2}\Bigr)^n\frac{e_n(x_k)}{n^2},$$ $$J_m = \frac{2\pi}{\sqrt{c_m}}\operatorname{erfc}(\sqrt{y_m})\bigl(\operatorname{Ci}(4\sqrt{c_m}) - \gamma - \log(4\sqrt{c_m})\bigr) + \sqrt\pi\, e^{-y_m}\mathcal B(c_m),$$ $$\mathcal B(c) = \sum_{n=1}^{\infty}\frac{4^n}{n\cdot n!}\,\beta_n(c),$$ $$\beta_n(c) = \sum_{i=1}^{n}(-c)^{n-i}u_0^{i-\frac12}\frac{\Gamma(i-\frac12)}{\Gamma(n+\frac12)},$$ $$M = \sum_{n=1}^{\infty}\frac{4^n}{n^2}\Bigl(\pi_n(u_0) - 4^{-n}\pi_n(4u_0)\Bigr) - \frac12\sum_{n=1}^{\infty}\frac{(4u_0)^n}{n^2\,n!},$$ $$\pi_n(y) = 1 - e^{-y}e_n(y).$$ The primary terms $I_k$ are computed using binary splitting and the dual terms $J_m$ are computed using the bit-burst algorithm. An unoptimized reference implementation in Python shows how this works concretely.

FLINT implementation and computations

An optimized implementation of algorithm K3 (using FFT matrix multiplication and so on; many times faster than the reference implementation) is part of FLINT 3.7-dev and arb_const_khinchin now uses it above $5 \cdot 10^6$ bits. At lower precision it uses an optimized implementation of the classical zeta expansion $$\log K \log 2 = \sum_{n=1}^\infty \frac {\zeta (2n)-1}{n} \sum_{k=1}^{2n-1} \frac{(-1)^{k+1}}{k}$$ the same quasi-quadratic (in practice quasi-cubic) algorithm that has been used for all previous record computations of $K$, most recently to $2 \cdot 10^6$ digits by Reza Ghazi.

I have computed Khinchin's constant with both FLINT's zeta expansion code (itself strongly optimized) and the new theta splitting algorithm (K3) at various sizes up to $10^7$ digits; the timings on my 8-core laptop are as follows:

zeta expansion theta splitting
digits CPU wall memory k/dual terms CPU wall memory
105 18.7 s 2.43 s 78 MB 1 919/38 88.3 s 11.2 s 223 MB
106 4 239 s 544 s 1.27 GB 6 069/121 5 416 s 679 s 1.08 GB
2·106 23 485 s 3 372 s 1.96 GB 8 583/171 18 815 s 2 355 s 1.78 GB
107 1 852 090 s 235 475 s 15.3 GB 19 194/382 327 183 s 40 921 s 10.5 GB

The theta splitting is firmly ahead at the size of the previous world record and nearly 6x faster at 10 million digits.

The k/dual terms column in the table shows how the work is balanced; the tuning parameter is chosen to give many cheap primary $I_k$ terms and fewer of the expensive dual terms $J_m$.

Since all computations were done rigorously in ball arithmetic and the two independent algorithms give the same result (also confirmed by a second run of the zeta method with different parameters on a different machine done by Vincent Neiger), the obtained 10 million digits are certainly correct. This establishes in particular that if $K = P / Q$ is a rational number, both $P$ and $Q$ must be larger than $10^{5\,000\,000}$. Some more data for the continued fraction of $K$ is presented in the paper.

Geometric mean of the first n partial quotients of Khinchin's constant, converging to K

The geometric mean $G_n = (a_1 a_2 \cdots a_n)^{1/n}$ of the first $n$ partial quotients of $K$ itself, for $10 \le n \le N = 9\,699\,141$ (all the partial quotients determined by the $10^7$ digits). At $n = N$, $G_N = 2.68672\ldots$ differs from $K$ by about $1.3 \cdot 10^{-3}$, an error of order $1/\sqrt{N}$: about $1.5$ standard deviations, well within the band $K e^{\pm 2\sigma/\sqrt n}$ ($\sigma \approx 1.10$) expected for a typical real number.

If someone with a large multicore machine and lots of RAM wants to try to reach $10^8$ digits, that should now just be a matter of calling the new FLINT implementation. At that scale the classical zeta expansion would no longer be practical for a verification run, however.

Other series and constants

After looking at the structure of the algorithms for Khinchin's constant, I suspected that the same method ought to work for summing arbitrary holonomic functions $F(x)$. It took a long session with Claude to work out most of the details, which are given in the paper. In general, any holonomic function is, near infinity, a linear combination of generalized series of the form $$F(x) = \exp\bigl(Q(x^{1/q})\bigr)\, x^{\rho} \sum_{j=0}^{J} (\log x)^j\, \varphi_j\bigl(x^{-1/q}\bigr)$$ where $Q$ is a polynomial without constant term and $\varphi_j$ is a formal power series. These expansions turn out to have just the right form for the theta splitting, with one important restriction. If infinity is a regular singular point, then all solutions have $Q = 0$ and the series $\varphi_j$ are convergent. If infinity is an irregular singular point, there are solutions with $Q \ne 0$ and the series $\varphi_j$ may be divergent. The method described in the paper requires a regular singular point at infinity, but allows irregular-like summands in factored form $G(x) = e^{-t x^r} F(x)$ where $F(x)$ is regular at infinity. I believe the method can be generalized to irregular singularities as well which would allow computing sums of things like Bessel functions of arguments approaching infinity, but this would require resummation to deal with the divergent series, which is left as an open problem.

To capture periodic and exponential factors that are not regular at infinity, the paper introduces the following companion functions of the zeta function $\zeta_F$ (with $|z| < 1$ and $0 < r < 2$). The twisted zeta function ($\chi$ being any periodic sequence; see the example K3 above): $$L_F(s,\chi) = \sum_{k=1}^{\infty} \frac{\chi(k) F(k)}{k^s}$$ The polylogarithm: $$\operatorname{Li}_F(s,z) = \sum_{k=1}^{\infty} \frac{z^k F(k)}{k^s}$$ The Lerch transcendent: $$\Phi_F(z,s,a) = \sum_{k=0}^{\infty} \frac{z^k F(k)}{(k+a)^s}$$ The damped zeta function: $$\Lambda_F(s;\tau,r) = \sum_{k=1}^{\infty} \frac{e^{-\tau k^r} F(k)}{k^s}$$

The theta splitting algorithm is constructed for each function; for $F = 1$ it coincides with the classical formulas for Riemann zeta and Dirichlet $L$-functions and with Crandall's formula for the classical polylogarithm and Lerch transcendent.

The paper gives a long list of constants and families of constants from classical analysis, number theory, geometry, probability theory and physics that can be expressed in terms of these functions, and which can thereby be computed in subquadratic time. Claude dug up most of these examples from the literature, some autonomously and others following my suggestions of specific application areas where sums of this kind might arise.

As proof of concept, I had Claude implement a handful of constants in a generic program (holsum in the repository), and I computed each constant to one million digits on my laptop. The code is much less optimized than the FLINT code for Khinchin's constant and the error bounds are heuristic, not rigorous. The following table shows timing results with 8 threads: wall time (in parentheses, CPU time summed over the threads), with links to the digit files and OEIS links where these exist. The first two timing columns are the classical reference methods, expansion in zeta values and Euler-Maclaurin summation.

constant digits zeta values Euler–Maclaurin theta splitting
$\mathcal A = \sum_{k\ge2}\frac{\log k}{k^2-1}$
A340440 · 106 digits
104 0.81 s (4.26 s) 0.82 s (2.51 s) 0.39 s (2.35 s)
105 134 s (1 059 s) 353 s (1 695 s) 17.9 s (137 s)
106 – – 1 063 s (8 435 s)
$\mathcal C = \sum_{k\ge1}\frac{\log k}{k(k+1)}$
A085361 · 106 digits
104 3.89 s (29.8 s) 0.79 s (2.49 s) 1.01 s (7.00 s)
105 3 481 s (27 817 s) 389 s (1 888 s) 59.7 s (469 s)
106 – – 3 662 s (29 201 s)
Khinchin's harmonic mean $K_{-1}$
A087491 · 106 digits
104 4.12 s (31.9 s) 1.16 s (3.36 s) 2.05 s (14.7 s)
105 3 762 s (30 050 s) 569 s (2 287 s) 127 s (997 s)
106 – – 6 458 s (51 551 s)
Theodorus $\mathcal T = \sum_{k\ge1}\frac{1}{(k+1)\sqrt k}$
A226317 · 106 digits
104 – 0.50 s (0.98 s) 1.09 s (7.17 s)
105 – 115 s (181 s) 60.4 s (476 s)
106 – – 3 482 s (27 804 s)
Hardy–Littlewood $H(1) = \sum_{k\ge1}\frac{\sin(1/k)}{k}$
A362753 · 106 digits
104 0.15 s (1.01 s) 0.93 s (4.34 s) 0.86 s (6.15 s)
105 39.1 s (304 s) 345 s (1 925 s) 52.8 s (419 s)
106 – – 3 564 s (28 465 s)
Somos $\sigma = \prod_{k\ge1}k^{1/2^k}$
A112302 · 106 digits
104 – 0.18 s (1.07 s)† 1.41 s (10.4 s)
105 – 19.1 s (142 s)† 82.8 s (652 s)
106 – – 5 268 s (41 423 s)
vortex rings $U(1)$
106 digits
104 8.58 s (53.5 s) 8.16 s (61.3 s) 1.34 s (9.85 s)
105 6 905 s (53 348 s) – 85.6 s (677 s)
106 – – 4 736 s (37 795 s)
$\operatorname{Tr}\Delta^{-3/2}$ on $S^2$
106 digits
104 2.38 s (2.38 s) 0.54 s (1.31 s) 0.65 s (4.12 s)
105 663 s (663 s) 124 s (233 s) 32.7 s (255 s)
106 – – 2 021 s (16 144 s)
$S = \sum_{k\ge1}e^{-\sqrt k}$
106 digits
104 – 0.69 s (2.92 s) 2.11 s (15.9 s)
105 – 302 s (1 703 s) 129 s (1 025 s)
106 – – 8 379 s (66 975 s)

†For $\sigma$, direct summation over prime powers instead of Euler–Maclaurin summation.

As an order-of-magnitude estimate, we see that it takes a second to obtain $10^4$ digits, a minute to obtain $10^5$ digits and an hour to obtain $10^6$ digits with theta splitting. The crossover where it beats the classical algorithms generally seems to be somewhere between $10^4$ and $10^7$ digits depending on the constant; usually on the lower end of this. I did not run the classical methods beyond $10^5$ digits to find out precisely where the crossover occurs for the constants where the classical methods are particularly cheap.

The context of some of these constants is explained a bit more below.

The constant of Theodorus

The spiral of Theodorus (Quadratwurzelschnecke) is built from right triangles with legs $\sqrt k$ and $1$, placed one after the other around a common vertex, so that the $k$-th vertex lies at distance $\sqrt k$ from it. Davis interpolated the vertices by a smooth spiral, whose slope at $(1,0)$ is given by the constant of Theodorus $$\mathcal T = \sum_{k=1}^{\infty}\frac{1}{(k+1)\sqrt k} = \zeta_F(\tfrac12), \quad F(k) = \frac{1}{k+1},$$ $\mathcal T \approx 1.8600250792$ (A226317), a classic example of a sum of an algebraic function that does not seem to reduce to other constants. Here we choose $F$ so that evaluation is done at $s = \frac12$ rather than $s = 0$, which simplifies the primary terms in the theta splitting.

The spiral of Theodorus with Davis's interpolating spiral and its tangent at (1, 0)

The spiral of Theodorus and Davis's interpolating spiral $T(\alpha) = \prod_{k=1}^{\infty} \frac{1 + i/\sqrt{k}}{1 + i/\sqrt{k+\alpha}}$, which satisfies $|T(\alpha)|^2 = \alpha + 1$ and passes through all the vertices. Since $T'(0) = (1 + i\mathcal{T})/2$, its slope at $(1, 0)$ is the constant of Theodorus $\mathcal{T} = \sum_{k=1}^{\infty} \frac{1}{(k+1)\sqrt{k}} \approx 1.8600250792$.

A relative is Hlawka's constant, the constant term in the angle swept by the first $n-1$ triangles, $\sum_{k<n} \operatorname{arctan}(1/\sqrt k) = 2\sqrt n + C_{\mathrm H} + o(1)$. It is the regularized value $C_{\mathrm H} = \zeta_G(0)$ with $G(k) = \arctan(1/\sqrt k)$, and $C_{\mathrm H} \approx -2.1577829966$.

Somos's quadratic recurrence constant

Somos's constant $$\sigma = \sqrt{1\sqrt{2\sqrt{3\cdots}}} = \prod_{k=1}^{\infty}k^{1/2^k} \approx 1.6616879496$$ governs the growth of the recurrence $g_n = n g_{n-1}^2$, $g_0 = 1$, whose solutions grow like $\sigma^{2^n}/(n+2+O(1/n))$. Its logarithm is a derivative of the ordinary polylogarithm, $$\log\sigma = \sum_{k=1}^{\infty}\frac{\log k}{2^k} = -\partial_s\operatorname{Li}_s(\tfrac12)\big|_{s=0},$$ or alternatively $\operatorname{Li}_F(0,\frac12)$ with $F(k) = \log(1+1/k)$. The geometric factor $2^{-k}$ is handled as a twist by a complex "character", which moves the dual points of the theta splitting into the complex plane (for $F = 1$ this is Crandall's formula for the polylogarithm). The same works for the generalized Euler constant function of Sondow and Hadjicostas, $\gamma(z) = \sum_{k\ge1}z^{k-1}(\frac1k - \log(1+\frac1k))$, with $\gamma(\frac12) = 2\log(2/\sigma)$. This one is a case where the theta splitting only wins asymptotically: the special structure of $\sum_k 2^{-k}\log k$ allows a cheap quasi-quadratic method (a sum over prime powers) which is faster in practice up to roughly $10^7$ digits (extrapolated).

The Hardy-Littlewood function

The function $$H(x) = \sum_{k=1}^{\infty}\frac1k\sin\frac xk = \zeta_F(1), \quad F(k) = \sin(x/k),$$ studied by Hardy and Littlewood, is a standard test case for summing slowly convergent series, and $H(1) \approx 1.4728282320$. The classical zeta expansion $$H(x) = \sum_{m=0}^{\infty}(-1)^m\zeta(2m+2)\frac{x^{2m+1}}{(2m+1)!}$$ needs only even zeta values (Bernoulli numbers) with factorially decaying coefficients, which as in the previous example makes the classical method unusually competitive. It is still quasi-quadratic, and the theta splitting overtakes it somewhere around $1.6 \cdot 10^5$ digits (extrapolated). This example shows that the holonomic function $F$ can have irregular singularities as long as they are not located at infinity (here the irregular singularity is at 0).

Periodic arrays of vortex rings

A row of coaxial vortex rings of radius r and circulation Gamma, spaced lambda r apart, translating along their common axis

A periodic array of coaxial thin-cored vortex rings of radius $r$ and circulation $\Gamma$, spaced $\lambda r$ apart. Each ring is also carried forward by the flow that all the others induce at its core, so the row translates faster than an isolated ring (speed $U_0$) by $U(\lambda)\,\Gamma/r$, where $U(\lambda) = \lambda^{-3}\zeta_F(3)$ with $F(k) = {}_2F_1(\frac32,\frac32;2;-\frac{4}{\lambda^2k^2})$; for rings spaced one radius apart, $U(1) \approx 0.2688277250$.

This is a fun physical application with a nonelementary summand which Claude found in the literature: consider an infinite row of identical coaxial thin-cored vortex rings of radius $r$ and circulation $\Gamma$, spaced $\lambda r$ apart. The rings ahead and behind push each ring forward alike, so the row translates rigidly, faster than an isolated ring by $U(\lambda)\,\Gamma/r$ where (Vasilev 1916, Levy and Forsdyke 1928) $$U(\lambda) = \frac{1}{2\pi}\sum_{n=1}^{\infty}\int_0^{2\pi}\frac{(1-\cos\varphi)\,d\varphi}{\bigl(2(1-\cos\varphi)+n^2\lambda^2\bigr)^{3/2}}.$$ Each summand is a complete elliptic integral, and $$U(\lambda) = \lambda^{-3}\zeta_F(3), \quad F(k) = {}_2F_1\Bigl(\frac32,\frac32;2;-\frac{4}{\lambda^2k^2}\Bigr),$$ with for example $U(1) \approx 0.2688277250$ and $U(2) \approx 0.0777025729$. The same elliptic integrals give the mutual inductance of coaxial circular loops, and the coupling sum for magnetoinductive waves in a chain of ring resonators is the twisted value $S_\lambda(\theta) = \frac{\pi}{2\lambda^3}L_F(3, \cos k\theta)$ with $F(k) = {}_2F_1(\frac32,\frac32;3;-\frac{4}{\lambda^2k^2})$; for rings spaced one diameter apart, at the band edges, $S_2(0) \approx 0.1479284112$ and $S_2(\pi) \approx -0.0969577191$.

Here the zeta expansion needs odd zeta values with growing coefficients; the theta splitting is well ahead already at $10^4$ digits and about 80 times faster at $10^5$ digits.

Spectral sums and partition functions

Many quantities in mathematical physics are traces $\sum_k d_k\,\phi(\lambda_k)$ over a discrete spectrum whose eigenvalues $\lambda_k$ and multiplicities $d_k$ are algebraic functions of a quantum number $k$. When $d_k\phi(\lambda_k) = k^{-s}F(k)$, the trace is a value of $\zeta_F$. Examples include spectral zeta functions and determinants, Casimir energies, Kaluza-Klein towers and partition functions.

Real spherical harmonics for l = 0 to 3, arranged in rows of 2l+1

The eigenfunctions of the Laplacian on the unit sphere $S^2$ are the spherical harmonics (red positive, blue negative): for each $\ell$ there are $2\ell+1$ of them, all with eigenvalue $\ell(\ell+1)$.

For example, the Laplacian $\Delta$ on the unit sphere $S^2$ (with the sign convention that makes it positive) has the spherical harmonics as eigenfunctions, with eigenvalues $\lambda_\ell = \ell(\ell+1)$ and multiplicities $2\ell+1$. Leaving out the eigenvalue $0$, its spectral zeta function is $$\zeta_\Delta(s) = \operatorname{Tr}\Delta^{-s} = \sum_{\ell=1}^{\infty}\frac{2\ell+1}{(\ell(\ell+1))^s}.$$ The sum converges for $\operatorname{Re}(s) > 1$ and extends to a meromorphic function of $s$. To put it in the form $\zeta_F$, fix $s$ and pull out the leading power of $\ell$: $(2\ell+1)(\ell(\ell+1))^{-s} = \ell^{1-2s}F(\ell)$ with $$F(k) = \Bigl(2+\frac1k\Bigr)\Bigl(1+\frac1k\Bigr)^{-s}, \qquad \zeta_\Delta(s) = \zeta_F(2s-1).$$ Note that $F$ depends on the chosen $s$: each value of $\zeta_\Delta$ is a value of $\zeta_F$ for a different function $F$.

For integer $s$ the summand is rational and $\zeta_\Delta(s)$ reduces to ordinary zeta values (for example, $\zeta_\Delta(2) = 1$ by telescoping). The number $$\operatorname{Tr}\Delta^{-3/2} = \zeta_\Delta(\tfrac32) = \sum_{\ell=1}^{\infty}\frac{2\ell+1}{(\ell(\ell+1))^{3/2}} \approx 2.0705444763,$$ is one of the constants computed to a million digits using theta splitting. This particular value was just chosen as the simplest computationally interesting representative of this class of spectral sums; it doesn't have an especially striking physical interpretation (if you insist on having one, three suggestions by Claude: "up to a factor $4\pi$, the mean square of a random field on the sphere", "a coefficient of the Casimir energy of a massive field", and "a time-weighted total of how much more likely Brownian motion on the sphere is to return to its starting point than its long-run uniform distribution predicts").

Values outside the region of convergence are defined by analytic continuation, as in $\zeta(-1) = -\frac1{12}$. An example is the Casimir energy of a massless field on the sphere, whose zeta-regularized value is $E = \tfrac12\zeta_\Delta(-\tfrac12) = \tfrac12\zeta_F(-2) + \tfrac1{48} \approx -0.1325477746,$ where now $F(k) = (2+\frac1k)(1+\frac1k)^{1/2}$ (the case $s = -\frac12$). The extra rational term $\frac1{48}$ comes from $F$ depending on $s$: the analytic continuation in $s$ also changes $F$, and at $s = -\frac12$ this adds a correction to the value $\zeta_F(-2)$ of the fixed function $F$.

Partition functions of bound states are another source of sums of holonomic functions. The internal partition function of hydrogen diverges, and the Planck-Larkin partition function regularizes it as $$\sigma(T) = \sum_{n=1}^{\infty}2n^2\Bigl(e^{\xi/n^2} - 1 - \frac{\xi}{n^2}\Bigr) = 2\zeta_F(-2), \quad F(k) = e^{\xi/k^2} - 1 - \frac{\xi}{k^2},$$ where $\xi = I/(k_BT)$; for example $\sigma \approx 2.1104548763$ at $\xi = 1$ (about 158 000 K). Like the Hardy-Littlewood function above, this summand has an irregular singularity at zero but is regular at infinity, so the theta splitting method applies. Thermal integrals against the Bose-Einstein weight also lead to such sums: expanding $1/(e^t-1) = \sum_k e^{-kt}$, $\int_0^\infty G(t)/(e^t-1)\,dt = \sum_k F(k)$ where $F$ is the Laplace transform of $G$, for instance $$\int_0^\infty\frac{t\,J_0(t)}{e^t-1}\,dt = \sum_{k=1}^{\infty}\frac{k}{(k^2+1)^{3/2}} \approx 0.9005247353.$$

Stretched-exponential sums

Energy levels that grow like a fractional power of the quantum number lead to damped zeta functions. A specific example suggested by Claude: in graphene in a magnetic field $B$, the charge carriers behave as massless Dirac fermions whose Landau levels are the non-equidistant $E_{\pm n} = \pm E_1\sqrt n$ with $E_1 \approx 36\,\mathrm{meV}\cdot(B/1\,\mathrm T)^{1/2}$.

Landau levels of graphene on the Dirac cone, with their Boltzmann weights

In graphene, the charge carriers form a Dirac cone $E = \pm\hbar v_F|k|$. A magnetic field $B$ quantizes their orbits into rings on the cone with energies $E_{\pm n} = \pm E_1\sqrt{n}$, $E_1 = v_F\sqrt{2e\hbar B}$, which crowd together instead of being equally spaced as for an ordinary electron gas. At $k_BT = E_1$ the Boltzmann weights of the levels are $e^{-\sqrt n}$, and their sum is the stretched-exponential sum $S = \sum_{n=1}^{\infty} e^{-\sqrt n} = \Lambda(0;1,\tfrac12) \approx 1.6704068180$.

The Boltzmann sums over the conduction-band levels are $$\sum_{n=1}^{\infty}n^{-s}e^{-\tau\sqrt n} = \Lambda(s;\tau,\tfrac12), \quad \tau = E_1/(k_BT).$$

A second example is the wrapped symmetric $\alpha$-stable distribution on the circle, which is also the heat kernel of the fractional Laplacian: $$p_t(x) = \frac1{2\pi}\Bigl(1 + 2\sum_{k=1}^{\infty}e^{-tk^\alpha}\cos kx\Bigr), \quad p_t(0) = \frac{1+2\Lambda(0;t,\alpha)}{2\pi}.$$ At the simplest parameters both the above examples lead to $S = \sum_{k=1}^{\infty}e^{-\sqrt k} = \Lambda(0;1,\frac12) \approx 1.6704068180$, one of the constants computed to one million digits, with $p_1(0) = (1+2S)/(2\pi) \approx 0.6908619472$.

The constants of Euler, Stieltjes, Stirling and Glaisher

Another class of examples which are important to note, but for which I did not run any computations: many classical constants are constant terms in asymptotic expansions of partial sums. Examples include Euler's constant $$\sum_{k\le n} \frac{1}{k} = \log n + \gamma + o(1),$$ the Stieltjes constants $$\sum_{k\le n} \frac{(\log k)^m}{k} = \frac{(\log n)^{m+1}}{m+1} + \gamma_m + o(1),$$ the constant $\log\sqrt{2\pi}$ in Stirling's formula for $\log n!$, and Glaisher's constant $A$ for the hyperfactorials, $$\sum_{k=1}^{n}k\log k = \Bigl(\frac{n^2}2 + \frac n2 + \frac1{12}\Bigr)\log n - \frac{n^2}4 + \log A + o(1).$$ In general, the constant term of $\sum_{k\le n}F(k)$ is $\zeta_F(0)$ plus elementary corrections. With $F = 1$ these are just values of the Riemann zeta function ($\gamma_m = (-1)^m\operatorname{CT}_{s=1}\zeta^{(m)}(s)$, $\log\sqrt{2\pi} = -\zeta'(0)$, $\log A = \frac1{12} - \zeta'(-1)$), but they can also be written as convergent sums of holonomic functions, such as $$\sum_{k=1}^{\infty}\Bigl(\Bigl(k + \frac12\Bigr)\log\Bigl(1+\frac1k\Bigr) - 1\Bigr) = 1 - \log\sqrt{2\pi},$$ which combined with theta splitting gives new rapidly converging series for $\gamma_1 \approx -0.0728158455$, $A \approx 1.2824271291$ and so on.

Specifically for computing $\gamma$ and $\pi$ quasilinear algorithms are of course known, but for the Stieltjes constants $\gamma_m$ with $m \ge 1$ and for Glaisher's constant $A$ theta splitting is the only known subquadratic algorithm. The expansions for these with $F = 1$ are classical (or at least folklore); expressing these numbers via special values of $\zeta_F$ with $F \ne 1$ and applying theta splitting yields new formulas (probably generally slower for computations, but of theoretical interest).

Another nice example is the Barnes $G$-function, which interpolates $G(n) = \prod_{i=0}^{n-2} i!$: by its Weierstrass product, $$\log G(1+x) = \frac x2\log2\pi - \frac{x + (1+\gamma)x^2}2 + \zeta_{F_x}(0)$$ with $$F_x(k) = k\log(1+\frac xk) - x + \frac{x^2}{2k},$$ so $G(x)$ can be computed in $\widetilde O(p^{3/2})$ for algebraic $x$. Unlike for $\Gamma(x)$, no quasilinear method is known when $x$ is not an integer.

Bernoulli-like numbers

Theta splitting also gives a subquadratic algorithm for computing the exact value of the $n$th Bernoulli number or Euler number and many other integer or rational sequences expressible as special values of the Riemann zeta function, Dirichlet $L$-functions and polylogarithms via expressions like $\zeta(-n)$. Unfortunately, the method is not at all competitive in practice here; standard quadratic methods like the Euler product and modular algorithms are about a hundred times faster for reasonable $n$.

The existence of such a subquadratic algorithm for Bernoulli and Euler numbers was already noted in my earlier preprint on the theta splitting in the classical case of Dirichlet $L$-functions. The new preprint lists a few more integer sequences for which this applies. However, the only examples I've been able to find come from $F = 1$. One of the open problems posed in the paper is whether there are sequences of this kind generated by $\zeta_F$ for nontrivial $F$.

I should note that Bernoulli numbers have an entirely different subquadratic algorithm due to David Harvey. It's plausible that Harvey's algorithm, which uses modular arithmetic rather than numerical approximations, can be generalized to the other integer sequences in this class.

Formal proofs

The paper comes with Lean proofs, a first for me (and again thanks to Claude's assistance). The complexity bounds have not been formalized as such, but most of the underlying mathematics is formally defined and proved. This includes:

As you would expect, the formalization uncovered lots of minor bugs in the paper to fix, and one real error: the splitting for the damped zeta function was first derived for a scale factor $e^{-t k^r}$ with $0 < r < 2$, but the resulting formula is only valid for $0 < r \le 1$; for $r > 1$ the series expansions in the dual system become divergent. This can possibly be fixed with a modification of the algorithm, but it is left as an open problem for now.

Altogether the formalization amounts to 20,000 lines of Lean code, all AI-generated. Apart from the missing formal complexity bounds, the biggest remaining gap in the formalization is a technical lemma that depends on Fuchs's criterion, left as a hypothesis; proving this would require infrastructure for differential operators beyond what Mathlib currently provides which didn't seem worth deriving ad hoc. A worthwhile continuation of this project would be to get proper support for holonomic functions into Mathlib, which should significantly streamline future formalizations in this area.



fredrikj.net  |  Blog index  |  RSS feed  |  Follow me on Mastodon  |  Become a sponsor