FLINT3.7.0-dev
Algorithm

The Epstein zeta function

The Epstein zeta function of the lattice Λ=AZd\Lambda = A \mathbb{Z}^d with shifts xx and yy is

ZΛ,ν ⁣∣xy∣=∑z∈Λ′e−2πi y⋅z∣x−z∣ν,Z_{\Lambda,\nu}\!\begin{vmatrix} x \\ y \end{vmatrix} = \sum_{z \in \Lambda}{}' \frac{e^{-2 \pi i\, y \cdot z}}{|x - z|^{\nu}},

the prime omitting z=xz = x, continued meromorphically from Re⁡(ν)>d\operatorname{Re}(\nu) > d (see acb_mzeta for the conventions and the regularised function). All algorithms in FLINT start from Crandall's representation [BBG2024], which splits ZZ into two rapidly converging sums over Λ\Lambda and the dual lattice Λ∗=A−TZd\Lambda^* = A^{-T} \mathbb{Z}^d whose terms are incomplete gamma functions. They differ in how these sums are evaluated: term by term in ball arithmetic, in double-precision ball arithmetic, as Mellin integrals of theta functions, or, for rational lattices, by shells of equal norm. Throughout, e(t)=e2πite(t) = e^{2\pi i t} and

Ga(t)=t−aΓ(a,t)=∫1∞wa−1e−tw dw.G_a(t) = t^{-a} \Gamma(a, t) = \int_1^\infty w^{a-1} e^{-t w}\, dw.

Reductions#

The basis is first LLL-reduced [LLL1982] through its Gram matrix (arb_mat_spd_lll_reduce), which leaves ZZ unchanged and makes the Cholesky factors of the quadratic forms well conditioned. Writing x=A(u0+m)x = A(u_0 + m) and ATy=w=w0+lA^T y = w = w_0 + l with m,l∈Zdm, l \in \mathbb{Z}^d and u0,w0u_0, w_0 near zero,

ZΛ,ν ⁣∣xy∣=e(−w⋅m) ZΛ,ν ⁣∣Au0A−Tw0∣,Z_{\Lambda,\nu}\!\begin{vmatrix} x \\ y \end{vmatrix} = e(-w \cdot m)\, Z_{\Lambda,\nu}\!\begin{vmatrix} A u_0 \\ A^{-T} w_0 \end{vmatrix},

by the substitution z→z+Amz \to z + Am and periodicity in yy. A shift whose ball contains a lattice point without being exactly that point gives an indeterminate result, since ZZ is discontinuous (or singular) there.

Crandall's representation#

Theorem 1 ([BBG2024, Thm. 2.11]). For λ>0\lambda > 0 and V=∣det⁡A∣V = |\det A|,

Z=(πλ2)ν/2[1Γ(ν/2)∑z∈Λ′Gν/2(π∣z−x∣2λ2)e(−y⋅z)+λdV Γ(ν/2)∑k∈Λ∗′G(d−ν)/2(πλ2∣k+y∣2)e(−x⋅(k+y))−[x∈Λ]Γ(ν/2+1)+λdV2 [y∈Λ∗](ν−d) Γ(ν/2)],\begin{aligned} Z = \Bigl(\frac{\pi}{\lambda^2}\Bigr)^{\nu/2} \Biggl[ &\frac{1}{\Gamma(\nu/2)} \sum_{z \in \Lambda}{}' G_{\nu/2}\Bigl(\frac{\pi |z - x|^2}{\lambda^2}\Bigr) e(-y \cdot z) \\ &+ \frac{\lambda^d}{V\, \Gamma(\nu/2)} \sum_{k \in \Lambda^*}{}' G_{(d - \nu)/2}\bigl(\pi \lambda^2 |k + y|^2\bigr) e(-x \cdot (k + y)) \\ &- \frac{[x \in \Lambda]}{\Gamma(\nu/2 + 1)} + \frac{\lambda^d}{V} \frac{2\, [y \in \Lambda^*]}{(\nu - d)\, \Gamma(\nu/2)} \Biggr], \end{aligned}

where the primes omit z=xz = x and k=−yk = -y and [⋅][\cdot] is 1 if the condition holds and 0 otherwise.

Proof. For Re⁡(ν)>d\operatorname{Re}(\nu) > d, write ∣x−z∣−ν=(π/λ2)ν/2Γ(ν/2)∫0∞sν/2−1e−πs∣x−z∣2/λ2ds|x - z|^{-\nu} = \frac{(\pi/\lambda^2)^{\nu/2}}{\Gamma(\nu/2)} \int_0^\infty s^{\nu/2 - 1} e^{-\pi s |x - z|^2 / \lambda^2} ds and split the integral at s=1s = 1. The part over [1,∞)[1, \infty) gives the first sum. In the part over [0,1][0, 1], Poisson summation over Λ\Lambda turns ∑ze(−y⋅z)e−πs∣x−z∣2/λ2\sum_z e(-y \cdot z) e^{-\pi s |x - z|^2/\lambda^2} into λdVsd/2∑ke−πλ2∣k+y∣2/se(−x⋅(k+y))\frac{\lambda^d}{V s^{d/2}} \sum_k e^{-\pi \lambda^2 |k + y|^2 / s} e(-x \cdot (k + y)), and s→1/ss \to 1/s gives the second sum. The sum over zz in the Poisson formula includes z=xz = x if x∈Λx \in \Lambda, whose contribution ∫01sν/2−1ds=2/ν\int_0^1 s^{\nu/2 - 1} ds = 2/\nu is subtracted, and the term k=−yk = -y, if y∈Λ∗y \in \Lambda^*, is ∫1∞s(d−ν)/2−1ds=2/(ν−d)\int_1^\infty s^{(d - \nu)/2 - 1} ds = 2/(\nu - d). Since Ga(t)G_a(t) is entire in aa for t>0t > 0 and 1/Γ1/\Gamma is entire, the right-hand side continues ZZ to all ν≠d\nu \ne d.

FLINT takes λ=V1/d\lambda = V^{1/d}, which balances the two sums. With the upper triangular Cholesky factors CDC_D of (π/λ2)ATA(\pi/\lambda^2) A^T A and CRC_R of πλ2(ATA)−1\pi \lambda^2 (A^T A)^{-1}, the arguments are t=∣CD(n−u0)∣2t = |C_D(n - u_0)|^2 and t=∣CR(m+w0)∣2t = |C_R(m + w_0)|^2 for n,m∈Zdn, m \in \mathbb{Z}^d. For the regularised function, the term of yy itself is replaced by Gb(t)−Γ(b)t−b=−t−bγ(b,t)G_b(t) - \Gamma(b) t^{-b} = -t^{-b} \gamma(b, t), b=(d−ν)/2b = (d - \nu)/2, which removes s^ν(y)\hat s_\nu(y); at y=0y = 0 this is the singular term.

Truncation#

Lemma 2. For t>v=max⁡(0,Re⁡(a)−1)t > v = \max(0, \operatorname{Re}(a) - 1), ∣Ga(t)∣≤e−t/(t−v)|G_a(t)| \le e^{-t} / (t - v).

Proof. ∣wa−1∣=wRe⁡(a)−1≤ev(w−1)|w^{a-1}| = w^{\operatorname{Re}(a) - 1} \le e^{v (w - 1)} for w≥1w \ge 1 (as log⁡w≤w−1\log w \le w - 1), so ∣Ga(t)∣≤∫1∞ev(w−1)−twdw=e−t/(t−v)|G_a(t)| \le \int_1^\infty e^{v(w-1) - t w} dw = e^{-t}/(t - v).

Theorem 3 (Tail of the Crandall sums). For T≥max⁡(4,v+1)T \ge \max(4, v + 1) and any shift cc,

∑∣C(n+c)∣2>T∣Ga(∣C(n+c)∣2)∣≤K T(d−1)/2e−TT−v,K=(1+8/π)∏j(1+2πCjj).\sum_{|C(n + c)|^2 > T} |G_a(|C(n + c)|^2)| \le K\, T^{(d-1)/2} \frac{e^{-T}}{T - v}, \qquad K = \Bigl(1 + \sqrt{8/\pi}\Bigr) \prod_j \Bigl(1 + \frac{\sqrt{2\pi}}{C_{jj}}\Bigr).

Proof. By Lemma 2 each term is at most e−t/(T−v)e^{-t}/(T - v), and the sum of e−te^{-t} over the points outside the ellipsoid is bounded by the theta tail bound Theorem 1 of Theta functions with R2=TR^2 = T.

TT is the smallest value making the bound at most 2−p2^{-p} for the target precision pp, so T≈plog⁡2+O(dlog⁡p)T \approx p \log 2 + O(d \log p), and the lattice points of both ellipsoids ∣C(n+c)∣2≤T|C(n + c)|^2 \le T number O(Td/2/det⁡C)O(T^{d/2} / \det C).

The scaled incomplete gamma function#

The sums need Ga(t)G_a(t) at many real t>0t > 0 with one aa, each to a relative accuracy of its own (tapered by the size e−te^{-t} of the term), so _acb_mzeta_gamma_upper_scaled chooses the method and the working precision itself:

  • Asymptotic series. F(t)=etGa(t)=∫0∞(1+v)a−1e−tvdvF(t) = e^t G_a(t) = \int_0^\infty (1 + v)^{a-1} e^{-tv} dv and Taylor's theorem with the integral remainder for (1+v)a−1(1 + v)^{a-1} give F(t)=∑k<N(a−1)⋯(a−k)/tk+1+RNF(t) = \sum_{k < N} (a-1) \cdots (a-k)/t^{k+1} + R_N with ∣RN∣≤∣(a−1)⋯(a−N)∣/tN+1|R_N| \le |(a-1) \cdots (a-N)| / t^{N+1} for N≥Re⁡(a)−1N \ge \operatorname{Re}(a) - 1 (then ∣(1+θv)a−1−N∣≤1|(1 + \theta v)^{a - 1 - N}| \le 1). It is used when the smallest term reaches the tolerance, that is for tt of the order of the precision or larger.
  • Convergent series. Ga(t)=Γ(a)t−a−e−t∑ktk/(a)k+1G_a(t) = \Gamma(a) t^{-a} - e^{-t} \sum_k t^k/(a)_{k+1}, whose cancellation (about t/log⁡2t/\log 2 bits, more near the poles of Γ\Gamma) is compensated by raising the working precision by an estimate of the loss. For real a>−1a > -1 with a short dyadic value (the usual case, a=ν/2a = \nu/2 or (d−ν)/2(d - \nu)/2 for a dyadic ν\nu) the sum 1a∑ktk/(a+1)k\frac1a \sum_k t^k/(a+1)_k is computed by rectangular splitting (_arb_hypgeom_gamma_lower_sum_rs_1), with no division per term; it is stopped at an NN with a+1+N≥2ta + 1 + N \ge 2t, after which the ratios of consecutive terms are at most 12\tfrac12, so the tail is at most twice the first omitted term.
  • Nonpositive integers a=−na = -n: Ga(t)=tn(−1)nn!(E1(t)−e−t∑k<n(−1)kk!/tk+1)G_a(t) = t^n \frac{(-1)^n}{n!} \bigl(E_1(t) - e^{-t} \sum_{k<n} (-1)^k k!/t^{k+1}\bigr) with E1(t)=−γ−log⁡t+e−t∑k≥1Hktk/k!E_1(t) = -\gamma - \log t + e^{-t} \sum_{k \ge 1} H_k t^k/k!, a series of positive terms.

A ball tt is evaluated at its midpoint and the radius is propagated with ∣Ga′(s)∣=∣Ga+1(s)∣≤GRe⁡(a)+1(t‾)|G_a'(s)| = |G_{a+1}(s)| \le G_{\operatorname{Re}(a)+1}(\underline{t}) at the lower endpoint t‾\underline t, which avoids the amplification of the radius by about ete^t that the series would cause.

Term-by-term summation#

acb_mzeta_epstein_crandall evaluates both sums of Theorem 1 in ball arithmetic. The points of the ellipsoids are enumerated with acb_theta_eld_set. If the Gram matrix is exact, the quadratic form is exact and the points are grouped by its value, so that GaG_a is evaluated once per shell; ±n\pm n are paired when the center is a lattice point. Each value is computed at a precision tapered by its magnitude e−te^{-t}. The cost is O(pd/2)O(p^{d/2}) incomplete gamma values.

Double-precision balls#

At precisions up to 95 bits and for real ν\nu, acb_mzeta_epstein_crandall_dfloat evaluates the same sums with dfloat balls of one or two doubles. The lattice points are enumerated line by line (Fincke–Pohst [FP1985], the coordinate n0n_0 varying along a line) in outward-rounded double interval arithmetic on enclosures of CC and the shift, so that no point with t≤Tt \le T is missed (extra points are harmless), and processed in batches with the vector operations of gr: per line the partial quadratic forms and phase offsets, per point t=y02+γt = y_0^2 + \gamma, e−te^{-t} (_gr_vec_exp), the factor F(t)=etGa(t)F(t) = e^t G_a(t) from a table, the phase reduced modulo 1 exactly, sin⁡\sin and cos⁡\cos (_gr_vec_sin_cos), and two dot products. Dyadic phases come from an exact table of e(r/2q)e(r/2^q) indexed by an integer computation of rr. Points with t<2−12t < 2^{-12} (very close to the shift) are evaluated with _acb_mzeta_gamma_upper_scaled.

Tables of FF. FF satisfies tF′=(t−a)F−1t F' = (t - a) F - 1, so its Taylor coefficients ckc_k at t0t_0 obey

t0(k+1)ck+1=(t0−a−k)ck+ck−1−[k=0].t_0 (k+1) c_{k+1} = (t_0 - a - k) c_k + c_{k-1} - [k = 0].

The table holds Taylor polynomials of degree 28 (resp. 15 for one double) on intervals ∣t−t0∣≤ρ|t - t_0| \le \rho with centers decreasing geometrically from T+2T + 2 to 2−122^{-12}, built once per aa and kept in the cache.

Lemma 4 (Coefficient bounds). With s=max⁡(0,a−1)s = \max(0, a - 1) and τ=t0−s>0\tau = t_0 - s > 0, ∣ck∣≤τ−(k+1)|c_k| \le \tau^{-(k+1)}. For a>0a > 0 and any t0>0t_0 > 0, ∣ck∣≤B (t0/2)−k|c_k| \le B\, (t_0/2)^{-k} with B=et0/2(t0/2)−aΓ(a)B = e^{t_0/2} (t_0/2)^{-a} \Gamma(a).

Proof. ck=(−1)kk!∫0∞vk(1+v)a−1e−t0vdvc_k = \frac{(-1)^k}{k!} \int_0^\infty v^k (1+v)^{a-1} e^{-t_0 v} dv and (1+v)a−1≤esv(1 + v)^{a-1} \le e^{s v} give the first bound. For the second, FF is analytic for Re⁡(t)>0\operatorname{Re}(t) > 0 with ∣F(t)∣≤∫0∞(1+v)a−1e−Re⁡(t)vdv=err−aΓ(a,r)≤err−aΓ(a)|F(t)| \le \int_0^\infty (1+v)^{a-1} e^{-\operatorname{Re}(t) v} dv = e^{r} r^{-a} \Gamma(a, r) \le e^r r^{-a} \Gamma(a), r=Re⁡(t)r = \operatorname{Re}(t), and Cauchy's inequality on the circle of radius t0/2t_0/2 applies.

The first bound is used with ρ=τ/16\rho = \tau/16 when s≤t0/4s \le t_0/4, the second with ρ=t0/32\rho = t_0/32 otherwise; either gives the truncation error of the polynomial on the interval. The values F(t0)F(t_0) at the centers are propagated downward from one evaluation at the top, by evaluating the series of the previous center (of degree 60, resp. 32) at the step h=t1−t0h = t_1 - t_0. Downward is the stable direction: the homogeneous solution η(t)=ett−a\eta(t) = e^t t^{-a} decreases relative to FF.

Proposition 5 (Propagated error). If the midpoint of F(t0)F(t_0) is off by δ\delta, the coefficients computed from it are those of FF plus δ\delta times those of g(y)=η(t0+y)/η(t0)=ey(1+y/t0)−ag(y) = \eta(t_0 + y)/\eta(t_0) = e^y (1 + y/t_0)^{-a}, and the value at the next center is off by at most

∣δ∣(eh(t1/t0)−a+MqK+11−q),M=et0/22∣a∣, q=2∣h∣/t0≤14,|\delta| \Bigl( e^{h} (t_1/t_0)^{-a} + M \frac{q^{K+1}}{1 - q} \Bigr), \qquad M = e^{t_0/2} 2^{|a|},\ q = 2|h|/t_0 \le \tfrac14,

for a polynomial of degree KK, plus the truncation error of FF.

Proof. The recurrence is linear and η\eta solves its homogeneous version, so the computed series is F(t0+y)−δg(y)F(t_0 + y) - \delta g(y) truncated at degree KK. The truncation of gg is g(h)g(h) minus its tail; the coefficients of gg are majorized by those of ex(1−x/t0)−∣a∣e^x (1 - x/t_0)^{-|a|}, which is bounded by MM on ∣x∣=t0/2|x| = t_0/2, so by Cauchy's inequality the tail is at most MqK+1/(1−q)M q^{K+1}/(1-q). So the propagated error follows the homogeneous solution, δη(t)/η(t0)\delta \eta(t)/\eta(t_0), and its size relative to FF decreases with tt; bounding g(h)g(h) by the majorant e∣h∣(1−∣h∣/t0)−∣a∣e^{|h|}(1 - |h|/t_0)^{-|a|} instead would multiply the error by more than e∣h∣e^{|h|} at every step.

Within an interval, ∣g(y)∣≤eρ(1−ρ/t0)−∣a∣|g(y)| \le e^\rho (1 - \rho/t_0)^{-|a|} bounds the effect of δ\delta, and the polynomial is evaluated by Horner's rule in plain double or double-double arithmetic with the a priori bound ∑k(k+1)∣ck∣ρk\sum_k (k+1) |c_k| \rho^k times the unit roundoff of a step (2−522^{-52} with fused multiply-add, 2−1022^{-102} for double-double, with the terms of degree at least 14 summed in plain double and bounded separately). Together these give an absolute bound EE for the value and DD for the derivative on each interval, from which a ball input gets its radius.

Mellin integrals of theta functions#

With QQ the matrix of one of the two quadratic forms, σ\sigma its shift, tn=(n−σ)TQ(n−σ)t_n = (n - \sigma)^T Q (n - \sigma) and phases e(−p⋅n)e(-p \cdot n), each Crandall sum is

S=∑n′e(−p⋅n) Ga(tn)=∫1∞wa−1 Θ(w) dw,Θ(w)=∑n′e(−p⋅n) e−wtn,S = \sum_n{}' e(-p \cdot n)\, G_a(t_n) = \int_1^\infty w^{a-1}\, \Theta(w)\, dw, \qquad \Theta(w) = \sum_n{}' e(-p \cdot n)\, e^{-w t_n},

by the integral form of GaG_a (the sums converge absolutely for w≥1w \ge 1), and the full sum over nn is a Riemann theta function,

∑ne(−p⋅n)e−wtn=e−wσTQσ θ(−p−iwQσ/π,  iwQ/π),\sum_n e(-p \cdot n) e^{-w t_n} = e^{-w \sigma^T Q \sigma}\, \theta\bigl(-p - i w Q \sigma/\pi,\; i w Q/\pi\bigr),

evaluated with acb_theta_one in quasi-linear time; the excluded points are subtracted. acb_mzeta_epstein_theta computes the integral by Gauss–Legendre quadrature in y=log⁡wy = \log w: the integrand f(y)=eayΘ(ey)f(y) = e^{a y} \Theta(e^y) is analytic for ∣Im⁡y∣<π/2|\operatorname{Im} y| < \pi/2, where Re⁡(w)>0\operatorname{Re}(w) > 0.

Lemma 6 (Bounds for the theta series). For r>0r > 0 and the Cholesky factor CC of QQ,

Φ(r)=∑n′e−rtn≤min⁡(Φ0(r), e−(r−r1)tmin⁡Φ0(r1)),Φ0(r)=∏j(1+π/rCjj),\Phi(r) = \sum_n{}' e^{-r t_n} \le \min\Bigl(\Phi_0(r),\ e^{-(r - r_1) t_{\min}} \Phi_0(r_1)\Bigr), \qquad \Phi_0(r) = \prod_j \Bigl(1 + \frac{\sqrt{\pi/r}}{C_{jj}}\Bigr),

for 0<r1≤r0 < r_1 \le r and a lower bound tmin⁡t_{\min} of the tnt_n of the points that are not excluded. If Re⁡(w)≥r\operatorname{Re}(w) \ge r, then ∣Θ(w)∣≤Φ(r)|\Theta(w)| \le \Phi(r).

Proof. tn=∑j(Cjjxj+∑k>jCjkxk)2t_n = \sum_j (C_{jj} x_j + \sum_{k > j} C_{jk} x_k)^2 with x=n−σx = n - \sigma. Summing over n0n_0 first, with the other coordinates fixed, the terms e−r(C00n0+β)2e^{-r (C_{00} n_0 + \beta)^2} form a unimodal sequence, whose sum is at most its maximum (at most 1) plus the integral π/r/C00\sqrt{\pi/r}/C_{00}; repeating for n1,n2,…n_1, n_2, \ldots gives Φ0(r)\Phi_0(r). For the second bound, e−rt≤e−(r−r1)tmin⁡e−r1te^{-r t} \le e^{-(r - r_1) t_{\min}} e^{-r_1 t} for t≥tmin⁡t \ge t_{\min}. Finally ∣e−wt∣=e−Re⁡(w)t|e^{-w t}| = e^{-\operatorname{Re}(w) t}.

The interval [0,log⁡W][0, \log W] is covered by intervals of half-length hh. On the Bernstein ellipse EρE_\rho of an interval with center ycy_c and semi-minor axis below π/2\pi/2, Re⁡(w)≥eyc−h(ρ+1/ρ)/2cos⁡θmax⁡\operatorname{Re}(w) \ge e^{y_c - h(\rho + 1/\rho)/2} \cos\theta_{\max} and ∣eay∣≤eRe⁡(a)Re⁡(y)+∣Im⁡(a)∣θmax⁡|e^{a y}| \le e^{\operatorname{Re}(a) \operatorname{Re}(y) + |\operatorname{Im}(a)| \theta_{\max}}, so Lemma 6 bounds ∣f∣|f| by some MM, and nn nodes have error at most 6415hMρ−2n/(ρ2−1)\frac{64}{15} h M \rho^{-2n}/(\rho^2 - 1) (Theorem 1 of Rigorous numerical integration). For the tail, Φ(w)≤e−(w−W/2)tmin⁡Φ0(W/2)\Phi(w) \le e^{-(w - W/2) t_{\min}} \Phi_0(W/2) for w≥W/2w \ge W/2 and ws−1≤Ws−1e(s−1)(w−W)/Ww^{s-1} \le W^{s-1} e^{(s-1)(w - W)/W}, s≥Re⁡(a)s \ge \operatorname{Re}(a), give

∫W∞∣wa−1∣ Φ(w) dw≤Φ0(W/2) eWtmin⁡/2 Ws−1e−Wtmin⁡tmin⁡−max⁡(0,s−1)/W.\int_W^\infty |w^{a-1}|\, \Phi(w)\, dw \le \Phi_0(W/2)\, e^{W t_{\min}/2}\, \frac{W^{s-1} e^{-W t_{\min}}}{t_{\min} - \max(0, s-1)/W}.

The node counts taper with these bounds from interval to interval, and the nodes are shared between the intervals and the two sums: a degree already computed is reused when it is at most 1/81/8 above the one required. Nodes come from arb_hypgeom_legendre_p_ui_root, half of them by symmetry.

Direct sums for large ww. For large ww the series Θ(w)\Theta(w) has few terms of any size. The points with tn≤T0t_n \le T_0 are enumerated once per sum, with their tnt_n and phases; then

Θ(w)=∑tn≤Te(−p⋅n) e−wtn+ϵ,∣ϵ∣≤e−(w−1)TΦ0(1)(w≥1),\Theta(w) = \sum_{t_n \le T} e(-p \cdot n)\, e^{-w t_n} + \epsilon, \qquad |\epsilon| \le e^{-(w-1) T} \Phi_0(1) \quad (w \ge 1),

since e−wt≤e−(w−1)Te−te^{-w t} \le e^{-(w-1) T} e^{-t} for t>Tt > T. A node uses the direct sum when the TT needed for its accuracy is at most T0T_0, and T0T_0 is chosen so that at most min⁡(80,max⁡(16,80000/p)) 2d\min(80, \max(16, 80000/p))\, 2^d points are stored, about where one real exponential per point stops being cheaper than a theta value. This replaces the reduction and the quasi-linear algorithm of acb_theta_one on most nodes of the upper intervals.

Working precision. The value wkf(yk)w_k f(y_k) of a node is needed to an absolute accuracy of about 2−p/n2^{-p}/n. With ℓ=log⁡2∣wkeayk∣\ell = \log_2 |w_k e^{a y_k}|, Θ(wk)\Theta(w_k) is needed to absolute accuracy 2−(p+ℓ+log⁡2n)2^{-(p + \ell + \log_2 n)}. A direct sum has relative accuracy and needs about p+ℓ+log⁡2Φ(wk)p + \ell + \log_2 \Phi(w_k) bits, which decreases rapidly for large wkw_k; acb_theta_one has absolute accuracy (relative to e−wσTQσθe^{-w \sigma^T Q \sigma} \theta), so a theta value needs p+ℓp + \ell bits.

The cost is about pp integrand values per sum, independent of the O(pd/2)O(p^{d/2}) lattice points of the truncated Crandall sums, so the method wins at high precision: measured crossovers against term-by-term summation are about 700 bits in dimension 3, 400 bits in dimension 4 and 220 bits in dimension 5; in dimension 2 the two break even at about 4000 bits.

Sums by shells#

For an integral positive definite Gram matrix FF (the lattice Gram matrix being F/LF/L) and rational uu, vv, the function Z=∑n′e(−v⋅n) F(n−u)−sZ = \sum_n{}' e(-v \cdot n)\, F(n - u)^{-s}, s=ν/2s = \nu/2, is computed by acb_mzeta_epstein_gram_shell. The same Mellin splitting as in Theorem 1, at a free parameter κ\kappa, gives

Z=1Γ(s)[κsSD+πd/2κs−d/2det⁡F e(−u⋅v) SR]+singular terms,Z = \frac{1}{\Gamma(s)} \left[\kappa^s S_D + \frac{\pi^{d/2} \kappa^{s - d/2}}{\sqrt{\det F}}\, e(-u \cdot v)\, S_R \right] + \text{singular terms},
SD=∑n′e(−v⋅n) Gs(κF(n−u)),SR=∑m′e(−u⋅m) Gd/2−s(π2F−1(m+v)/κ),S_D = \sum_n{}' e(-v \cdot n)\, G_s(\kappa F(n - u)), \qquad S_R = \sum_m{}' e(-u \cdot m)\, G_{d/2 - s}\bigl(\pi^2 F^{-1}(m + v)/\kappa\bigr),

with singular terms −κs/Γ(s+1)-\kappa^s/\Gamma(s+1) if u∈Zdu \in \mathbb{Z}^d and πd/2(det⁡F)−1/2κs−d/2/((s−d/2)Γ(s))\pi^{d/2} (\det F)^{-1/2} \kappa^{s - d/2} / ((s - d/2) \Gamma(s)) if v∈Zdv \in \mathbb{Z}^d.

Shells. On each side the values of the integral quadratic form at the shifted points, V(n)=(Sn−s)TF(Sn−s)V(n) = (S n - s)^T F (S n - s) with s=Sσs = S\sigma for the common denominator SS of the shift σ\sigma, are gM+r0g M + r_0 with integers M≥0M \ge 0, gg the gcd of all differences V(n)−V(0)V(n) - V(0) (computed from the values at ±ei\pm e_i and the cross terms 2S2Fij2 S^2 F_{ij}). The points are counted by shell MM and by the residue Nℓ⋅n mod NN \ell \cdot n \bmod N of the linear character, so that each side is ∑M∑rCr(M) e(r/N) G(γ(gM+r0))\sum_M \sum_r C_r(M)\, e(r/N)\, G(\gamma (g M + r_0)): one incomplete gamma value per shell instead of one per point.

Choice of κ\kappa. κ\kappa is chosen so that the arguments on one side are λ(gM+r0)\lambda (g M + r_0) with a dyadic λ\lambda. There the values Ga(λV)G_a(\lambda V) at exact rationals come from binary splitting (the asymptotic series or the series at 0, _arb_hypgeom_gamma_upper_fmpq_inf_bsplit_sum and _arb_hypgeom_gamma_lower_fmpq_0_bsplit_sum, or the convergent series for Γ(−n,z)\Gamma(-n, z)). The arguments on the other side are irrational. If its index is a positive integer jj (the Coulomb potential ν=d−2\nu = d - 2, and even ν\nu), then Gj(t)=(j−1)! e−t∑i<jti−j/i!G_j(t) = (j-1)!\, e^{-t} \sum_{i<j} t^{i-j}/i!, and that side is a sum of jj power series in q=e−γgq = e^{-\gamma g} with rational coefficients Cr(M)/(gM+r0)j−iC_r(M)/(gM + r_0)^{j-i}. These are summed by rectangular splitting with one shared fixed-point table of powers of qq, read once per block for the sums over all residues and powers; the denominators are cleared in chunks whose integer multipliers fit in one or two limbs, each chunk is divided once, and the divisions of several chunks are interleaved [GraMol2010]. Otherwise each value on that side is computed below 16384 bits as in The scaled incomplete gamma function, which is faster there, and above by a bit-burst step, whose cost grows more slowly with the precision: binary splitting at a dyadic z0z_0 of about 2p2\sqrt{p} bits near zz, then the Taylor series in ε=z−z0\varepsilon = z - z_0 with coefficients gkg_k from the differential equation tG′′+(1+a+t)G′+aG=0t G'' + (1 + a + t) G' + a G = 0,

gk+2=−(k+1)(k+1+a+z0) gk+1+(k+a) gkz0(k+1)(k+2),g_{k+2} = -\frac{(k+1)(k+1+a+z_0)\, g_{k+1} + (k+a)\, g_k}{z_0 (k+1)(k+2)},

and the bound ∣gk∣≤Γ(k+a)/(k! z0k+a)|g_k| \le \Gamma(k+a)/(k!\, z_0^{k+a}) for k+a>0k + a > 0 from the integral form of GaG_a, so that the tail after degree KK is at most its first term over 1−q1 - q, q=max⁡(1,K+aK+1)∣ε∣/z0q = \max(1, \frac{K+a}{K+1}) |\varepsilon|/z_0. λ\lambda balances the costs: about T/(λgB)T/(\lambda g_B) incomplete gamma values on the binary splitting side against about TλΠ/(π2gO)T \lambda \Pi/(\pi^2 g_O) terms on the other.

Both sides are truncated with Theorem 3. The sums are split into tasks for flint_parallel_do and accumulated with an order-independent fixed-point accumulator: every contribution is rounded to the grid 2−E2^{-E} on its own and added as an exact integer, with the radius in whole ulps, so the result does not depend on the number of threads.

Counts. The integral form is first divided by the content of its entries. The counts Cr(M)C_r(M) come from interchangeable methods, each of which recognises the forms it applies to and estimates its cost; the cheapest applicable one is used (estimates independent of the number of threads, so that the choice, and hence the result, is too), and the sums read the counts block by block.

  • Products of theta series. Zd\mathbb{Z}^d is split into mutually FF-orthogonal sublattices LbL_b of rank 2 (and one of rank 1 for odd dd), with bases from an LLL-reduced basis and the integral kernels of the previous blocks, so that ∑Lb\sum L_b has finite index. On a coset v+∑Lbv + \sum L_b, with y=Sv−sy = S v - s, cb=BbFyc_b = B_b F y and Gb=BbFBbTG_b = B_b F B_b^T, the points n=v+∑bBbTubn = v + \sum_b B_b^T u_b have

    V(n)=∑b(Sub+tb)TGb(Sub+tb),tb=Gb−1cb,V(n) = \sum_b (S u_b + t_b)^T G_b (S u_b + t_b), \qquad t_b = G_b^{-1} c_b,

    and Den⋅(Su+t)TG(Su+t)\mathrm{Den} \cdot (S u + t)^T G (S u + t) is an integer for the common denominator Den\mathrm{Den} of the cbTGb−1cbc_b^T G_b^{-1} c_b. So the generating function ∑nxDen V(n)ζNℓ⋅n\sum_n x^{\mathrm{Den}\, V(n)} \zeta^{N \ell \cdot n} of a coset is the product of the series of the blocks, each enumerated directly in linear time (a rank-2 block has about as many points as exponents). The ⌈d/2⌉−1\lceil d/2 \rceil - 1 products run in Z[x][ζ]/(ζN−1)\mathbb{Z}[x][\zeta]/(\zeta^N - 1) by Kronecker substitution with nmod_poly arithmetic modulo a prime just above a bound for every count. The exponents of a block on a coset lie in one class modulo a common step qq, so the series are taken in xqx^q; among the choices of the first block the one with the least total series length is used.

  • Enumeration. Fincke–Pohst enumeration with exact integer values, for any form.
  • Sums of three squares. For F=I3F = I_3 and characters of order at most 2, the counts are streamed from r3r_3 without a table of all shells: r3(M)r_3(M) for integral shifts, and for the shift (12,12,12)(\tfrac12, \tfrac12, \tfrac12) with trivial character r3(8k+3)=8[xk]T(x)3r_3(8k + 3) = 8 [x^k] T(x)^3, T(x)=∑a≥0xa(a+1)/2T(x) = \sum_{a \ge 0} x^{a(a+1)/2}. The coefficients t2(j)=[xj]T(x)2=∑d∣4j+1χ4(d)t_2(j) = [x^j] T(x)^2 = \sum_{d \mid 4j+1} \chi_4(d) (from 8j+2=(2a+1)2+(2b+1)28j + 2 = (2a+1)^2 + (2b+1)^2 and r2(n)=4∑d∣nχ4(d)r_2(n) = 4 \sum_{d \mid n} \chi_4(d)) come from a segmented divisor sieve over d≤4j+1d \le \sqrt{4j + 1}, since dd and (4j+1)/d(4j+1)/d have the same character, and fit in 2 bytes; r3(8k+3)r_3(8k+3) then needs one sparse convolution with TT per block, or one FFT for short sums.

The Madelung constant#

The Madelung constant of sodium chloride is M=−ZZ3,1(0;(12,12,12))M = -Z_{\mathbb{Z}^3, 1}\bigl(0; (\tfrac12, \tfrac12, \tfrac12)\bigr), computed by the shell algorithm. With κ=λ\kappa = \lambda the splitting is Crandall's expansion [Cra1999, eq. (1.2)]

−M=∑N≥1(−1)Nr3(N)erfc⁡(λN)N+4π∑M≡3 mod 8r3(M)e−π2M/(4λ)M−2λ/π.-M = \sum_{N \ge 1} (-1)^N r_3(N) \frac{\operatorname{erfc}(\sqrt{\lambda N})}{\sqrt{N}} + \frac{4}{\pi} \sum_{M \equiv 3 \bmod 8} r_3(M) \frac{e^{-\pi^2 M/(4\lambda)}}{M} - 2 \sqrt{\lambda/\pi}.

The first sum has O(p/λ)O(p/\lambda) terms, each an incomplete gamma value at an exact integer by binary splitting; the second is a power series in q=e−2π2/λq = e^{-2\pi^2/\lambda} with O(λp)O(\lambda p) terms, whose coefficients come from the t2t_2 sieve. Both cost about p2p^2 up to logarithmic factors, and λ\lambda balances them.

Use in FLINT#

Referenced from#

References#

  • [BBG2024] A. A. Buchheit, J. K. Busse and R. Gutendorf, "Computation and properties of the Epstein zeta function with high-performance implementation in EpsteinLib", preprint (2024), https://arxiv.org/abs/2412.16317
  • [LLL1982] A. K. Lenstra, H. W. Lenstra, Jr. and L. Lovász, "Factoring polynomials with rational coefficients", Mathematische Annalen 261 (1982), 515–534. https://doi.org/10.1007/BF01457454
  • [FP1985] U. Fincke and M. Pohst, "Improved methods for calculating vectors of short length in a lattice, including a complexity analysis", Mathematics of Computation 44 (1985), 463-471, https://doi.org/10.1090/S0025-5718-1985-0777278-8
  • [GraMol2010] N. Möller and T. Granlund, "Improved division by invariant integers", IEEE Transactions on Computers 60 (2011), 165–175, https://gmplib.org/~tege/division-paper.pdf
  • [Cra1999] R. E. Crandall, "New representations for the Madelung constant", Experimental Mathematics 8 (1999), 367-379
Cite this page

The FLINT team, “The Epstein zeta function,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/epstein.html (generated 2026-11-07).