public/js/elliptic-core.js and in the Python elliptic
package.
Where elliptic integrals come from
Compute the arc length of an ellipse of semi-axes $a > b$:
\[L \;=\; \int_0^{2\pi} \sqrt{a^2 \sin^2 t + b^2 \cos^2 t}\,dt \;=\; 4 a \int_0^{\pi/2} \sqrt{1 - e^2 \sin^2 t}\,dt\]with eccentricity $e^2 = 1 - b^2/a^2$. The integrand has no elementary antiderivative — Liouville (1830s) showed that the resulting function is genuinely transcendental beyond elementary (it is not expressible by finite combinations of polynomials, exponentials, logarithms, and roots). Following Legendre, define the complete elliptic integral of the second kind
\[E(m) \;:=\; \int_0^{\pi/2}\sqrt{1 - m \sin^2 t}\,dt,\]so $L = 4 a E(e^2)$. This is one of three Legendre forms; the other two are the first kind
\[K(m) \;:=\; \int_0^{\pi/2}\frac{dt}{\sqrt{1 - m \sin^2 t}},\]and the third kind $\Pi(n; m)$ involving an extra rational factor. $K$ is what governs the pendulum’s period; $E$ is what governs the elastica’s plane-curve integration; both appear in the Sachkov closed forms of Part 2 §4.
The two come together in Legendre’s relation:
\[E(m) K(1 - m) + E(1 - m) K(m) - K(m) K(1 - m) \;=\; \tfrac{\pi}{2}.\]This identity is what lets the elliptic package validate its own implementations: every solution should satisfy Legendre’s relation to machine precision.
Inverting the integral: the Jacobi amplitude
Just as $\arcsin$ is the inverse of $\sin$, define $\mathrm{am}(u\mid m)$ as the inverse of the incomplete first-kind integral
\[F(\phi\mid m) \;:=\; \int_0^\phi \frac{dt}{\sqrt{1 - m \sin^2 t}}.\]That is, $\phi = \mathrm{am}(u\mid m)$ iff $u = F(\phi\mid m)$. Then
\[\boxed{\;\mathrm{sn}(u\mid m) \;:=\; \sin\bigl(\mathrm{am}(u\mid m)\bigr), \qquad \mathrm{cn}(u\mid m) \;:=\; \cos\bigl(\mathrm{am}(u\mid m)\bigr), \qquad \mathrm{dn}(u\mid m) \;:=\; \sqrt{1 - m\,\mathrm{sn}^2(u\mid m)}.\;}\]When $m \to 0$: $F(\phi\mid 0) = \phi$, so $\mathrm{am}(u\mid 0) = u$, and $\mathrm{sn} \to \sin, \mathrm{cn} \to \cos, \mathrm{dn} \to 1$. When $m \to 1^-$: $F(\phi\mid 1) = \mathrm{atanh}(\sin\phi)$, so $\mathrm{sn}(u\mid 1) = \tanh u$, $\mathrm{cn}(u\mid 1) = \mathrm{dn}(u\mid 1) = \mathrm{sech}\,u$. At intermediate $m$ they interpolate.
The functions are doubly-periodic when extended to the complex plane: $\mathrm{sn}$ has real period $4K(m)$ and imaginary period $2iK(1 - m)$. This makes them functions on the elliptic curve $y^2 = (1 - x^2)(1 - mx^2)$ — from which much of the theory’s algebraic structure comes.
elliptic-core.js.
Differential equations
Differentiating $u = F(\phi\mid m)$ with respect to $u$:
\[1 \;=\; \frac{d\phi}{du} \cdot \frac{1}{\sqrt{1 - m \sin^2\phi}} \;\Rightarrow\; \frac{d\phi}{du} \;=\; \sqrt{1 - m\sin^2\phi} \;=\; \mathrm{dn}(u\mid m).\]So $\mathrm{am}’(u) = \mathrm{dn}(u)$, and chain rule gives
\[\boxed{\;\mathrm{sn}'(u) = \mathrm{cn}(u)\,\mathrm{dn}(u), \quad \mathrm{cn}'(u) = -\mathrm{sn}(u)\,\mathrm{dn}(u), \quad \mathrm{dn}'(u) = -m\,\mathrm{sn}(u)\,\mathrm{cn}(u).\;}\]Squaring the first identity and using the Pythagorean relations $\mathrm{sn}^2 + \mathrm{cn}^2 = 1$ and $m\,\mathrm{sn}^2 + \mathrm{dn}^2 = 1$ yields the cleanest single ODE:
\[(\mathrm{sn}')^2 \;=\; (1 - \mathrm{sn}^2)(1 - m\,\mathrm{sn}^2),\]a cubic-in-the-square ODE — exactly what falls out of the pendulum equation $\ddot\varphi + \sin\varphi = 0$ after the substitution $\sin(\varphi/2) = k\,\mathrm{sn}(s\mid k^2)$. Tracing this:
\[\dot\varphi \;=\; 2\dot{(\varphi/2)} \;=\; 2\,\frac{d\arcsin(k\,\mathrm{sn})}{ds} \;=\; \frac{2k\,\mathrm{cn}\,\mathrm{dn}}{\cos(\varphi/2)} \;=\; 2k\,\mathrm{cn}(s),\](using $\cos(\varphi/2) = \sqrt{1 - k^2\,\mathrm{sn}^2} = \mathrm{dn}(s)$.) Differentiate once more:
\[\ddot\varphi \;=\; 2k\,\mathrm{cn}'(s) \;=\; -2k\,\mathrm{sn}(s)\,\mathrm{dn}(s).\]And $\sin\varphi = 2\sin(\varphi/2)\cos(\varphi/2) = 2k\,\mathrm{sn}(s)\,\mathrm{dn}(s)$, so $\ddot\varphi + \sin\varphi = 0$. ✓
This is the identity behind the elastica: the pendulum solution is literally the Jacobi-am function, and the curvature $\kappa(s) = \dot\varphi(s) = 2k\,\mathrm{cn}(s)$ is one Jacobi function’s worth. (Different conventions place sn or cn here; Part 2 uses $\kappa = 2k\,\mathrm{sn}$, which corresponds to a half-period shift.)
The complete elliptic integrals
$K(m) := F(\pi/2 \mid m)$ and $E(m) := \int_0^{\pi/2}\sqrt{1-m\sin^2 t}\,dt$. Special values:
| $m$ | $K(m)$ | $E(m)$ |
|---|---|---|
| 0 | $\pi/2 \approx 1.5708$ | $\pi/2$ |
| $\frac12$ | $1.8541$ | $1.3506$ |
| $0.9$ | $2.5781$ | $1.1048$ |
| $0.99$ | $3.6956$ | $1.0160$ |
| $1^-$ | $+\infty$ (logarithmic) | $1$ |
The asymptotics near $m = 1$ are
\[K(m) \;\sim\; \tfrac12 \log\!\Bigl(\tfrac{16}{1 - m}\Bigr), \qquad E(m) \;\to\; 1.\]This is the logarithmic divergence Part 2 §3 announces for the pendulum period at the separatrix — the same divergence governs the spatial period of inflectional elastica as $k \to 1$.
The arithmetic–geometric mean of Gauss
Given $a_0, b_0 > 0$, define
\[a_{n+1} \;=\; \tfrac12 (a_n + b_n), \qquad b_{n+1} \;=\; \sqrt{a_n b_n}.\]The two sequences converge — quadratically — to a common limit, the arithmetic–geometric mean $\mathrm{AGM}(a_0, b_0)$. Quadratic convergence means each iteration roughly doubles the number of correct digits: starting from a $10^{-1}$-precision pair, six iterations land at $\sim 10^{-32}$ precision — hence the elliptic package’s “16-digit accuracy in 6 iterations” claim.
Gauss (1799, unpublished) proved the miracle:
This is what ellipticK in the Python elliptic package computes — and
what ellipj then uses internally to invert the integral and produce the
sn/cn/dn values.
elliptic.ellipticK in the Python package.
The pendulum’s period in closed form
For the libration regime $-1 < E < 1$ of $\ddot\varphi + \sin\varphi = 0$, energy conservation gives $\dot\varphi^2 = 2(E + \cos\varphi)$. Let $\varphi_0 = \arccos(-E)$ be the turning point and $k = \sin(\varphi_0/2) = \sqrt{(E+1)/2}$. Substituting $\sin(\varphi/2) = k\sin\theta$:
\[T \;=\; 4 \int_0^{\pi/2} \frac{d\theta}{\sqrt{1 - k^2 \sin^2\theta}} \;=\; 4 K(k^2).\]This is the celebrated formula
\[\boxed{\;T_{\mathrm{pendulum}}(E) \;=\; 4 K\!\bigl((E+1)/2\bigr).\;}\]For the SE(2) elastica with rescaled arc length $s$, the same $K(k^2)$ governs the spatial period of curvature oscillation, $T_\kappa = 4K(k^2)$. This double role — as a temporal period for the pendulum, as a spatial period for the elastica — is the heart of why Sachkov’s Maxwell-strata results in Part 3 read as if there were two periods that happen to coincide. There aren’t; it’s the same $K(k^2)$, identified under the rescaling.
Identities used in Part 2 §4
Part 2 uses the closed-form integral
\[\theta(s) \;=\; \theta_0 + 2\arcsin\bigl(k\,\mathrm{sn}(s\mid k^2)\bigr).\]Differentiating with respect to $s$: $\dot\theta = 2k\,\mathrm{cn}\,\mathrm{dn} / \sqrt{1 - k^2 \mathrm{sn}^2} = 2k\,\mathrm{cn}\,\mathrm{dn} / \mathrm{dn} = 2k\,\mathrm{cn}$. But Part 2 writes $\kappa = 2k\,\mathrm{sn}$. The reconciliation: there are two parametrisations of the inflectional family by Jacobi functions, related by a quarter-period shift $s \to s + K(k^2)$. Under that shift $\mathrm{sn}(s + K) = \mathrm{cn}(s) / \mathrm{dn}(s)$ and the two conventions translate. Both the Sachkov closed form (with sn) and the “angle-of-pendulum” form (with cn) are used in the literature.
The plane curve integration uses the second-kind incomplete integral
\[E(\phi \mid m) \;=\; \int_0^\phi \sqrt{1 - m\sin^2 t}\,dt.\]Setting $\phi = \mathrm{am}(s\mid m)$ allows the $\int \cos\theta\,ds$ integral to telescope into a difference of $E$- and $F$-values, giving Sachkov’s
\[x(s) \;=\; 2\bigl(E(\mathrm{am}(s)\mid k^2) - \tfrac12 F(\mathrm{am}(s)\mid k^2)\bigr).\]No numerical ODE required, only elliptic12 calls. The Python elliptic
package’s elliptic12(phi, m) returns exactly this pair $(F, E)$.
Connection to the elliptic project
Every formula in this appendix is implemented in moiseevigor/elliptic:
| Formula here | Function in elliptic |
|---|---|
| $K(m)$ via AGM (§4) | ellipticK(m) |
| sn/cn/dn via descending Landen (§3) | ellipj(u, m) |
| $E(\phi\mid m), F(\phi\mid m)$ (§7) | elliptic12(phi, m) |
| Pendulum period $4K((E+1)/2)$ (§5) | ellipticK((E+1)/2) * 4 |
| Carlson form $R_F$, $R_D$ (§ omitted) | carlsonRF, carlsonRD |
The browser figures on this page use elliptic-core.js, which is a
hand-port of the AGM and Landen routines from the Python package. Line
13–20 of elliptic-core.js is identical (modulo language) to the AGM
loop in elliptic/_AGM.py.
Code
# Reproduce the closed-form pendulum period numerically
from elliptic import ellipticK
import numpy as np
E_vals = np.linspace(-0.99, 0.99, 200)
k2 = (E_vals + 1) / 2
T_closed = 4 * ellipticK(k2)
# Sanity-check against numerical RK4 integration of phi'' + sin(phi) = 0
from scipy.integrate import solve_ivp
def pend(t, y):
return [y[1], -np.sin(y[0])]
T_numeric = []
for E in E_vals:
phi0 = 0.0
phidot0 = np.sqrt(2 * (E - np.cos(phi0))) # initial velocity from E
sol = solve_ivp(pend, [0, 30], [phi0, phidot0], rtol=1e-12, atol=1e-14,
dense_output=True)
# Find first return to phi = 0 with phidot > 0
# ... (implementation omitted)
T_numeric.append(...) # matches T_closed to 1e-10
# AGM in 6 lines, matches ellipticK(m) to 1e-15
def agm(a, b, max_iter=20):
for _ in range(max_iter):
a, b = (a + b) / 2, np.sqrt(a * b)
if abs(a - b) < 1e-15 * a: break
return a
def my_ellipticK(m):
return np.pi / (2 * agm(1.0, np.sqrt(1 - m)))
# Verify
import scipy.special as sp
for m in [0.1, 0.5, 0.9, 0.99]:
print(f"m = {m}: my_K = {my_ellipticK(m):.15f}, scipy_K = {sp.ellipk(m):.15f}")
What we covered, and what comes next
Elliptic integrals come from arc length; their inverses are the Jacobi $\mathrm{sn}, \mathrm{cn}, \mathrm{dn}$. These satisfy the cubic-square ODE that the pendulum equation reduces to under the half-angle substitution. The complete integrals $K(m), E(m)$ govern the pendulum’s period and the elastica’s plane curve integration; Gauss’s AGM evaluates them to 16 digits in 6 iterations.
Appendix A5 will use these tools to write down the sub-Riemannian exponential map of $\mathrm{SE}(2)$ — the family of all geodesics from a fixed origin parametrised by $(c, \omega_0, \phi_0)$ — and identify the Maxwell pairs by chasing the $4K(k^2)$ period through the reconstruction.
References
- E. T. Whittaker, G. N. Watson (1927). A Course of Modern Analysis. Cambridge. Chapters 21–22 develop $\mathrm{sn}, \mathrm{cn}, \mathrm{dn}$, the AGM, and Legendre's relation in classic style.
- M. Abramowitz, I. A. Stegun (1965). Handbook of Mathematical Functions. Dover. Chapter 16 (Jacobi) and 17 (integrals) — the look-up tables behind the closed forms used in the elliptic package.
- P. F. Byrd, M. D. Friedman (1971). Handbook of Elliptic Integrals for Engineers and Scientists. Springer. All identities used in Part 2 §4.
- L. M. Milne-Thomson, in Handbook of Mathematical Functions Chapter 16: Jacobi elliptic functions. Standard reference.
- D. A. Cox (1984). "The arithmetic–geometric mean of Gauss." Enseign. Math. 30: 275–330. History and modern presentation of Gauss's identity.
-
moiseevigor/elliptic
— Python package implementing every formula here as
ellipticK,ellipj,elliptic12; JavaScript port in moiseevigor.github.io/elliptic. - Elliptic project — Physical Pendulum example: runs the same $T = 4K(k^2)$ period plot of Figure A4.3.