FLINT3.7.0-dev
Module · 25 functions

acb_elliptic.h

#include <flint/acb_elliptic.h>

This module evaluates elliptic integrals and elliptic (doubly periodic) functions of complex variables with rigorous error bounds:

  • the complete elliptic integrals K(m)K(m), E(m)E(m) and Π(n,m)\Pi(n, m), computed with the arithmetic-geometric mean;
  • the incomplete Legendre integrals F(ϕ,m)F(\phi, m), E(ϕ,m)E(\phi, m) and Π(n,ϕ,m)\Pi(n, \phi, m), reduced to Carlson's symmetric integrals;
  • the Carlson symmetric integrals RFR_F, RGR_G, RJR_J and the special cases RCR_C and RDR_D, computed by the duplication algorithm with a high-order Taylor expansion;
  • the Weierstrass functions ℘\wp, ℘′\wp', ℘−1\wp^{-1}, ζ\zeta and σ\sigma for the lattice Z+τZ\mathbb{Z} + \tau\mathbb{Z}, and the lattice invariants and roots, computed with Jacobi theta functions.

The modular forms and theta functions on which the Weierstrass functions are built are in acb_modular (genus 1) and acb_theta (any genus). The algorithms are described in Elliptic integrals, elliptic functions and modular forms, following [Joh2019].

AlgorithmElliptic integrals, elliptic functions and modular formsThe complex arithmetic-geometric mean with Dupont's error bound, complete and incomplete elliptic integrals through the AGM and Carlson's duplication algorithm with high-order Taylor series, Weierstrass functions via theta functions, and modular forms by reduction to the fundamental domain and q-series with short addition sequences.

Conventions#

  • The parameter mm of the Legendre integrals is the parameter, related to the modulus kk and the modular angle α\alpha by m=k2=sin⁡2αm = k^2 = \sin^2 \alpha (as in [NIST2012, §19.1]).
  • In the Weierstrass functions, the lattice is Λ=Z+τZ\Lambda = \mathbb{Z} + \tau \mathbb{Z} with Im⁡(τ)>0\operatorname{Im}(\tau) > 0, that is, the half-periods are ω1=1/2\omega_1 = 1/2 and ω3=τ/2\omega_3 = \tau/2. A general lattice 2ω1Z+2ω3Z2\omega_1 \mathbb{Z} + 2\omega_3 \mathbb{Z} is handled by the homogeneity relations, for instance ℘(z;2ω1,2ω3)=(2ω1)−2℘(z/(2ω1),ω3/ω1)\wp(z; 2\omega_1, 2\omega_3) = (2\omega_1)^{-2} \wp(z/(2\omega_1), \omega_3/\omega_1).
  • A nonzero flag times_pi replaces the amplitude ϕ\phi by πϕ\pi \phi, which makes the quasi-period 1 instead of π\pi and allows exact input at multiples of π/2\pi/2.
  • The flags arguments of the Carlson integrals are reserved for future use; pass 0.
  • Outputs may alias inputs. A function returns indeterminate balls (or balls containing the result with infinite radius) when the input is not finite, lies on or straddles a singularity, or the algorithm cannot separate the input from a branch cut.

Complete elliptic integrals#

void acb_elliptic_k(acb_t k, const acb_t m, slong prec)

Sets k to the complete elliptic integral of the first kind K(m)=∫0π/2(1−msin⁡2t)−1/2 dtK(m) = \int_0^{\pi/2} (1 - m \sin^2 t)^{-1/2} \, dt, computed as K(m)=π/(2M(1−m))K(m) = \pi / (2 M(\sqrt{1-m})) where M(z)=agm⁡(1,z)M(z) = \operatorname{agm}(1, z) is computed by acb_agm1. The branch cut is m∈[1,∞)m \in [1, \infty).

More
void acb_elliptic_k_jet(acb_ptr w, const acb_t m, slong len, slong prec)

Sets w to the Taylor coefficients of K(m+x)K(m + x) at x=0x = 0, truncated to length len. The first two coefficients come from (M,M′)(M, M') evaluated by acb_agm1_cpx, the others from the linear recurrence implied by the hypergeometric differential equation of KK.

More
void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, slong len, slong prec)

Set res to K(m(x))K(m(x)) truncated to length len, for a power series m(x)m(x), by composing the output of acb_elliptic_k_jet with the nonconstant part of mm. The underscore version requires len ≥1\ge 1 and reads min⁡(mlen,len)\min(\text{mlen}, \text{len}) coefficients of m.

void acb_elliptic_e(acb_t res, const acb_t m, slong prec)

Sets res to the complete elliptic integral of the second kind E(m)=∫0π/2(1−msin⁡2t)1/2 dtE(m) = \int_0^{\pi/2} (1 - m \sin^2 t)^{1/2} \, dt, computed from K(m)K(m) and K′(m)K'(m) by E(m)=(1−m)(2mK′(m)+K(m))E(m) = (1-m)(2m K'(m) + K(m)), where K′K' is the derivative (not the complementary integral).

More
void acb_elliptic_pi(acb_t r, const acb_t n, const acb_t m, slong prec)

Sets r to the complete elliptic integral of the third kind Π(n,m)=∫0π/2(1−nsin⁡2t)−1(1−msin⁡2t)−1/2 dt\Pi(n, m) = \int_0^{\pi/2} (1 - n \sin^2 t)^{-1} (1 - m \sin^2 t)^{-1/2} \, dt. For n=0n = 0 this is K(m)K(m) and for m=0m = 0 it is π2(1−n)−1/2\frac{\pi}{2}(1-n)^{-1/2}; otherwise it is computed as RF(0,1−m,1)+n3RJ(0,1−m,1,1−n)R_F(0, 1-m, 1) + \frac{n}{3} R_J(0, 1-m, 1, 1-n), the same reduction as for the incomplete integral, which is slower than the AGM methods for KK and EE.

More

Legendre incomplete elliptic integrals#

The incomplete integrals are computed on the strip ∣Re⁡(ϕ)∣≤π/2|\operatorname{Re}(\phi)| \le \pi/2 by the reductions to Carlson's integrals of [NIST2012, §19.25(i)], with s=sin⁡ϕs = \sin \phi and c=cos⁡ϕc = \cos \phi:

F(ϕ,m)=sRF(c2,1−ms2,1),E(ϕ,m)=sRF(c2,1−ms2,1)−m3s3RD(c2,1−ms2,1),F(\phi, m) = s R_F(c^2, 1 - ms^2, 1), \quad E(\phi, m) = s R_F(c^2, 1-ms^2, 1) - \tfrac{m}{3} s^3 R_D(c^2, 1-ms^2, 1),
Π(n,ϕ,m)=sRF(c2,1−ms2,1)+n3s3RJ(c2,1−ms2,1,1−ns2).\Pi(n, \phi, m) = s R_F(c^2, 1-ms^2, 1) + \tfrac{n}{3} s^3 R_J(c^2, 1-ms^2, 1, 1-ns^2).

Outside the strip the functions are extended by quasi-periodicity: writing ϕ=ϕ′+dπ\phi = \phi' + d \pi with d∈Zd \in \mathbb{Z} and ∣Re⁡(ϕ′)∣≤π/2|\operatorname{Re}(\phi')| \le \pi/2, the integral over a full period is added dd times. If Re⁡(ϕ)\operatorname{Re}(\phi) is a ball that contains a point π/2+dπ\pi/2 + d \pi, both neighbouring values of dd are tried and the union of the results is returned; if it is wider than π/2\pi/2, the result is indeterminate.

void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int times_pi, slong prec)

Sets res to the incomplete elliptic integral of the first kind F(ϕ,m)=∫0ϕ(1−msin⁡2t)−1/2 dtF(\phi, m) = \int_0^\phi (1 - m \sin^2 t)^{-1/2} \, dt, extended by F(ϕ+dπ,m)=2dK(m)+F(ϕ,m)F(\phi + d\pi, m) = 2 d K(m) + F(\phi, m). With times_pi nonzero, ϕ\phi is replaced by πϕ\pi \phi. In particular F(π/2,m)=K(m)F(\pi/2, m) = K(m).

More
void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int times_pi, slong prec)

Sets res to the incomplete elliptic integral of the second kind E(ϕ,m)=∫0ϕ(1−msin⁡2t)1/2 dtE(\phi, m) = \int_0^\phi (1 - m \sin^2 t)^{1/2} \, dt, extended by E(ϕ+dπ,m)=2dE(m)+E(ϕ,m)E(\phi + d\pi, m) = 2 d E(m) + E(\phi, m). With times_pi nonzero, ϕ\phi is replaced by πϕ\pi \phi. In particular E(π/2,m)=E(m)E(\pi/2, m) = E(m).

More
void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int times_pi, slong prec)

Sets res to the incomplete elliptic integral of the third kind Π(n,ϕ,m)=∫0ϕ(1−nsin⁡2t)−1(1−msin⁡2t)−1/2 dt\Pi(n, \phi, m) = \int_0^\phi (1 - n \sin^2 t)^{-1} (1 - m \sin^2 t)^{-1/2} \, dt, extended by Π(n,ϕ+dπ,m)=2dΠ(n,m)+Π(n,ϕ,m)\Pi(n, \phi + d\pi, m) = 2 d \Pi(n, m) + \Pi(n, \phi, m). With times_pi nonzero, ϕ\phi is replaced by πϕ\pi \phi. In particular Π(n,π/2,m)=Π(n,m)\Pi(n, \pi/2, m) = \Pi(n, m) and Π(0,ϕ,m)=F(ϕ,m)\Pi(0, \phi, m) = F(\phi, m).

More

Carlson symmetric integrals#

Carlson's symmetric forms are the preferred form of incomplete elliptic integrals: they are symmetric in their arguments, homogeneous, and can be computed by a duplication algorithm [Car1995]. Every elliptic integral can be expressed in terms of RFR_F, RGR_G and RJR_J, of which RC(x,y)=RF(x,y,y)R_C(x, y) = R_F(x, y, y) and RD(x,y,z)=RJ(x,y,z,z)R_D(x, y, z) = R_J(x, y, z, z) are special cases. Carlson symmetric integrals explains the domains of validity and the choice of method.

void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec)

Sets res to the Carlson symmetric integral of the first kind RF(x,y,z)=12∫0∞((t+x)(t+y)(t+z))−1/2 dtR_F(x, y, z) = \frac12 \int_0^\infty ((t+x)(t+y)(t+z))^{-1/2} \, dt, by duplication steps followed by a Taylor series in the elementary symmetric polynomials of the deviations. The result is indeterminate if more than one argument contains zero.

Full documentation
void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec)

Sets res to the Carlson symmetric integral of the second kind RGR_G, computed from RFR_F and RDR_D. There are no restrictions on the arguments.

Full documentation
void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec)
void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec)
void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec)

Set res to the Carlson symmetric integral of the third kind RJ(x,y,z,p)=32∫0∞(t+p)−1((t+x)(t+y)(t+z))−1/2 dtR_J(x, y, z, p) = \frac32 \int_0^\infty (t+p)^{-1} ((t+x)(t+y)(t+z))^{-1/2} \, dt. The carlson version uses the duplication algorithm, which can give wrong values for some complex arguments; the integration version moves the arguments to the right half-plane by numerical integration; the default version uses the duplication algorithm when it is known to be correct (including the case p=zp = z, which computes RD(x,y,z)R_D(x, y, z)) and integration otherwise.

Full documentation
void acb_elliptic_rc1(acb_t res, const acb_t x, slong prec)

Sets res to RC(1,1+x)=atan⁡(x)/xR_C(1, 1+x) = \operatorname{atan}(\sqrt{x})/\sqrt{x}, a helper for RJR_J, using a short Taylor series for small ∣x∣|x|.

Full documentation

Weierstrass elliptic functions#

The Weierstrass functions for the lattice Z+τZ\mathbb{Z} + \tau\mathbb{Z} are computed from the Jacobi theta functions θi(z,τ)\theta_i(z, \tau) of acb_modular, which moves τ\tau to the fundamental domain and reduces zz before summing the theta series. Because the Weierstrass functions are invariant (or covariant) under the action of the modular group, the cost is O(log⁡p)O(\log p) multiplications plus the theta series, which needs O(p)O(\sqrt{p}) terms at precision pp. The reference is [NIST2012, Ch. 23]. When zz is real and Re⁡(τ)\operatorname{Re}(\tau) is a multiple of 1/21/2, the functions are real and the imaginary part of the output is set to exactly zero.

void acb_elliptic_p(acb_t r, const acb_t z, const acb_t tau, slong prec)

Sets r to the Weierstrass elliptic function ℘(z,τ)=z−2+∑ω∈Λ∖0((z+ω)−2−ω−2)\wp(z, \tau) = z^{-2} + \sum_{\omega \in \Lambda \setminus 0} ((z + \omega)^{-2} - \omega^{-2}), computed by

℘(z,τ)=π2θ22(0,τ)θ32(0,τ)θ42(z,τ)θ12(z,τ)−π23[θ24(0,τ)+θ34(0,τ)].\wp(z, \tau) = \pi^2 \theta_2^2(0,\tau) \theta_3^2(0,\tau) \frac{\theta_4^2(z,\tau)}{\theta_1^2(z,\tau)} - \frac{\pi^2}{3} \left[ \theta_2^4(0,\tau) + \theta_3^4(0,\tau)\right].
void acb_elliptic_p_prime(acb_t r, const acb_t z, const acb_t tau, slong prec)

Sets r to the derivative ℘′(z,τ)\wp'(z, \tau) with respect to zz, computed by ℘′(z,τ)=(−2πη(τ)2/θ1(z,τ))3 θ2(z,τ)θ3(z,τ)θ4(z,τ)\wp'(z,\tau) = (-2\pi \eta(\tau)^2/\theta_1(z,\tau))^3 \, \theta_2(z,\tau) \theta_3(z,\tau) \theta_4(z,\tau), where η\eta is the Dedekind eta function.

void acb_elliptic_p_jet(acb_ptr r, const acb_t z, const acb_t tau, slong len, slong prec)

Sets r to the Taylor coefficients of ℘(z+x,τ)\wp(z + x, \tau) at x=0x = 0, truncated to length len, from the theta function jets of acb_modular_theta_jet. With len = 2 this gives (℘(z,τ),℘′(z,τ))(\wp(z, \tau), \wp'(z, \tau)), which generate the field of elliptic functions with periods 1 and τ\tau.

void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec)
void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong len, slong prec)

Set res to ℘(z(x),τ)\wp(z(x), \tau) truncated to length len, for a power series z(x)z(x). The underscore version requires len ≥1\ge 1.

void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, slong prec)

Sets g2 and g3 to the lattice invariants g2=60G4(τ)g_2 = 60 G_4(\tau) and g3=140G6(τ)g_3 = 140 G_6(\tau), where G2kG_{2k} are the Eisenstein series of acb_modular_eisenstein. They are the coefficients of the differential equation ℘′2=4℘3−g2℘−g3\wp'^2 = 4 \wp^3 - g_2 \wp - g_3.

void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, slong prec)

Sets e1, e2, e3 to the lattice roots, the roots of 4x3−g2x−g34x^3 - g_2 x - g_3, which are e1=℘(1/2)e_1 = \wp(1/2), e2=℘((1+τ)/2)e_2 = \wp((1 + \tau)/2) and e3=℘(τ/2)e_3 = \wp(\tau/2), computed from the fourth powers of the theta constants [NIST2012, 23.6.2–23.6.4]. The outputs are indeterminate if Im⁡(τ)\operatorname{Im}(\tau) is not certainly positive.

More
void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, slong prec)

Sets res to the inverse Weierstrass function, a solution ww of ℘(w,τ)=z\wp(w, \tau) = z, given by the elliptic integral

℘−1(z,τ)=12∫z∞dt(t−e1)(t−e2)(t−e3)=RF(z−e1,z−e2,z−e3).\wp^{-1}(z, \tau) = \frac12 \int_z^\infty \frac{dt}{\sqrt{(t-e_1)(t-e_2)(t-e_3)}} = R_F(z - e_1, z - e_2, z - e_3).
void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, slong prec)

Sets res to the Weierstrass zeta function ζ(z,τ)=z−1+∑ω≠0((z−ω)−1+ω−1+zω−2)\zeta(z, \tau) = z^{-1} + \sum_{\omega \ne 0} ((z - \omega)^{-1} + \omega^{-1} + z \omega^{-2}), which satisfies ζ′=−℘\zeta' = -\wp and is quasi-periodic: ζ(z+1)=ζ(z)+2η1\zeta(z + 1) = \zeta(z) + 2\eta_1, ζ(z+τ)=ζ(z)+2η3\zeta(z + \tau) = \zeta(z) + 2\eta_3 with η1=ζ(1/2)\eta_1 = \zeta(1/2) and η3=ζ(τ/2)\eta_3 = \zeta(\tau/2). It is computed as ζ(z)=2η1z+θ1′(z,τ)/θ1(z,τ)\zeta(z) = 2 \eta_1 z + \theta_1'(z, \tau)/\theta_1(z, \tau), where η1=−θ1′′′(0,τ)/(6θ1′(0,τ))\eta_1 = -\theta_1'''(0, \tau) / (6 \theta_1'(0, \tau)).

void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, slong prec)

Sets res to the Weierstrass sigma function σ(z,τ)=z∏ω≠0(1−z/ω)exp⁡(z/ω+z2/(2ω2))\sigma(z, \tau) = z \prod_{\omega \ne 0} (1 - z/\omega) \exp(z/\omega + z^2/(2\omega^2)), which satisfies σ′/σ=ζ\sigma'/\sigma = \zeta, computed as σ(z)=eη1z2θ1(z,τ)/θ1′(0,τ)\sigma(z) = e^{\eta_1 z^2} \theta_1(z, \tau) / \theta_1'(0, \tau).

More

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
  • [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).
Cite this page

The FLINT team, “acb_elliptic.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/acb_elliptic/index.html (generated 2026-11-02).