Elliptic integrals
The complete elliptic integrals of the first and second kind, K(m) and E(m), arise in pendulum motion, magnetic field calculations, and conformal mapping. Both are computed via the arithmetic-geometric mean (AGM) recurrence, which converges quadratically in about 10 iterations.
ellipk
Section titled “ellipk”Signature: (m: f32) -> f32
Computes the complete elliptic integral of the first kind, K(m) = integral(0, pi/2, dt / sqrt(1 - m*sin^2(t))). Uses K(m) = pi / (2 * AGM(1, sqrt(1-m))).
- Domain: m in [0, 1)
- At m = 1: returns +inf (logarithmic singularity)
- Outside [0, 1]: returns NaN
- Precision: ~1e-8 relative
import Nautilus.Special (ellipk)
k0 = ellipk(cast(0.0, f32)) -- pi/2 = approximately 1.5708k_half = ellipk(cast(0.5, f32)) -- approximately 1.8541ellipe
Section titled “ellipe”Signature: (m: f32) -> f32
Computes the complete elliptic integral of the second kind, E(m) = integral(0, pi/2, sqrt(1 - m*sin^2(t)) dt). Uses the AGM recurrence with an accumulated sum of squared differences.
- Domain: m in [0, 1]
- At m = 0: returns pi/2
- At m = 1: returns 1.0
- Outside [0, 1]: returns NaN
- Precision: ~1e-8 relative
import Nautilus.Special (ellipe)
e0 = ellipe(cast(0.0, f32)) -- pi/2 = approximately 1.5708e_half = ellipe(cast(0.5, f32)) -- approximately 1.3506e1 = ellipe(cast(1.0, f32)) -- 1.0Edge cases
Section titled “Edge cases”| Input m | ellipk | ellipe |
|---|---|---|
| 0.0 | pi/2 | pi/2 |
| 1.0 | +inf | 1.0 |
| negative | NaN | NaN |
| > 1.0 | NaN | NaN |
| NaN | NaN | NaN |