Quasi-linear evaluation of theta functions
- Cost
- operations at precision for theta values at a reduced , for fixed genus (the constant grows exponentially with ); derivatives up to order cost about times as much.
Summing the theta series over an ellipsoid costs multiplications at precision in genus (Summation over ellipsoids). For , the theta constants can instead be computed with the arithmetic-geometric mean in steps, and Dupont [Dup2006], and Labrande and Thomé [LT2016] for , generalised this to quasi-linear algorithms based on the duplication formulas and Newton's method, which however needed hypotheses on the input (good choices of square roots) and were not uniform in . Elkies and Kieffer [EK2025] give an algorithm that is uniform in for every fixed and needs no Newton iteration. It is implemented in acb_theta_ql_exact and used by every evaluation in acb_theta above low precision.
Throughout, is reduced (Reduction), and the characteristics run over with addition modulo 2.
Duplication formulas#
Theorem 1 (Duplication formula). For , and ,
and for any , .
Proof. The product is the sum over of . Put and . Then and . As runs over , runs exactly once over the pairs with and for some : indeed , and conversely , lie in . The sum factors as stated. For the general case, replace and by and : then is unchanged and is shifted by , which multiplies the term by .
The formula also holds for the normalised functions , because the normalising factors match on both sides. Three special cases are used:
For , the third formula and its version with give (with for the sign and for ), and the second formula at , where and the odd vanishes, gives . Hence and satisfy and : the AGM, read from down to by taking square roots. In general, each formula is a sum of products, computed for all at once by two Hadamard transforms of length and pointwise products (acb_theta_agm_mul, following [LT2016]).
The algorithm for theta constants#
To compute for all , choose with (more precisely, so that the ellipsoid for has points: for the diagonal entries of the Cholesky factor of ).
- Compute for all by summation. Since is large, only lattice points contribute at precision , and the value is about where is the distance from 0 to .
- For : apply the third duplication formula to get from the values at , and take square roots, choosing the signs with low-precision approximations of computed by summation.
The cost is steps of multiplications and square roots at precision , that is , provided the precision loss per step is bounded.
Precision. The values for are exponentially small. FLINT works with shifted absolute precision: a value of expected magnitude is computed with absolute error . The duplication formula is compatible with this, because by the parallelogram identity the products at have magnitude at most that of at (see acb_theta_agm_mul_tight, which computes the products on midpoints and adds error bounds of the right shape). Assuming that every is of its expected order of magnitude, the loss is bits per step, and the square roots are determined by approximations to bits.
Robustness: an auxiliary shift#
The assumption can fail: some may be much smaller than expected (for instance, close to a zero of a theta constant), and then a square root cannot be chosen, or precision is lost. The algorithm then introduces a random real vector . A real shift does not change the expected magnitudes, and for almost every none of the values and is abnormally small. At each step, the first duplication formula gives and by square roots (from the values at of the vectors ), and the second formula with gives the theta constants by divisions, without square roots of small numbers. acb_theta_ql_setup tries a few random vectors at low precision, doubling the precision if none works, and determines how many initial steps are easy (need no shift). This makes the algorithm probabilistic, with a negligible probability of failure, in which case the result is indeterminate rather than wrong.
Nonzero . For theta values at , the first formula computes from the values at and the theta constants, so the algorithm carries the vectors for , of which itself is only needed at the last step. Theta values with nonzero are obtained at the last step from the general duplication formula with signs .
Dimension lowering#
If the eigenvalues of have very different sizes, doubling makes the ellipsoids thin in some directions long before they are thin in others, and the number of duplication steps needed for the largest direction would make the precision loss in the others large. The algorithm then splits the variables: writing with of size and , the theta series is
and only the in a small ellipsoid of dimension (with the lower right block of the Cholesky factor) contribute at the required precision. Each term is a theta value in dimension at a shifted vector, which is evaluated recursively by the same algorithm for many vectors at once. acb_theta_ql_nb_steps decides, from the diagonal of the Cholesky factor and the precision, how many duplication steps to apply before lowering the dimension at each level (a vector called the pattern). acb_theta_ql_lower_dim and acb_theta_ql_recombine perform the split and the recombination, and acb_theta_ql_exact runs the whole recursion. The effect is that every summation and every duplication step works at precision on ellipsoids with points, which keeps the algorithm quasi-linear uniformly in .
The algorithm#
acb_theta_ql_exact)Input: exact reduced , , with ; a pattern from acb_theta_ql_nb_steps; precision .
Output: for all (or all ).
- Let be the number of duplication steps of the pattern. If , sum the series and return.
- With
acb_theta_ql_setup, compute low-precision approximations of all the values whose square roots will be taken, choose the auxiliary vector if needed, and estimate the precision loss . - Compute the theta values at for the vectors at precision : by summation, or, if the pattern says so, by dimension lowering and a recursive call.
- For , apply the duplication formulas (
acb_theta_agm_mul_tight), taking square roots withacb_theta_agm_sqrtguided by the approximations, or divisions by the shifted values. - At , compute the requested values (with the general formula for ).
The main function acb_theta_jet reduces , uses when only one value is needed, and when the squares of all values are requested, so that the quasi-linear algorithm only ever computes the functions .
Derivatives#
Partial derivatives with respect to up to total order are computed from values (acb_theta_ql_jet_fd). Let be a primitive -th root of unity, , and for . If (multi-index notation), a discrete Fourier transform in each coordinate gives
which is plus terms of order . If on the polydisc of radius around , Cauchy's estimate bounds those terms, and the error of is at most . acb_theta_ql_local_bound gives and from the Cholesky factor and ; is chosen so that this error is , and the precision of the evaluations is raised to compensate for the division by . The evaluations are made at the midpoints of , and the effect of the input radii is added with acb_theta_ql_jet_error, which bounds the variation of the derivatives over the input balls with derivatives of order (computed cheaply at low precision) and the heat equation. The total cost is quasi-linear in . At low precision, direct summation of the differentiated series is faster, and acb_theta_ql_jet chooses between the two.
Use in FLINT#
acb_theta_agm_mul,acb_theta_agm_mul_tight,acb_theta_agm_sqrt: duplication steps.acb_theta_ql_nb_steps,acb_theta_ql_setup,acb_theta_ql_lower_dim,acb_theta_ql_recombine,acb_theta_ql_exact: the algorithm for values.acb_theta_ql_local_bound,acb_theta_ql_jet_error,acb_theta_ql_jet_fd,acb_theta_ql_jet: derivatives.acb_theta_jet_notransform,acb_theta_jet,acb_theta_one,acb_theta_all, and the genus 2 modular forms (acb_theta_g2_sextic_chi5) built on them.
Referenced from#
References#
- [Dup2006] R. Dupont. "Moyenne arithmético-géométrique, suites de Borchardt et applications." These de doctorat, École polytechnique, Palaiseau (2006). http://www.lix.polytechnique.fr/Labo/Regis.Dupont/these_soutenance.pdf
- [LT2016] H. Labrande and E. Thomé, "Computing theta functions in quasi-linear time in genus 2 and above", ANTS XII, Kaiserslautern, LMS J. Comp. Math 19 (2016), 163–177. https://doi.org/10.1112/S1461157016000309
- [EK2025] N. D. Elkies and J. Kieffer, "A uniform quasi-linear time algorithm for evaluating theta functions in any dimension", in preparation.
The FLINT team, “Quasi-linear evaluation of theta functions,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/theta-quasi-linear.html (generated 2026-11-02).
@misc{flint-doc-algorithms-special-functions-theta-quasi-linear,
author = {{The FLINT team}},
title = {{Quasi-linear evaluation of theta functions}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/special-functions/theta-quasi-linear.html},
note = {Generated 2026-11-02}
}