Elliptic integrals, elliptic functions and modular forms
- Cost
- square roots at precision for the AGM and complete elliptic integrals; duplication steps plus a Taylor series of terms for Carlson's integrals; multiplications for modular forms and theta functions on the fundamental domain.
Elliptic integrals and elliptic functions reduce to a few primitives that converge quickly: the arithmetic-geometric mean, which gives the complete elliptic integrals; Carlson's duplication algorithm, which gives the incomplete integrals; and theta functions, which give the Weierstrass elliptic functions and the modular forms after a modular transformation has moved to the fundamental domain. The sections below describe these methods as implemented in acb (the AGM), acb_elliptic and acb_modular, following [Joh2019]; the summation of theta series is described in Theta functions.
The arithmetic-geometric mean#
For , the arithmetic-geometric mean is the common limit of , , with , . The convergence is quadratic: , so steps give bits once and agree to a few bits. With complex variables, it is convenient to use the univariate function ; then (acb_agm), and is analytic on .
Functional equation. If the real part of is not nonnegative, acb_agm1 first applies with , which has nonnegative real part (rounding errors that make the ball for cross the imaginary axis only inflate the result). For the derivative this becomes .
Square roots. In the iteration the correct square root is the continuous branch , which is computed as , or when and both have positive real part, both have nonnegative imaginary part, or both have nonpositive imaginary part, and as otherwise.
Lemma 1 (Dupont [Dup2006, p. 87]). If , the iterates of the AGM of satisfy for all .
This gives a rigorous enclosure when the iteration is stopped, and for real positive variables the lower and upper bounds can be used directly (arb_agm). It is slightly faster to stop when and agree to about bits and finish with a series: with ,
valid for and with nonnegative real part, where the tail is bounded by .
First derivative. acb_agm1_cpx computes for exact with by a central finite difference. Since , Cauchy's integral formula gives with and for (FLINT takes ). For ,
so two evaluations at about 1.5 times the precision give both values, against twice the precision for a one-sided difference. For inexact , the midpoint is used and the propagated error is bounded with and , valid if the disk of radius around avoids the negative real axis (with ).
Higher derivatives. is D-finite. The coefficients of satisfy and
which reduces at to . Given , the remaining coefficients follow by the recurrence and one power series inversion.
Complete elliptic integrals#
With as above,
where is the derivative; both cost square roots (acb_elliptic_k, acb_elliptic_e). The Taylor coefficients of (acb_elliptic_k_jet) satisfy the recurrence of the hypergeometric equation of :
The complete integral of the third kind, , is computed with Carlson's integrals, .
Carlson's symmetric integrals#
The symmetric integrals , (with , as special cases) and are defined on Carlson symmetric integrals. All three Legendre integrals reduce to them on the strip [NIST2012, §19.25], and are extended outside it by quasi-periodicity.
Duplication. For ,
and the differences between the arguments are divided by about 4 at each step, while their mean is preserved up to the factor introduced by the step. After steps, with , , , the elementary symmetric polynomials and of the deviations are of order and , and
Carlson [Car1995] uses the terms of total degree and enough duplication steps to make the remainder negligible, which costs square roots at precision . FLINT instead sums the series up to degree (real case) or (complex case), at most 500, so that only duplication steps are needed [Joh2019]: the iteration stops as soon as . The coefficients are computed exactly with a common denominator, the polynomial in is evaluated with precomputed powers and the polynomial in by Horner's rule. The tail is bounded using that the coefficient of with in the expansion has absolute value at most , so that the truncation error is at most .
. The duplication theorem for adds a term (up to scaling) at each step, and the final Taylor series is in the symmetric polynomials of four deviations [Car1995]; is computed by acb_elliptic_rc1. The principal square roots in the duplication can cross branch cuts of for complex arguments, so the algorithm is only used where it is known to be valid, and otherwise is shifted into the right half-plane by numerical integration; see Correctness of the duplication algorithm for . For the duplication algorithm is valid everywhere.
is computed from .
Weierstrass elliptic functions#
For the lattice with half-periods and , the Weierstrass functions are quotients of theta functions [NIST2012, §23.6]. With and in the notation of acb_modular,
where is the Dedekind eta function. The lattice roots are , and , the invariants are and , and the inverse function is the elliptic integral .
All of these need theta values at one , and the theta functions are evaluated after reducing to the fundamental domain, so the cost is multiplications for every .
Modular forms#
A modular form of weight satisfies for , so it can be evaluated at the image of in the fundamental domain , where and the -series converge geometrically with ratio (for ).
Input: in the upper half-plane, a tolerance .
Output: with in up to .
- .
- Repeat: let be the nearest integer to , and ; if , return ; otherwise and .
Each inversion multiplies by , which guarantees termination. acb_modular_fundamental_domain_approx runs the algorithm on the midpoint in double arithmetic when possible and in arf arithmetic at the working precision otherwise, and then applies to the ball once, which does not need to be exact: reducing to instead of 1 is enough for fast convergence.
Transformation formulas. The eta function transforms as with a 24th root of unity given by Dedekind sums (acb_modular_epsilon_arg), and the four theta functions are permuted with 8th roots of unity and the factors of acb_modular_theta_transform [Rad1973].
-series. On , the theta constants and the eta function are lacunary series,
(with and ), which need terms. The powers of with exponents in the sequence of generalised pentagonal numbers (or squares and pronic numbers) are computed with an addition sequence in which most terms cost one multiplication; Enge, Hart and Johansson [EHJ2016] construct short addition sequences for these exponents (acb_modular_addseq_eta, acb_modular_addseq_theta). For many terms, rectangular splitting is used instead: the series is written as a polynomial in for a well-chosen such that the exponents modulo take few values, which replaces most full multiplications by cheaper additions and scalar operations. Each term is computed at a precision reduced according to its magnitude (_acb_modular_mul).
Forms computed from theta constants. With at the reduced point:
and the higher Eisenstein series follow from the recurrence for [Apostol1997, Theorem 1.13]. is invariant under and under (for , the transformation of the theta functions is applied).
Class polynomials. The Hilbert class polynomial is the product of over the CM points of the reduced forms of discriminant . Its coefficients have about bits; computing the roots to that precision and expanding the product with a binary product tree gives the polynomial with a certificate when every coefficient ball contains a unique integer [Enge2009]. See Hilbert class polynomials.
Use in FLINT#
acb_agm1,acb_agm1_cpx,acb_agm,arb_agm(acb,arb): the AGM.acb_elliptic_k,acb_elliptic_k_jet,acb_elliptic_e: complete integrals by the AGM;acb_elliptic_pi: via and .acb_elliptic_rf,acb_elliptic_rj_carlson,acb_elliptic_rj,acb_elliptic_rj_integration,acb_elliptic_rg,acb_elliptic_rc1: Carlson's integrals;acb_elliptic_f,acb_elliptic_e_inc,acb_elliptic_pi_inc: Legendre forms.acb_elliptic_p,acb_elliptic_p_prime,acb_elliptic_p_jet,acb_elliptic_zeta,acb_elliptic_sigma,acb_elliptic_roots,acb_elliptic_invariants,acb_elliptic_inv_p: Weierstrass functions.acb_modular_fundamental_domain_approx,acb_modular_theta,acb_modular_eta,acb_modular_j,acb_modular_delta,acb_modular_lambda,acb_modular_eisenstein,acb_modular_hilbert_class_poly: modular forms.
Referenced from#
- acb.h (module)
- Carlson symmetric integrals
- acb_elliptic.h (module)
acb_elliptic_k- acb_modular.h (module)
- The Gauss hypergeometric function (algorithm)
References#
- [Joh2019] F. Johansson. Numerical evaluation of elliptic functions, elliptic integrals and modular forms. In J. Blümlein, C. Schneider and P. Paule (eds.), Elliptic Integrals, Elliptic Functions and Modular Forms in Quantum Field Theory, Texts & Monographs in Symbolic Computation, Springer, 2019, 269–293. https://arxiv.org/abs/1806.06725
- [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
- [NIST2012] National Institute of Standards and Technology, Digital Library of Mathematical Functions (2012), https://dlmf.nist.gov/
- [Car1995] B. C. Carlson, "Numerical computation of real or complex elliptic integrals". Numerical Algorithms, 10(1):13-26 (1995).
- [Rad1973] H. Rademacher, Topics in analytic number theory, Springer, 1973.
- [EHJ2016] A. Enge, W. Hart and F. Johansson, "Short addition sequences for theta functions", preprint (2016), https://arxiv.org/abs/1608.06810
- [Apostol1997] Apostol, Tom : Modular functions and Dirichlet series in number theory, Springer (1997)
- [Enge2009] A. Enge. The complexity of class polynomial computation via floating point approximations. Mathematics of Computation 78 (2009), 1089–1107. https://doi.org/10.1090/S0025-5718-08-02200-X
The FLINT team, “Elliptic integrals, elliptic functions and modular forms,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/elliptic-modular.html (generated 2026-11-02).
@misc{flint-doc-algorithms-special-functions-elliptic-modular,
author = {{The FLINT team}},
title = {{Elliptic integrals, elliptic functions and modular forms}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/special-functions/elliptic-modular.html},
note = {Generated 2026-11-02}
}