FLINT3.7.0-dev
Algorithm

Theta functions

Cost
After reduction, summation needs O(pg/2)O(p^{g/2}) terms at precision pp in genus gg (genus 1: O(p)O(\sqrt{p})); the quasi-linear algorithm of Quasi-linear evaluation of theta functions needs O(M(p)log⁡p)O(M(p) \log p) for fixed gg.

In genus gg, for τ\tau in the Siegel upper half-space Hg\mathcal{H}_g (symmetric complex matrices with positive definite imaginary part YY), z∈Cgz \in \mathbb{C}^g and characteristics a,b∈{0,1}ga, b \in \{0, 1\}^g,

θa,b(z,τ)=∑n∈Zg+a2exp⁡(πinTτn+2πinT(z+b2)).\theta_{a,b}(z,\tau) = \sum_{n\in \mathbb{Z}^{g} + \tfrac a2} \exp\bigl(\pi i n^T \tau n + 2\pi i n^T (z + \tfrac b2)\bigr).

For g=1g = 1 these are the four Jacobi theta functions: θ0,0=θ3\theta_{0,0} = \theta_3, θ0,1=θ4\theta_{0,1} = \theta_4, θ1,0=θ2\theta_{1,0} = \theta_2 and θ1,1=−θ1\theta_{1,1} = -\theta_1. FLINT evaluates them in two steps: an action of the modular group moves (z,τ)(z, \tau) to a reduced point, where the series converges quickly and uniformly, and the theta values at the reduced point are computed either by summing the series (described below) or by the quasi-linear algorithm based on duplication formulas (Quasi-linear evaluation of theta functions). The general references are [Mum1983] and [Igu1972]; the algorithms of acb_theta are those of Elkies and Kieffer [EK2025].

Size of the terms#

Writing y=Im⁡(z)y = \operatorname{Im}(z) and ∥x∥τ2=πxTYx\lVert x \rVert_\tau^2 = \pi x^T Y x, the term of index nn has absolute value

∣eπinTτn+2πinT(z+b/2)∣=eπyTY−1y e−∥n+Y−1y∥τ2.\bigl| e^{\pi i n^T \tau n + 2\pi i n^T (z + b/2)} \bigr| = e^{\pi y^T Y^{-1} y} \, e^{-\lVert n + Y^{-1} y \rVert_\tau^2}.

Hence the terms decrease like a Gaussian centered at v=−Y−1yv = -Y^{-1}y, ∣θa,b(z,τ)∣≲eπyTY−1y|\theta_{a,b}(z,\tau)| \lesssim e^{\pi y^T Y^{-1} y}, and, barring cancellation, ∣θa,b(z,τ)∣≈eπyTY−1ye−d2|\theta_{a,b}(z,\tau)| \approx e^{\pi y^T Y^{-1} y} e^{-d^2} where dd is the distance from vv to Zg+a2\mathbb{Z}^g + \frac a2. The normalised function θ~a,b=e−πyTY−1yθa,b\widetilde\theta_{a,b} = e^{-\pi y^T Y^{-1} y}\theta_{a,b} is bounded, and FLINT measures precision in terms of its absolute error (Precision).

Reduction#

The symplectic group Sp2g(Z)\mathrm{Sp}_{2g}(\mathbb{Z}) acts on Cg×Hg\mathbb{C}^g \times \mathcal{H}_g by m⋅(z,τ)=((γτ+δ)−Tz,(ατ+β)(γτ+δ)−1)m \cdot (z, \tau) = ((\gamma\tau + \delta)^{-T} z, (\alpha\tau + \beta)(\gamma\tau + \delta)^{-1}), and the theta transformation formula [Igu1972, p. 176]

θa,b(m⋅(z,τ))=κ(m)ζ8e(m,a,b)det⁡(γτ+δ)1/2eπizT(γτ+δ)−1γzθa′,b′(z,τ)\theta_{a,b}(m\cdot(z,\tau)) = \kappa(m) \zeta_8^{e(m, a, b)} \det(\gamma\tau + \delta)^{1/2} e^{\pi i z^T (\gamma\tau + \delta)^{-1} \gamma z} \theta_{a',b'}(z,\tau)

relates the theta values at (z,τ)(z, \tau) and at m⋅(z,τ)m \cdot (z, \tau), with an explicit permutation of characteristics, an 8th root of unity, and a square root of det⁡(γτ+δ)\det(\gamma\tau + \delta) whose branch must be tracked (acb_siegel_kappa). The group is generated by the block-diagonal matrices diag⁡(U,U−T)\operatorname{diag}(U, U^{-T}) (a change of basis of the lattice), the trigonal matrices (IS0I)\begin{pmatrix} I & S \\ 0 & I \end{pmatrix} (integer translations of τ\tau), and JJ.

A matrix τ\tau is reduced (Siegel's fundamental domain, in a relaxed form) if

  1. YY is reduced (FLINT uses LLL reduction with parameters (0.99,0.51)(0.99, 0.51), as a practical substitute for Minkowski reduction);
  2. ∣Re⁡(τj,k)∣≤12|\operatorname{Re}(\tau_{j,k})| \le \frac12 for all j,kj, k;
  3. ∣det⁡(γτ+δ)∣≥1|\det(\gamma\tau + \delta)| \ge 1 for a finite set of fundamental symplectic matrices.

For g=1g = 1 this is the usual fundamental domain ∣Re⁡τ∣≤12|\operatorname{Re}\tau| \le \frac12, ∣τ∣≥1|\tau| \ge 1, where the only fundamental matrix is JJ. For g=2g = 2, Gottschling [Got1959] found the 19 matrices that define the boundary of the fundamental domain. For g≥3g \ge 3 no such list is known, and FLINT uses the 19g(g−1)/219 g(g-1)/2 matrices obtained by embedding the genus 2 matrices on pairs of coordinates and the 2g2^g embeddings of JJ on subsets of coordinates (sp2gz_fundamental). acb_siegel_reduce alternates the three reductions until no fundamental matrix increases det⁡Y\det Y; in exact arithmetic, det⁡Y\det Y increases strictly with each such step and is bounded on an orbit, so the iteration terminates. For reduced τ\tau, the diagonal entries of the Cholesky factor of πY\pi Y are bounded below by a constant depending only on gg (for g=1g = 1, πIm⁡τ≥π3/2\pi \operatorname{Im}\tau \ge \pi\sqrt3/2).

The vector zz is then reduced by the quasi-periodicity in the lattice Zg+τZg\mathbb{Z}^g + \tau\mathbb{Z}^g: subtracting τr+s\tau r + s with r,s∈2Zgr, s \in 2\mathbb{Z}^g multiplies every θa,b\theta_{a,b} by an explicit exponential, and choosing rr close to Y−1yY^{-1}y and ss close to Re⁡(z−τr)\operatorname{Re}(z - \tau r) makes Y−1yY^{-1}y and Re⁡(z)\operatorname{Re}(z) bounded (acb_theta_reduce_z).

Summation over ellipsoids#

After reduction, θ~a,b(z,τ)\widetilde\theta_{a,b}(z, \tau) is approximated by the sum over the lattice points n∈Zg+a2n \in \mathbb{Z}^g + \frac a2 with ∥n−v∥τ≤R\lVert n - v \rVert_\tau \le R, an ellipsoid; the shift by a/2a/2 is handled by θa,b(z,τ)=eπiaTτa/4+πiaT(z+b/2)θ0,b(z+τa2,τ)\theta_{a,b}(z,\tau) = e^{\pi i a^T\tau a/4 + \pi i a^T(z + b/2)} \theta_{0,b}(z + \tau\tfrac{a}{2},\tau). Write πY=CTC\pi Y = C^T C with CC upper triangular with positive diagonal entries γ0,…,γg−1\gamma_0, \ldots, \gamma_{g-1}.

Theorem 1 (Tail bound [EK2025]). For every v∈Rgv \in \mathbb{R}^g and R≥2R \ge 2,

∑n∈Zg∥C(n+v)∥≥Re−∥C(n+v)∥2≤(1+8π)Rg−1e−R2∏j=0g−1(1+2πγj).\sum_{\substack{n \in \mathbb{Z}^g \\ \lVert C(n + v) \rVert \ge R}} e^{-\lVert C(n + v)\rVert^2} \le \Bigl(1 + \sqrt{\tfrac{8}{\pi}}\Bigr) R^{g-1} e^{-R^2} \prod_{j=0}^{g-1} \Bigl(1 + \frac{\sqrt{2\pi}}{\gamma_j}\Bigr).

The factors 1+2π/γj1 + \sqrt{2\pi}/\gamma_j account for the spacing γj\gamma_j of the lattice points along the successive coordinates of the triangular basis, and Rg−1e−R2R^{g-1}e^{-R^2} is the order of the Gaussian integral over the outside of a ball of radius RR; see [EK2025] for the proof. Weighted versions with ∥⋅∥ord\lVert \cdot \rVert^{\mathit{ord}} bound the tails of the differentiated series. acb_theta_sum_radius solves (1+8/π)Rg−1+2 orde−R2∏j(1+2π/γj)≤2−p(1 + \sqrt{8/\pi}) R^{g - 1 + 2\,\mathit{ord}} e^{-R^2} \prod_j (1 + \sqrt{2\pi}/\gamma_j) \le 2^{-p} for R2R^2, so that R2≈plog⁡2+O(glog⁡p)R^2 \approx p \log 2 + O(g \log p), and acb_theta_sum_jet_radius adapts the radius to derivatives.

Ellipsoids. The lattice points with ∥Cn+Cv∥≤R\lVert C n + C v \rVert \le R are enumerated recursively on the last coordinate: for fixed nd,…,ng−1n_{d}, \ldots, n_{g-1} the allowed values of nd−1n_{d-1} form an interval, computed from the triangular structure of CC, and each value has a child ellipsoid of dimension d−1d - 1 (acb_theta_eld_set). This uses O(Rg−1)O(R^{g-1}) memory for O(Rg)O(R^g) points, an approach also used by [DHBHS2004]. When several vectors zz differ by small amounts, one ellipsoid with a union of centers serves all of them.

Summation. The terms are summed line by line: on a line with fixed n1,…,ng−1n_1, \ldots, n_{g-1}, the terms are c⋅eπij2τ0,0xjc \cdot e^{\pi i j^2 \tau_{0,0}} x^j for nmin⁡≤j≤nmax⁡n_{\min} \le j \le n_{\max}, where xx and the cofactor cc depend on the fixed coordinates and are obtained from those of neighbouring lines by a few multiplications. The powers eπij2τ0,0e^{\pi i j^2 \tau_{0,0}} are computed once for the ellipsoid, the powers xjx^j by repeated multiplication, and each line is summed with one dot product (acb_dot), so that fewer than two complex multiplications are needed per lattice point on average. Terms far from the center are small and are computed at a lower precision. With R2≈plog⁡2R^2 \approx p\log 2 and γj\gamma_j bounded below, the ellipsoid contains O(pg/2)O(p^{g/2}) points, so summation costs O(pg/2M(p))O(p^{g/2} M(p)) for fixed gg; it is the method of choice at low precision and the base case of the quasi-linear algorithm, where it is applied at 2mτ2^m\tau with O(1)O(1) points.

Derivatives. Differentiating the series multiplies the term of index nn by (2πi)∣k∣n0k0⋯ng−1kg−1(2\pi i)^{|k|} n_0^{k_0} \cdots n_{g-1}^{k_{g-1}}; the summation workers accumulate these products (acb_theta_sum_jet), and the tail bound includes the polynomial weight.

Genus 1#

For g=1g = 1, acb_modular_theta_sum sums the four Jacobi series together. With q=eπiτq = e^{\pi i \tau} and w=eπizw = e^{\pi i z},

θ3(z,τ)=1+∑n≥1qn2(w2n+w−2n),θ2(z,τ)q1/4=∑n≥0qn(n+1)(w2n+1+w−2n−1),\theta_3(z,\tau) = 1 + \sum_{n \ge 1} q^{n^2} (w^{2n} + w^{-2n}), \qquad \frac{\theta_2(z,\tau)}{q_{1/4}} = \sum_{n \ge 0} q^{n(n+1)} (w^{2n+1} + w^{-2n-1}),

and similarly for θ4\theta_4 and θ1\theta_1 with alternating signs. The exponents of qq, interleaved, are ⌊(k+2)2/4⌋\lfloor (k+2)^2/4 \rfloor, k=0,1,2,…k = 0, 1, 2, \ldots, that is 1,2,4,6,9,12,…1, 2, 4, 6, 9, 12, \ldots, and the exponents of ww are ±(k+2)\pm(k+2). The powers of qq are computed with a short addition sequence for this set of exponents [EHJ2016], in which most powers cost one multiplication, and only even powers of ww and w−1w^{-1} are needed when the odd terms are written as w(w2n±w−2n−2)w (w^{2n} \pm w^{-2n-2}).

Lemma 2 (Truncation bound for genus 1). Let Q=∣q∣<1Q = |q| < 1, W=max⁡(∣w∣,∣w∣−1)W = \max(|w|, |w|^{-1}), and stop the summation before the term of index k=Nk = N. With E=⌊(N+2)2/4⌋E = \lfloor (N+2)^2/4 \rfloor and F=⌊(N+1)/2⌋+1F = \lfloor (N+1)/2 \rfloor + 1, the error of each of the four series, and of its rr-th derivative with respect to πz\pi z, is at most

2QEWN+2(N+2)r1−QFWer/(N+2),\frac{2 Q^E W^{N+2} (N+2)^r}{1 - Q^F W e^{r/(N+2)}},

provided that the denominator is positive.

Proof. The term of index kk (in whichever series it belongs to) is bounded by 2QEkWk+22 Q^{E_k} W^{k+2} with Ek=⌊(k+2)2/4⌋E_k = \lfloor (k+2)^2/4 \rfloor, where the factor 2 accounts for w±(k+2)w^{\pm(k+2)}, and the omitted terms of each series are among those with k≥Nk \ge N. Since Ek+1−Ek=⌊(k+3)/2⌋≥FE_{k+1} - E_k = \lfloor (k+3)/2 \rfloor \ge F for k≥Nk \ge N, the bounds of consecutive terms decrease at least by the ratio QFWQ^F W. Differentiating rr times with respect to πz\pi z multiplies the term of index kk by at most (k+2)r(k+2)^r, and ((N+2+m)/(N+2))r≤emr/(N+2)((N+2+m)/(N+2))^r \le e^{mr/(N+2)}. Summing the geometric series gives the bound.

acb_modular_theta_sum chooses the smallest NN with QEWN+2<2−pQ^{E} W^{N+2} < 2^{-p}, which is N≈2p/log⁡2(1/Q)N \approx 2\sqrt{p/\log_2(1/Q)}; after reduction (to ∣τ∣2≥63/64|\tau|^2 \ge 63/64), Q<0.07Q < 0.07, so N=O(p)N = O(\sqrt{p}), and zz has been reduced so that WW is bounded. acb_theta_sum calls it for g=1g = 1, and the theta constants alone (z=0z = 0) use the specialised acb_modular_theta_const_sum, with rectangular splitting for many terms.

Use in FLINT#

Referenced from#

References#

Cite this page

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