Elliptic integrals and functions — NumPy, PyTorch, JAX
Project description
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.
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"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file elliptic_functions-4.0.0.tar.gz.
File metadata
- Download URL: elliptic_functions-4.0.0.tar.gz
- Upload date:
- Size: 36.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6de562f0b65c6c9e8bd3a08bbbf856ff41ec4ff3bebec312656cce450f143e96
|
|
| MD5 |
f636ffbe427fe06d48da1f4c24fea278
|
|
| BLAKE2b-256 |
8f33e86264835858b560ce90d459842f8ab75373d49416890ade00385e064165
|
Provenance
The following attestation bundles were made for elliptic_functions-4.0.0.tar.gz:
Publisher:
python.yml on moiseevigor/elliptic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
elliptic_functions-4.0.0.tar.gz -
Subject digest:
6de562f0b65c6c9e8bd3a08bbbf856ff41ec4ff3bebec312656cce450f143e96 - Sigstore transparency entry: 1340628505
- Sigstore integration time:
-
Permalink:
moiseevigor/elliptic@56ed16edc9d9e6928041a5b6e53ffdeb790c0c50 -
Branch / Tag:
refs/tags/v4.0.0 - Owner: https://github.com/moiseevigor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@56ed16edc9d9e6928041a5b6e53ffdeb790c0c50 -
Trigger Event:
release
-
Statement type:
File details
Details for the file elliptic_functions-4.0.0-py3-none-any.whl.
File metadata
- Download URL: elliptic_functions-4.0.0-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ddf1c0519fcd1fccb8db4c0ca9c16dc677347cfcada4914b45f8faa29ad4ac3
|
|
| MD5 |
bb52733acf502c02b878d5c0856ec571
|
|
| BLAKE2b-256 |
d6fde0922d98478045918c3fd6067700f26699add574a7fb814281535a736f8b
|
Provenance
The following attestation bundles were made for elliptic_functions-4.0.0-py3-none-any.whl:
Publisher:
python.yml on moiseevigor/elliptic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
elliptic_functions-4.0.0-py3-none-any.whl -
Subject digest:
1ddf1c0519fcd1fccb8db4c0ca9c16dc677347cfcada4914b45f8faa29ad4ac3 - Sigstore transparency entry: 1340628509
- Sigstore integration time:
-
Permalink:
moiseevigor/elliptic@56ed16edc9d9e6928041a5b6e53ffdeb790c0c50 -
Branch / Tag:
refs/tags/v4.0.0 - Owner: https://github.com/moiseevigor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@56ed16edc9d9e6928041a5b6e53ffdeb790c0c50 -
Trigger Event:
release
-
Statement type: