Skip to main content

elliptic (Python)

Standalone Python implementation of elliptic integrals and functions. Works identically on NumPy arrays, PyTorch tensors (CPU and CUDA), and JAX arrays — no scipy runtime dependency.

tests

Install

pip install elliptic-functions                   # NumPy only
pip install "elliptic-functions[torch]"          # + PyTorch backend
pip install "elliptic-functions[jax]"            # + JAX backend
pip install "elliptic-functions[dev]"            # + test deps (scipy, mpmath, pytest)

Quick start

import numpy as np
import elliptic

phi = np.linspace(0, np.pi/2, 200)
m   = 0.7

# Incomplete integrals F(φ|m), E(φ|m), Jacobi zeta Z(φ|m)
F, E, Z = elliptic.elliptic12(phi, m)

# Third kind Π(φ,m,n)  — missing from scipy (issue #4452)
Pi = elliptic.elliptic3(phi, m, 0.3)

# Jacobi elliptic functions sn, cn, dn, am
sn, cn, dn, am = elliptic.ellipj(np.linspace(0, 3, 100), m)

# Associate incomplete integrals B, D, J  (DLMF §19.2)
B, D, J = elliptic.ellipticBDJ(phi, m, 0.3)
# identities: F = B+D,  E = B+(1-m)D,  Pi = B+D+n*J

# Complete associate integrals B(m), D(m), S(m)
B_c, D_c, S_c = elliptic.ellipticBD(np.array([0.3, 0.5, 0.7]))

# Carlson symmetric forms  (DLMF §19.16)
RF = elliptic.carlsonRF(0.0, 1.0 - m, 1.0)    # = K(m)
RD = elliptic.carlsonRD(0.0, 1.0 - m, 1.0)    # = 3D(m)

# Bulirsch generalised complete integrals
K  = elliptic.cel1(np.sqrt(1 - m))             # = K(m)
E2 = elliptic.cel2(np.sqrt(1 - m), 1.0, 1-m)  # = E(m)

# Jacobi theta functions (4 types)
Th3 = elliptic.theta(3, phi, m)
Th,  H  = elliptic.jacobiThetaEta(np.linspace(0, 1, 50), m)
Th3, dTh3 = elliptic.theta_prime(3, phi, m)

# Weierstrass functions
e1, e2, e3 = 2.0, 0.5, -2.5
P   = elliptic.weierstrassP(0.4, e1, e2, e3)
Zf  = elliptic.weierstrassZeta(0.4, e1, e2, e3)
S   = elliptic.weierstrassSigma(0.4, e1, e2, e3)
dP  = elliptic.weierstrassPPrime(0.4, e1, e2, e3)
g2, g3, Delta = elliptic.weierstrassInvariants(e1, e2, e3)

# Nome and inverse
q = elliptic.nomeq(m)
m_back = elliptic.inversenomeq(q)

# Inverse E(phi|m): given E value, solve for phi
phi_inv = elliptic.inverselliptic2(E, m)

# Arithmetic-geometric mean
agm_val = elliptic.agm(1.0, np.sqrt(1 - m))   # = π/(2K(m))

# Complex arguments
import numpy as np
u_c = np.array([0.4 + 0.3j, 0.8 - 0.2j])
Fi, Ei, Zi = elliptic.elliptic12i(u_c, m)
sni, cni, dni = elliptic.ellipji(u_c, m)

# Application: ellipse arc length
arc = elliptic.arclength_ellipse(5, 10)       # full perimeter ≈ 48.44
arc = elliptic.arclength_ellipse(5, 10, 0, np.pi/4)  # quarter arc

GPU (PyTorch)

Pass a torch.Tensor on any device:

import torch, elliptic

phi = torch.linspace(0.01, 1.5, 1_000_000, dtype=torch.float64, device="cuda")
F, E, Z = elliptic.elliptic12(phi, torch.full_like(phi, 0.7))

JAX (jit / vmap)

import jax, jax.numpy as jnp, elliptic

phi = jnp.linspace(0.01, 1.5, 10_000)
F, E, Z = jax.jit(elliptic.elliptic12)(phi, 0.7)

Comparison with scipy.special

Function scipy elliptic
K(m), E(m) ✓ ✓
F(φ,m), E(φ,m) ✓ ✓
Jacobi sn/cn/dn (real) ✓ ✓
Jacobi sn/cn/dn (complex) ✗ ✓
F(u,m), E(u,m) (complex) ✗ ✓
Π(φ,m,n) — 3rd kind ✗ (open since 2015) ✓
Carlson RF/RD/RJ/RC ✓ since v1.8 ✓
B, D, J associate ✗ ✓
Bulirsch cel ✗ ✓
Jacobi theta θ₁…θ₄ ✗ ✓
Weierstrass P/ζ/σ/℘′ ✗ ✓
Weierstrass invariants g₂,g₃ ✗ ✓
Nome q(m) and m(q) ✗ ✓
Inverse E(φ,m) ✗ ✓
AGM ✗ ✓
Ellipse arc length ✗ ✓
PyTorch GPU ✗ ✓
JAX jit/vmap ✗ ✓

All algorithms run identically across backends — the same Python code dispatches to NumPy, PyTorch CUDA, or JAX TPU.

References

  • Abramowitz & Stegun, Handbook of Mathematical Functions, §16–18
  • NIST DLMF §19, §22, §23 — https://dlmf.nist.gov
  • Fukushima (2015), "Elliptic functions and elliptic integrals for celestial mechanics"
  • Bulirsch (1965), "Numerical computation of elliptic integrals"
  • Carlson (1995), "Numerical Computation of Real or Complex Elliptic Integrals"
  • Boyd (2012), "Numerical inversion of the incomplete elliptic integral of the second kind"

Metadata

Release files for elliptic-functions 4.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elliptic-functions 4.2.0
File Size Uploaded
elliptic_functions-4.2.0.tar.gz 201.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for elliptic-functions 4.2.0
File Interpreter ABI Platform
elliptic_functions-4.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 236.7 kB

Release files / elliptic_functions-4.2.0.tar.gz

Download URL elliptic_functions-4.2.0.tar.gz
Size 201.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3123d88f55e492708b0058b67881d6b4b2883f874c8081ec12b029fe06a7f750
BLAKE2b-256 checksum
How to use checksums
e92b824733f114f8c656154b6983c50d4c485fea60f8808992bacf0bf485697e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / elliptic_functions-4.2.0-py3-none-any.whl

Download URL elliptic_functions-4.2.0-py3-none-any.whl
Size 35.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1ec81ccba0458d90568c39b9de6b9ee7fa6d65feb6ff894e486c35ee6f119c9
BLAKE2b-256 checksum
How to use checksums
55949a01292a5c37e66b5155c1f1bd96f2efe4b86db6c587f29b2caed6811acd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

4.2.0 This release

2 release files

4.1.0

2 release files

4.0.2

2 release files

4.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page