This is a read-only demonstration of PhysicsHive on an example project. You can open every page and type in every form, but nothing is saved. How this works
PhysicsHivependulum

← Session S1 · a card of the session record

CL-S1-1

The period of the simple pendulum at amplitude \(\theta_0\) is \(T = T_0\,(1 + \theta_0^2/16 + O(\theta_0^4))\) with \(T_0 = 2\pi\sqrt{L/g}\), so \(c_2 = 1/16\).
Evidence
A derivation and a computation, each confirmed by a blind review (agent)
Draft
In the draft, as a result

Origin: agent (claude-opus-5-5), contributor dlouapre, session S1

Derivation D-S1-1

Confirmed by a blind review (agent).

Review R-S1-1 (agent) · confirmed

Summary

Reviewed D-S1-1. Verdict: confirmed. Wrote derivations/D-S1-1_R-S1-1.md.

Result

I checked the derivation with tests that have a clear outcome, and all passed. The dimensions are consistent. The limits \(\theta_0 \to 0\) and \(\theta_0 \to \pi\) behave as expected, and the result is even in \(\theta_0\), as the symmetry \(\theta \to -\theta\) requires. A sympy series of \((2/\pi)K(m=\sin^2(\theta_0/2))\) reproduces \(c_2 = 1/16\), \(c_4 = 11/3072\) and \(c_6 = 173/737280\) exactly, along with the intermediate series of eqs. (Kseries) and (k2). Direct quadrature of the time integral (eq. Tint) agrees with \(4K/\omega_0\) to 15 digits for \(\theta_0\) from 0.1 to 3.0. In the high-precision exact period, \((T/T_0 - 1)/\theta_0^2\) tends to \(0.0625\) as \(\theta_0 \to 0\), and the residual scales as \((11/3072)\theta_0^2\). A direct ODE integration of \(\ddot\theta + \sin\theta = 0\) gives the same period to about \(10^{-12}\), independently of the elliptic-integral route. The particular solution in the Poincaré–Lindstedt check (§3) and the right-hand side of eq. (PL3) are correct. The derivation's hand evaluation at \(\theta_0 = 0.1\) matches the exact value to the digits quoted. No remark weakens or breaks the claim.

Flags

  • The derivation states correctly that mpmath.ellipk and scipy.special.ellipk take the parameter \(m = k^2 = \sin^2(\theta_0/2)\), not the modulus. The numerical comparison that project.md asks for (a separate computation) should be checked for this point, because passing \(k\) instead of \(k^2\) is the most likely error there.

Tests

Check Outcome Detail
Dimensions pass \(\omega_0^{-1} = \sqrt{L/g}\) is a time; \(K\), \(k\), \(\theta_0\) and \(c_2\) are dimensionless; the mass cancels in eq. (energy).
Limit \(\theta_0 \to 0\) pass \(K(0) = \pi/2\) gives \(T = 4/\omega_0 \cdot \pi/2 = T_0\).
Limit \(\theta_0 \to \pi\) pass \(k \to 1\), \(K\) diverges logarithmically; the numerical ratio \(T/T_0\) grows from 1.33 at \(\theta_0 = 2\) to 2.57 at \(\theta_0 = 3\).
Parity symmetry pass \(T\) depends on \(\theta_0\) only through \(\sin^2(\theta_0/2)\), so it is even; only even powers appear.
Symbolic series (sympy) pass series((2/pi)*elliptic_k(sin(t/2)**2), t, 0, 8) = \(1 + \theta_0^2/16 + 11\theta_0^4/3072 + 173\theta_0^6/737280\), which matches eqs. (c2)–(c6).
Intermediate series pass \(K/(\pi/2) = 1 + m/4 + 9m^2/64 + 25m^3/256\) (eq. Kseries); \(\sin^2(\theta_0/2) = \theta_0^2/4 - \theta_0^4/48 + \theta_0^6/1440\) (eq. k2).
Wallis integral (eq. wallis) pass Checked symbolically for \(n = 0,\dots,4\).
Exact period vs. original integral pass mpmath quadrature of \(4\int_0^{\theta_0} d\theta/\sqrt{2(\cos\theta - \cos\theta_0)}\) equals \(4K(m = \sin^2(\theta_0/2))\) to 15 digits at \(\theta_0 = 0.1, 0.5, 1, 2, 3\).
Numerical extraction of \(c_2\) pass \((T/T_0 - 1)/\theta_0^2 = 0.0625358\), \(0.06250036\), \(0.0625000036\), \(0.062500000036\) at \(\theta_0 = 10^{-1}, 10^{-2}, 10^{-3}, 10^{-4}\); the excess is \((11/3072)\theta_0^2 = 3.58\times10^{-3}\theta_0^2\).
Independent ODE integration pass scipy solve_ivp (rtol \(10^{-12}\)) of \(\ddot\theta + \sin\theta = 0\): \(T/T_0 = 1.000625358308\) at \(\theta_0 = 0.1\), the same as the elliptic-integral value.
Poincaré–Lindstedt (§3) pass The order-\(A^2\) equation is \(u_3'' + u_3 = w\cos\tau + \cos^3\tau/6 = (w + 1/8)\cos\tau + \cos3\tau/24\); \(u_3 = (\cos\tau - \cos3\tau)/192\) solves it with \(w = -1/8\) and \(u_3(0) = u_3'(0) = 0\). Then \(T = T_0(1 + A^2/16)\) with \(A = \theta_0\).
Hand evaluation at \(\theta_0 = 0.1\) pass Exact: 0.0625358307737; truncated series: 0.0625358307563; the derivation's quoted value 0.06253583 matches both.

Remarks

No issue found.

Verdict

Confirmed. The claim follows from the derivation. The exact period \(T = (4/\omega_0)K(\sin(\theta_0/2))\) is derived correctly, with valid steps and a justified change of variables. Its expansion gives \(c_2 = 1/16\), and every coefficient checks against an independent symbolic series. A high-precision evaluation of the exact period and a direct integration of the equation of motion, which does not use elliptic integrals, confirm the value numerically. The Poincaré–Lindstedt check in §3 is correct and reaches the same coefficient by a separate route.

The summary of D-S1-1, by the agent who wrote it

Summary

Wrote derivations/D-S1-1.tex and derivations/D-S1-1.summary.md. Energy conservation gives the exact period as a complete elliptic integral; expanding K(k) and k = sin(θ₀/2) gives c₂ = 1/16, which an independent Poincaré–Lindstedt calculation confirms.

Result

For the simple pendulum \(\ddot\theta + \omega_0^2\sin\theta = 0\) with amplitude \(\theta_0 \in (0,\pi)\), the exact period is $\(T(\theta_0) = \frac{2T_0}{\pi}\,K\bigl(\sin(\theta_0/2)\bigr) = 4\sqrt{L/g}\;K\bigl(\sin(\theta_0/2)\bigr),\)\( with \)K\( written with the modulus \)k\(, as in `conventions.md`. Its expansion is \)\(T(\theta_0) = T_0\Bigl(1 + \tfrac{1}{16}\theta_0^2 + \tfrac{11}{3072}\theta_0^4 + O(\theta_0^6)\Bigr),\)\( so \)c_2 = 1/16\( exactly (and \)c_4 = 11/3072\(). Assumptions: point mass, massless rigid rod, no friction, uniform gravity, libration (\)\theta_0 < \pi\(), \)\theta_0$ in radians.

Flags

  • The numerical comparison with the exact period, which the goal in project.md asks for, is not done here. The only numerical check is a hand evaluation at \(\theta_0 = 0.1\) (no code was run); a /compute should do the real comparison.

Task

For the simple pendulum (point mass on a massless rigid rod of length \(L\), no friction, uniform gravity \(g\)), derive analytically the period \(T(\theta_0)\) to first non-trivial order in the amplitude: find \(c_2\) in \(T(\theta_0) = T_0(1 + c_2\theta_0^2 + O(\theta_0^4))\), \(T_0 = 2\pi\sqrt{L/g}\), as an exact number, and state the exact expression of the period if the derivation goes through one.

Key steps

  • Energy conservation gives \(\dot\theta^2 = 2\omega_0^2(\cos\theta - \cos\theta_0)\) (eq. 3). Parity and time-reversal symmetry make the period four times the quarter-period integral (eq. 4).
  • The half-angle identity with \(k = \sin(\theta_0/2)\) (eqs. 5–6) and the substitution \(\sin(\theta/2) = k\sin\phi\) (eq. 7) turn the integral into \(T = (4/\omega_0)K(k)\) (eqs. 8–9).
  • The binomial series of the integrand, integrated term by term with the Wallis integrals (eqs. 10–11), gives \(K(k) = \frac{\pi}{2}\sum_n [\binom{2n}{n}4^{-n}]^2 k^{2n}\) (eq. 12), hence \(T/T_0 = 1 + k^2/4 + 9k^4/64 + \dots\) (eq. 13).
  • Substituting \(k^2 = \theta_0^2/4 - \theta_0^4/48 + \dots\) (eq. 14) gives \(c_2 = 1/16\) (eq. 15), \(c_4 = 11/3072\) (eq. 16) and \(c_6 = 173/737280\) (eq. 17), collected in eq. 18.
  • Independent check (§3): Poincaré–Lindstedt on \(\sin\theta \approx \theta - \theta^3/6\). Removing the resonant term gives \(\omega^2 = \omega_0^2(1 - A^2/8)\), so \(T = T_0(1 + A^2/16)\) (eqs. 19–21). The amplitude \(A\) equals \(\theta_0\) because the solution has a turning point at \(\theta = A\).

Assumptions

  • The model of the brief: point mass, massless rigid rod, no friction, uniform \(g\), planar motion.
  • \(0 < \theta_0 < \pi\), so the motion is a libration, \(k = \sin(\theta_0/2) < 1\), and the integrable singularity at \(\theta = \theta_0\) is of the form \((\theta_0 - \theta)^{-1/2}\).
  • Term-by-term integration of the binomial series is justified by uniform convergence on \([0, \pi/2]\), since \(k^2 < 1\).
  • In the Poincaré–Lindstedt check, the standard assumption that the frequency and the solution have regular expansions in the amplitude.

Sanity checks

  • \(\theta_0 \to 0\): \(K(0) = \pi/2\) gives \(T \to T_0\). Passed.
  • \(\theta_0 \to \pi\): \(K \to \infty\) logarithmically, so \(T \to \infty\), as expected when the pendulum approaches the upright equilibrium. Passed.
  • Sign: \(c_2 > 0\), as expected, because \(\sin\theta < \theta\) makes the restoring force weaker than in the linear problem, so the period grows with amplitude. Passed.
  • Parity: the equation of motion is invariant under \(\theta \to -\theta\), and only even powers of \(\theta_0\) appear. Passed.
  • Dimensions: \(c_2\) is a pure number, the prefactor \(\sqrt{L/g}\) is a time, and the mass drops out. Passed.
  • Two methods (the exact period and Poincaré–Lindstedt) give the same \(c_2 = 1/16\). Passed.
  • Hand evaluation at \(\theta_0 = 0.1\): the series for \(K\), summed through \(k^8\), gives \((T/T_0 - 1)/\theta_0^2 = 0.06253583\). The truncated expansion \(1/16 + (11/3072)\theta_0^2 + (173/737280)\theta_0^4\) gives the same value to eight digits. Passed.

Computation C-S1-2

Confirmed by a blind review (agent).

Output · computations/C-S1-2.out
==============================================================================
C-S1-2  simple pendulum: second-order amplitude correction to the period
==============================================================================

## SYMBOLIC PATH

S1  dE/dt on the equation of motion simplifies to: 0
    theta'^2 = 2 \omega_{0}^{2} \left(\cos{\left(\theta \right)} - \cos{\left(\theta_{0} \right)}\right)
S2  [dtheta/dphi / sqrt(theta'^2)] / [1/(w0 sqrt(1-k^2 sin^2 phi))] simplifies to: cos(phi)/Abs(cos(phi))
    spot values of that ratio at 6 random (k, phi, w0): ['1.0', '1.0', '1.0', '1.0', '1.0', '1.0']
    => T = (4/omega_0) K(k), k = sin(theta_0/2);  T/T0 = (2/pi) K(sin(theta_0/2))

S3  K as a series in the parameter m = k^2 (term-by-term integration):
    K = \frac{1225 \pi m^{4}}{32768} + \frac{25 \pi m^{3}}{512} + \frac{9 \pi m^{2}}{128} + \frac{\pi m}{8} + \frac{\pi}{2} + O(m^5)
    difference with sympy.elliptic_k(m).series (parameter m): 0
    difference with pi/2 * sum [binom(2n,n)/4^n]^2 m^n: 0

S4  T/T0 = \frac{22931 \theta_{0}^{8}}{1321205760} + \frac{173 \theta_{0}^{6}}{737280} + \frac{11 \theta_{0}^{4}}{3072} + \frac{\theta_{0}^{2}}{16} + 1 + O(theta_0^10)
    c0 = 1,  c2 = 1/16,  c4 = 11/3072,  c6 = 173/737280,  c8 = 22931/1321205760
    LaTeX: c_2 = \frac{1}{16} , c_4 = \frac{11}{3072} , c_6 = \frac{173}{737280} , c_8 = \frac{22931}{1321205760}
    cross-check, series of (2/pi) elliptic_k(sin^2(theta0/2)) directly to theta0^6: \frac{173 \theta_{0}^{6}}{737280} + \frac{11 \theta_{0}^{4}}{3072} + \frac{\theta_{0}^{2}}{16} + 1

S5  Lindstedt-Poincare from the equation of motion (no elliptic integral):
    order eps^3: secular condition gives a2 = -1/8
    order eps^5: secular condition gives a4 = 7/1536
    order eps^7: secular condition gives a6 = -19/184320
    T/T0 = Omega^(-1/2) = \frac{173 \theta_{0}^{6}}{737280} + \frac{11 \theta_{0}^{4}}{3072} + \frac{\theta_{0}^{2}}{16} + 1 + O(theta_0^8)
    difference with the elliptic-integral series (through theta0^6): 0
    Lindstedt-Poincare: c2 = 1/16, c4 = 11/3072

## NUMERICAL PATH

N1  T/T0 at each amplitude: mpmath (40 digits) as reference; differences of the other routes
    relative error of the second-order formula = [T0(1 + theta0^2/16) - T]/T
 theta0            T/T0 mpmath   scipy-mp     AGM-mp  ODE(1/4)-mp  ODE(1/2)-mp  2nd-order relerr   resid/th^4
  0.010    1.00000625003580753    0.0e+00    0.0e+00      5.3e-15      4.7e-15     -3.580736e-11   0.00358075
  0.020    1.00002500057293168    2.2e-16    2.2e-16      7.1e-15      5.1e-15     -5.729174e-10   0.00358082
  0.050    1.00015627238322432    0.0e+00    0.0e+00      4.4e-15      7.3e-15     -2.237973e-08   0.00358132
  0.100    1.00062535830773663    0.0e+00    0.0e+00      3.1e-15      6.2e-15     -3.580838e-07   0.00358308
  0.200    1.00250574422860192    0.0e+00    0.0e+00      8.9e-16      7.3e-15     -5.729871e-06   0.00359014
  0.300    1.00565417611036461    0.0e+00    0.0e+00      2.9e-15      1.3e-14     -2.901207e-05   0.00360199
  0.500    1.01585253110143671   -2.2e-16    0.0e+00      1.1e-15      1.6e-15     -2.239804e-04   0.00364050
  0.750    1.03633279661752203    0.0e+00    2.2e-16      1.8e-15      1.3e-15     -1.135298e-03   0.00371847
  1.000    1.06633424557996305   -2.2e-16    0.0e+00      3.3e-15      1.8e-15     -3.595726e-03   0.00383425
  1.500    1.16196874438667244    0.0e+00    0.0e+00      1.3e-14      6.7e-15     -1.836860e-02   0.00421605
  2.000    1.32890445191509954    0.0e+00   -4.4e-16      1.3e-14      7.3e-15     -5.937556e-02   0.00493153
  2.500    1.64298239844576622   -4.4e-16   -4.4e-16      1.3e-14     -1.6e-14     -1.535971e-01   0.00646035
  3.000    2.57123394943214205   -1.3e-15    4.4e-16      5.8e-15     -9.4e-13     -3.923151e-01   0.01245351

    table written to computations/C-S1-2.periods.csv

N2  log-log slope of the residual vs theta0 on [0.01, 0.3]: 4.001437 (expect 4)
    residual/theta0^4 -> 0.0035807526 at theta0 = 0.01; c4 = 11/3072 = 0.0035807292
    same slope from the ODE data alone: 4.001404

N3  c2 extracted from numerical data alone
     theta0   (T/T0-1)/th^2 [mpmath]    (T/T0-1)/th^2 [ODE]
      0.010           0.062500358075         0.062500358129
      0.020           0.062501432329         0.062501432347
      0.050           0.062508953290         0.062508953291
      0.100           0.062535830774         0.062535830774
      0.200           0.062643605715         0.062643605715
      0.300           0.062824179004         0.062824179004
    fit c2 + c4 th^2 + c6 th^4 on theta0 in [0.05, 0.5] (5 points):
      ODE data   : c2 = 0.062500003309, c4 = 0.00358032, c6 = 0.000241
      mpmath data: c2 = 0.062500003308, c4 = 0.00358032, c6 = 0.000241
      exact      : c2 = 0.062500000000, c4 = 0.00358073, c6 = 0.000235
    Richardson from ODE at theta0 = 0.05, 0.1: c2 = 0.062499994131 (|err| = 5.9e-09)

N4  truncated symbolic series vs mpmath exact, relative error
    theta0 =  0.1: order 2 -3.581e-07   order 4 -2.347e-10   order 8 -1.387e-16
    theta0 =  0.5: order 2 -2.240e-04   order 4 -3.677e-06   order 8 -1.362e-09
    theta0 =  1.0: order 2 -3.596e-03   order 4 -2.377e-04   order 8 -1.420e-06
    theta0 =  2.0: order 2 -5.938e-02   order 4 -1.626e-02   order 8 -1.620e-03

Limits
    theta0 -> 0: T/T0 (mpmath, theta0 = 1e-8) - 1 = 6.25e-18  (expect theta0^2/16 = 6.250e-18)
    theta0 = 3.1: T/T0 = 3.348496446, (2/pi) ln(4/cos(theta0/2)) = 3.348203238
    theta0 = 3.14: T/T0 = 5.425144192, (2/pi) ln(4/cos(theta0/2)) = 5.425143433
    theta0 = 3.1415: T/T0 = 7.235874068, (2/pi) ln(4/cos(theta0/2)) = 7.235874065

SUMMARY
    symbolic (elliptic series):   c2 = 1/16, c4 = 11/3072, c6 = 173/737280, c8 = 22931/1321205760
    symbolic (Lindstedt-Poincare): c2 = 1/16, c4 = 11/3072
    numerical (ODE fit)          : c2 = 0.062500003309, c4 = 0.00358032
    max |ODE - mpmath| over all amplitudes: 1.31e-14
    max |scipy - mpmath|: 1.33e-15
Code · computations/C-S1-2.py
"""C-S1-2: independent check of the second-order period correction of the simple pendulum.

Target: T(theta0) = T0 (1 + c2 theta0^2 + c4 theta0^4 + ...), T0 = 2 pi sqrt(L/g); is c2 = 1/16?

Conventions (conventions.md): EOM  theta'' + omega0^2 sin(theta) = 0, omega0 = sqrt(g/L),
theta0 = maximum angle; K(k) written with the MODULUS k.
Library conventions used below:
  - sympy.elliptic_k(m)      : PARAMETER m = k^2
  - scipy.special.ellipk(m)  : PARAMETER m = k^2
  - mpmath.ellipk(m)         : PARAMETER m = k^2
  - the AGM route below       : takes k' = sqrt(1 - k^2), K(k) = pi / (2 AGM(1, k'))
All periods are reported as the dimensionless ratio T/T0 (equivalently omega0 = 1, T0 = 2 pi).

Run from the workspace root:
  uv run --with sympy --with numpy --with scipy python computations/C-S1-2.py
"""

from pathlib import Path
import csv

import numpy as np
import sympy as sp
import mpmath as mp
from scipy.special import ellipk
from scipy.integrate import solve_ivp

HERE = Path(__file__).resolve().parent
OUT_CSV = HERE / "C-S1-2.periods.csv"

mp.mp.dps = 40
rng = np.random.default_rng(12345)

print("=" * 78)
print("C-S1-2  simple pendulum: second-order amplitude correction to the period")
print("=" * 78)

# ---------------------------------------------------------------------------
# SYMBOLIC PATH
# ---------------------------------------------------------------------------
print("\n## SYMBOLIC PATH\n")

th, th0, phi, k, w0, t = sp.symbols("theta theta_0 phi k omega_0 t", positive=True)
m = sp.symbols("m", positive=True)

# S1. Energy integral from the EOM.
# Multiply theta'' + w0^2 sin(theta) = 0 by theta' and integrate:
#   theta'^2/2 - w0^2 cos(theta) = const = -w0^2 cos(theta0)  (theta' = 0 at theta = theta0)
thetadot_sq = 2 * w0**2 * (sp.cos(th) - sp.cos(th0))
# Check: d/dt of the energy vanishes on the EOM.
thf = sp.Function("theta")(t)
E = sp.Rational(1, 2) * thf.diff(t) ** 2 - w0**2 * sp.cos(thf)
dE = sp.diff(E, t).subs(thf.diff(t, 2), -w0**2 * sp.sin(thf))
print("S1  dE/dt on the equation of motion simplifies to:", sp.simplify(dE))
print("    theta'^2 =", sp.latex(thetadot_sq))
# By symmetry of the motion, T = 4 * int_0^theta0 dtheta / sqrt(theta'^2).

# S2. Substitution sin(theta/2) = k sin(phi), k = sin(theta0/2), maps the quarter-period
# integral onto int_0^{pi/2} dphi / sqrt(1 - k^2 sin^2 phi) / w0.
theta_of_phi = 2 * sp.asin(k * sp.sin(phi))
cos_th0 = 1 - 2 * k**2  # cos(theta0) with k = sin(theta0/2)
integrand_theta = 1 / sp.sqrt(2 * w0**2 * (sp.cos(theta_of_phi) - cos_th0))
jac = sp.diff(theta_of_phi, phi)
integrand_phi = integrand_theta * jac
target_phi = 1 / (w0 * sp.sqrt(1 - k**2 * sp.sin(phi) ** 2))
ratio = sp.simplify(sp.trigsimp(integrand_phi / target_phi))
print("S2  [dtheta/dphi / sqrt(theta'^2)] / [1/(w0 sqrt(1-k^2 sin^2 phi))] simplifies to:", ratio)
# Numerical spot check of the same identity, in case simplify is fragile.
f_chk = sp.lambdify((k, phi, w0), integrand_phi / target_phi, "mpmath")
spot = [f_chk(mp.mpf(kk), mp.mpf(pp), mp.mpf(ww))
        for kk, pp, ww in zip(rng.uniform(0.05, 0.99, 6), rng.uniform(0.01, 1.55, 6), rng.uniform(0.3, 3, 6))]
print("    spot values of that ratio at 6 random (k, phi, w0):", [mp.nstr(s, 18) for s in spot])
print("    => T = (4/omega_0) K(k), k = sin(theta_0/2);  T/T0 = (2/pi) K(sin(theta_0/2))")

# S3. Series of K in the parameter m = k^2, by term-by-term integration of the integrand.
NMAX = 5  # keep m^0..m^4  -> theta0^8 accuracy
s = sp.symbols("s")
binom_series = sp.series((1 - m * s) ** sp.Rational(-1, 2), m, 0, NMAX).removeO()
K_series_m = 0
for n in range(NMAX):
    coeff = binom_series.coeff(m, n)  # polynomial in s = sin^2 phi
    term = sp.integrate(coeff.subs(s, sp.sin(phi) ** 2), (phi, 0, sp.pi / 2))
    K_series_m += sp.simplify(term) * m**n
K_series_m = sp.expand(K_series_m)
print("\nS3  K as a series in the parameter m = k^2 (term-by-term integration):")
print("    K =", sp.latex(K_series_m), "+ O(m^5)")
# Cross-check against SymPy's own elliptic_k (which takes the parameter m).
K_sympy = sp.series(sp.elliptic_k(m), m, 0, NMAX).removeO()
print("    difference with sympy.elliptic_k(m).series (parameter m):", sp.simplify(K_series_m - K_sympy))
# Closed-form coefficients: pi/2 * [binom(2n,n)/4^n]^2
closed = sum(sp.pi / 2 * (sp.binomial(2 * n, n) / 4**n) ** 2 * m**n for n in range(NMAX))
print("    difference with pi/2 * sum [binom(2n,n)/4^n]^2 m^n:", sp.simplify(K_series_m - closed))

# S4. T/T0 = (2/pi) K(m = sin^2(theta0/2)), expanded in theta0.
ORDER = 10  # through theta0^8
TT0_expr = (2 / sp.pi) * K_series_m.subs(m, sp.sin(th0 / 2) ** 2)
TT0_series = sp.series(TT0_expr, th0, 0, ORDER).removeO()
TT0_series = sp.expand(TT0_series)
c = {j: sp.nsimplify(TT0_series.coeff(th0, j)) for j in range(0, ORDER, 1)}
print("\nS4  T/T0 =", sp.latex(TT0_series), "+ O(theta_0^10)")
for j in (1, 3, 5, 7):
    assert c[j] == 0, f"odd coefficient c{j} nonzero"
c2_sym, c4_sym, c6_sym, c8_sym = c[2], c[4], c[6], c[8]
print(f"    c0 = {c[0]},  c2 = {c2_sym},  c4 = {c4_sym},  c6 = {c6_sym},  c8 = {c8_sym}")
print("    LaTeX: c_2 =", sp.latex(c2_sym), ", c_4 =", sp.latex(c4_sym),
      ", c_6 =", sp.latex(c6_sym), ", c_8 =", sp.latex(c8_sym))
# Check that truncating the m-series at m^4 does not affect theta0^8: m^5 ~ theta0^10.
TT0_direct = sp.series((2 / sp.pi) * sp.elliptic_k(sp.sin(th0 / 2) ** 2), th0, 0, 8).removeO()
print("    cross-check, series of (2/pi) elliptic_k(sin^2(theta0/2)) directly to theta0^6:",
      sp.latex(sp.expand(TT0_direct)))

# S5. Independent symbolic route that never uses an elliptic integral:
# Lindstedt-Poincare on the EOM with omega0 = 1, tau = omega t, initial data theta(0) = eps,
# theta'(0) = 0, so the maximum angle is exactly eps = theta0.
#   Omega theta_tau'' + sin(theta) = 0,  Omega = omega^2 = 1 + a2 eps^2 + a4 eps^4 + a6 eps^6
#   theta = eps cos tau + eps^3 y3 + eps^5 y5 + eps^7 y7
# Each y_j is a trig polynomial in cos(n tau); we represent it as a Laurent polynomial in
# z = exp(i tau) (cos n tau = (z^n + z^-n)/2, d^2/dtau^2 -> multiply z^n by -n^2).
print("\nS5  Lindstedt-Poincare from the equation of motion (no elliptic integral):")
z, eps = sp.symbols("z epsilon")
a2, a4, a6 = sp.symbols("a2 a4 a6")


def d2(expr):
    """Second tau-derivative of a Laurent polynomial in z = exp(i tau)."""
    expr = sp.expand(expr)
    return sp.expand(sum(-(n**2) * expr.coeff(z, n) * z**n for n in range(-15, 16)))


def solve_forced(f):
    """Solve y'' + y = -f for y even in tau with y(0) = 0; f must have no z^{+-1} term."""
    f = sp.expand(f)
    y = 0
    for n in range(-15, 16):
        cn = f.coeff(z, n)
        if cn == 0:
            continue
        assert abs(n) != 1, "secular term left in forcing"
        y += -cn / (1 - n**2) * z**n
    # add C cos tau so that y(tau=0) = y(z=1) = 0
    C = -y.subs(z, 1)
    return sp.expand(y + C * (z + 1 / z) / 2)


cos_tau = (z + 1 / z) / 2
Omega = 1 + a2 * eps**2 + a4 * eps**4 + a6 * eps**6
ys = {1: cos_tau}
sol_a = {}
for order in (3, 5, 7):
    theta_trunc = sum(eps**j * ys[j] for j in ys)
    y_new = sp.Symbol("Y")
    # residual of the EOM at this order, with the unknown y_order entering as y'' + y
    sin_series = sum((-1) ** q * theta_trunc ** (2 * q + 1) / sp.factorial(2 * q + 1) for q in range(4))
    res = sp.expand(Omega.subs(sol_a) * d2(theta_trunc) + sin_series)
    f = sp.expand(res.coeff(eps, order))
    # the y_order contribution at eps^order is (y'' + y), so y'' + y = -f
    a_unknown = {3: a2, 5: a4, 7: a6}[order]
    secular = sp.expand(f.coeff(z, 1))
    a_val = sp.solve(secular, a_unknown)[0]
    sol_a[a_unknown] = a_val
    f = sp.expand(f.subs(a_unknown, a_val))
    assert sp.simplify(f.coeff(z, 1)) == 0 and sp.simplify(f.coeff(z, -1)) == 0
    ys[order] = solve_forced(f)
    print(f"    order eps^{order}: secular condition gives {a_unknown} = {a_val}")
Omega_sol = Omega.subs(sol_a)
TT0_LP = sp.expand(sp.series(Omega_sol ** sp.Rational(-1, 2), eps, 0, 8).removeO())
print("    T/T0 = Omega^(-1/2) =", sp.latex(TT0_LP.subs(eps, th0)), "+ O(theta_0^8)")
print("    difference with the elliptic-integral series (through theta0^6):",
      sp.simplify(TT0_LP.subs(eps, th0) - sum(c[j] * th0**j for j in range(0, 7))))
c2_LP = TT0_LP.coeff(eps, 2)
c4_LP = TT0_LP.coeff(eps, 4)
print(f"    Lindstedt-Poincare: c2 = {c2_LP}, c4 = {c4_LP}")

# ---------------------------------------------------------------------------
# NUMERICAL PATH
# ---------------------------------------------------------------------------
print("\n## NUMERICAL PATH\n")
c2n, c4n = float(c2_sym), float(c4_sym)
amps = np.array([0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0])


def tt0_scipy(a):
    # scipy.special.ellipk takes the PARAMETER m = k^2
    return 2 / np.pi * ellipk(np.sin(a / 2) ** 2)


def tt0_mpmath(a):
    # mpmath.ellipk takes the PARAMETER m = k^2; 40 significant digits
    a = mp.mpf(a)
    return 2 / mp.pi * mp.ellipk(mp.sin(a / 2) ** 2)


def tt0_agm(a):
    # Pure NumPy arithmetic-geometric mean; K(k) = pi / (2 AGM(1, k')), k' = sqrt(1-k^2) = cos(a/2)
    x, y = 1.0, np.cos(a / 2)
    for _ in range(60):
        x, y = (x + y) / 2, np.sqrt(x * y)
    return 2 / np.pi * (np.pi / (2 * x))


def tt0_ode(a):
    """Direct integration of theta'' + sin(theta) = 0 (omega0 = 1), no elliptic function.

    Rescaled u = theta/theta0: u'' = -sin(theta0 u)/theta0, u(0) = 1, u'(0) = 0, so the tolerances
    are uniform in the amplitude. The first zero crossing of u (downwards) is a quarter period.
    """
    def rhs(_t, y):
        return [y[1], -np.sin(a * y[0]) / a]

    def hit_zero(_t, y):
        return y[0]
    hit_zero.terminal = True
    hit_zero.direction = -1
    sol = solve_ivp(rhs, (0.0, 50.0), [1.0, 0.0], method="DOP853",
                    rtol=1e-13, atol=1e-15, events=hit_zero, dense_output=False)
    tq = sol.t_events[0][0]
    # Also check the half period by symmetry: integrate on and locate u' = 0 (u = -1 turning point)

    def hit_turn(_t, y):
        return y[1]
    hit_turn.terminal = True
    hit_turn.direction = 1
    sol2 = solve_ivp(rhs, (0.0, 100.0), [1.0, 0.0], method="DOP853",
                     rtol=1e-13, atol=1e-15, events=hit_turn, first_step=1e-3)
    th_ = sol2.t_events[0]
    th_ = th_[th_ > 1e-6][0]
    T_q, T_h = 4 * tq, 2 * th_
    return T_q / (2 * np.pi), T_h / (2 * np.pi), sol2.y_events[0][-1][0]


rows = []
hdr = (f"{'theta0':>7} {'T/T0 mpmath':>22} {'scipy-mp':>10} {'AGM-mp':>10} {'ODE(1/4)-mp':>12} "
       f"{'ODE(1/2)-mp':>12} {'2nd-order relerr':>17} {'resid/th^4':>12}")
print("N1  T/T0 at each amplitude: mpmath (40 digits) as reference; differences of the other routes")
print("    relative error of the second-order formula = [T0(1 + theta0^2/16) - T]/T")
print(hdr)
for a in amps:
    ref = tt0_mpmath(a)
    ref_f = float(ref)
    sc = float(tt0_scipy(a))
    ag = float(tt0_agm(a))
    ode_q, ode_h, u_turn = tt0_ode(a)
    second = 1 + c2n * a**2
    relerr = (second - ref_f) / ref_f
    resid = ref - 1 - mp.mpf(c2n) * mp.mpf(a) ** 2  # high-precision residual
    resid_f = float(resid)
    rows.append(dict(theta0_rad=a, T_over_T0_mpmath=mp.nstr(ref, 20), T_over_T0_scipy=sc,
                     T_over_T0_agm=ag, T_over_T0_ode_quarter=ode_q, T_over_T0_ode_half=ode_h,
                     T_over_T0_second_order=second, relerr_second_order=relerr,
                     residual=resid_f, residual_over_theta0_4=resid_f / a**4,
                     ode_minus_mpmath=ode_q - ref_f))
    print(f"{a:7.3f} {mp.nstr(ref, 18):>22} {sc - ref_f:10.1e} {ag - ref_f:10.1e} {ode_q - ref_f:12.1e} "
          f"{ode_h - ref_f:12.1e} {relerr:17.6e} {resid_f / a**4:12.8f}")

with open(OUT_CSV, "w", newline="") as fh:
    w = csv.DictWriter(fh, fieldnames=list(rows[0].keys()))
    w.writeheader()
    for r in rows:
        w.writerow(r)
print(f"\n    table written to {OUT_CSV.relative_to(HERE.parent)}")

# N2. Scaling of the residual T/T0 - 1 - theta0^2/16 at small amplitude
small = amps[amps <= 0.3]
res_small = np.array([r["residual"] for r in rows if r["theta0_rad"] <= 0.3])
slope, icpt = np.polyfit(np.log(small), np.log(res_small), 1)
print(f"\nN2  log-log slope of the residual vs theta0 on [{small[0]}, {small[-1]}]: {slope:.6f} (expect 4)")
print(f"    residual/theta0^4 -> {res_small[0] / small[0]**4:.10f} at theta0 = {small[0]}; "
      f"c4 = 11/3072 = {c4n:.10f}")
# same with the ODE data alone (no elliptic function)
ode_small = np.array([r["T_over_T0_ode_quarter"] for r in rows if r["theta0_rad"] <= 0.3])
res_ode = ode_small - 1 - small**2 / 16
okm = res_ode > 0
slope_ode = np.polyfit(np.log(small[okm]), np.log(res_ode[okm]), 1)[0]
print(f"    same slope from the ODE data alone: {slope_ode:.6f}")

# N3. c2 from the numerical data alone
print("\nN3  c2 extracted from numerical data alone")
print(f"    {'theta0':>7} {'(T/T0-1)/th^2 [mpmath]':>24} {'(T/T0-1)/th^2 [ODE]':>22}")
for r in rows:
    if r["theta0_rad"] <= 0.3:
        a = r["theta0_rad"]
        q_mp = (float(mp.mpf(r["T_over_T0_mpmath"]) - 1)) / a**2
        q_ode = (r["T_over_T0_ode_quarter"] - 1) / a**2
        print(f"    {a:7.3f} {q_mp:24.12f} {q_ode:22.12f}")
# Least-squares fit (T/T0 - 1)/theta0^2 = c2 + c4 th^2 + c6 th^4 on theta0 in [0.05, 0.5], ODE data only
sel = (amps >= 0.05) & (amps <= 0.5)
x = amps[sel] ** 2
yode = (np.array([r["T_over_T0_ode_quarter"] for r in rows])[sel] - 1) / x
A = np.vstack([np.ones_like(x), x, x**2]).T
coef_ode, *_ = np.linalg.lstsq(A, yode, rcond=None)
ymp = (np.array([float(mp.mpf(r["T_over_T0_mpmath"])) for r in rows])[sel] - 1) / x
coef_mp, *_ = np.linalg.lstsq(A, ymp, rcond=None)
print(f"    fit c2 + c4 th^2 + c6 th^4 on theta0 in [0.05, 0.5] ({sel.sum()} points):")
print(f"      ODE data   : c2 = {coef_ode[0]:.12f}, c4 = {coef_ode[1]:.8f}, c6 = {coef_ode[2]:.6f}")
print(f"      mpmath data: c2 = {coef_mp[0]:.12f}, c4 = {coef_mp[1]:.8f}, c6 = {coef_mp[2]:.6f}")
print(f"      exact      : c2 = {c2n:.12f}, c4 = {c4n:.8f}, c6 = {float(c6_sym):.6f}")
# Richardson on two smallest-but-not-too-small ODE points (removes the c4 term)
a1, a2_ = 0.05, 0.1
q1 = (rows[list(amps).index(a1)]["T_over_T0_ode_quarter"] - 1) / a1**2
q2 = (rows[list(amps).index(a2_)]["T_over_T0_ode_quarter"] - 1) / a2_**2
c2_rich = (q1 * a2_**2 - q2 * a1**2) / (a2_**2 - a1**2)
print(f"    Richardson from ODE at theta0 = {a1}, {a2_}: c2 = {c2_rich:.12f} (|err| = {abs(c2_rich - c2n):.1e})")

# N4. Truncated series vs exact (checks the symbolic coefficients numerically)
print("\nN4  truncated symbolic series vs mpmath exact, relative error")
ser_f = sp.lambdify(th0, TT0_series, "mpmath")
for a in (0.1, 0.5, 1.0, 2.0):
    ex = tt0_mpmath(a)
    s2 = 1 + mp.mpf(1) / 16 * mp.mpf(a) ** 2
    s4 = s2 + mp.mpf(11) / 3072 * mp.mpf(a) ** 4
    s8 = ser_f(mp.mpf(a))
    print(f"    theta0 = {a:4.1f}: order 2 {float((s2 - ex) / ex):10.3e}   order 4 {float((s4 - ex) / ex):10.3e}"
          f"   order 8 {float((s8 - ex) / ex):10.3e}")

# Limits
print("\nLimits")
print(f"    theta0 -> 0: T/T0 (mpmath, theta0 = 1e-8) - 1 = {mp.nstr(tt0_mpmath(1e-8) - 1, 6)}"
      f"  (expect theta0^2/16 = {1e-16 / 16:.3e})")
for a in (3.1, 3.14, 3.1415):
    ex = tt0_mpmath(a)
    # near the separatrix K(k) ~ ln(4/k'), k' = cos(theta0/2)
    approx = 2 / mp.pi * mp.log(4 / mp.cos(mp.mpf(a) / 2))
    print(f"    theta0 = {a}: T/T0 = {mp.nstr(ex, 10)}, (2/pi) ln(4/cos(theta0/2)) = {mp.nstr(approx, 10)}")

print("\nSUMMARY")
print(f"    symbolic (elliptic series):   c2 = {c2_sym}, c4 = {c4_sym}, c6 = {c6_sym}, c8 = {c8_sym}")
print(f"    symbolic (Lindstedt-Poincare): c2 = {c2_LP}, c4 = {c4_LP}")
print(f"    numerical (ODE fit)          : c2 = {coef_ode[0]:.12f}, c4 = {coef_ode[1]:.8f}")
print(f"    max |ODE - mpmath| over all amplitudes: {max(abs(r['ode_minus_mpmath']) for r in rows):.2e}")
print(f"    max |scipy - mpmath|: {max(abs(r['T_over_T0_scipy'] - float(mp.mpf(r['T_over_T0_mpmath']))) for r in rows):.2e}")
Data · computations/C-S1-2.periods.csv
theta0_rad,T_over_T0_mpmath,T_over_T0_scipy,T_over_T0_agm,T_over_T0_ode_quarter,T_over_T0_ode_half,T_over_T0_second_order,relerr_second_order,residual,residual_over_theta0_4,ode_minus_mpmath
0.01,1.0000062500358075263,1.0000062500358076,1.0000062500358076,1.000006250035813,1.0000062500358122,1.00000625,-3.580735532677236e-11,3.5807526314669654e-11,0.0035807526314669655,5.329070518200751e-15
0.02,1.0000250005729316845,1.0000250005729319,1.0000250005729319,1.0000250005729387,1.0000250005729368,1.000025,-5.729173788181238e-10,5.729316844721086e-10,0.0035808230279506786,7.105427357601002e-15
0.05,1.0001562723832243177,1.0001562723832242,1.0001562723832242,1.0001562723832287,1.0001562723832316,1.00015625,-2.2379726829788575e-08,2.2383224317702912e-08,0.0035813158908324654,4.440892098500626e-15
0.1,1.000625358307736634,1.0006253583077367,1.0006253583077367,1.0006253583077398,1.000625358307743,1.000625,-3.58083805909176e-07,3.583077366339772e-07,0.003583077366339771,3.1086244689504383e-15
0.2,1.0025057442286019164,1.0025057442286018,1.0025057442286018,1.0025057442286027,1.0025057442286092,1.0025,-5.729871010673761e-06,5.74422860191614e-06,0.003590142876197587,8.881784197001252e-16
0.3,1.0056541761103646063,1.0056541761103646,1.0056541761103646,1.0056541761103674,1.0056541761103774,1.005625,-2.9012071005777395e-05,2.9176110364606705e-05,0.0036019889339020624,2.886579864025407e-15
0.5,1.015852531101436711,1.0158525311014366,1.0158525311014368,1.015852531101438,1.0158525311014384,1.015625,-0.00022398044447465828,0.00022753110143671103,0.0036404976229873764,1.1102230246251565e-15
0.75,1.0363327966175220313,1.036332796617522,1.0363327966175222,1.0363327966175238,1.0363327966175233,1.03515625,-0.0011352980638672243,0.0011765466175220312,0.0037184683220449384,1.7763568394002505e-15
1.0,1.0663342455799630457,1.066334245579963,1.0663342455799631,1.0663342455799665,1.066334245579965,1.0625,-0.003595725820357348,0.0038342455799630455,0.0038342455799630455,3.3306690738754696e-15
1.5,1.16196874438667244,1.1619687443866724,1.1619687443866724,1.161968744386685,1.161968744386679,1.140625,-0.018368604568566416,0.02134374438667244,0.004216048273910605,1.2656542480726785e-14
2.0,1.3289044519150995439,1.3289044519150996,1.3289044519150992,1.3289044519151127,1.328904451915107,1.25,-0.059375564436848355,0.07890445191509954,0.004931528244693721,1.3100631690576847e-14
2.5,1.6429823984457662167,1.6429823984457659,1.6429823984457659,1.642982398445779,1.6429823984457503,1.390625,-0.15359714059291943,0.2523573984457662,0.006460349400211615,1.2656542480726785e-14
3.0,2.5712339494321420493,2.571233949432141,2.5712339494321426,2.571233949432148,2.5712339494312046,1.5625,-0.3923151176713894,1.0087339494321421,0.012453505548544965,5.773159728050814e-15
Review R-S1-1 (agent) · confirmed

Summary

Reviewed C-S1-2. Verdict: confirmed. Wrote computations/C-S1-2_R-S1-1.md.

Result

I re-ran the script from a copy outside the workspace. It reproduces C-S1-2.out line for line and C-S1-2.periods.csv byte for byte. I then checked \(c_2 = 1/16\) by routes that the script does not use, and all of them pass. The first expands \((2/\pi)K\) as the hypergeometric series \({}_2F_1(\tfrac12,\tfrac12;1;\sin^2(\theta_0/2))\); it gives \(1/16\), \(11/3072\), \(173/737280\), \(22931/1321205760\) and \(1319183/951268147200\), the standard values through \(\theta_0^{10}\). The second expands the period integral \(4\int_0^{\theta_0}d\theta/\sqrt{2(\cos\theta-\cos\theta_0)}\) directly, with no elliptic function; it gives \(1/16\), \(11/3072\) and \(173/737280\). The third is a 50-digit tanh-sinh quadrature of that same integral at the 13 amplitudes, which matches the CSV's mpmath column to within \(5\times10^{-20}\), the precision of the stored strings. The fourth is an implicit Radau ODE integration in the original variable \(\theta\), which matches to within \(2.7\times10^{-15}\). A 3-point Richardson fit on quadrature data at 0.001, 0.002 and 0.004 rad gives \(c_2 = 0.0625000000000000000\) to 20 digits and \(c_4 = 0.00358072916667 = 11/3072\). I also recomputed the CSV's derived columns (relative error of the second-order formula, residual\(/\theta_0^4\)) independently, and they agree. The checks of dimensions, evenness in \(\theta_0\), the \(\theta_0\to0\) limit and the \(\theta_0\to\pi\) logarithmic limit all pass. I found no remark that weakens or breaks the result. The only remark is cosmetic: a stale flag in the artefact about the letter \(m\).

Flags

  • The artefact's flag (C-S1-2.md, line 19) says that conventions.md uses \(m\) for both the mass and the elliptic parameter. The current conventions.md writes the mass as \(M\) and keeps \(m\) for the parameter \(m=k^2\), so this flag no longer applies and needs no action.

Tests

Check Outcome Detail
Re-run of C-S1-2.py (scratch copy) pass Runs in about 1 s. The output is identical to C-S1-2.out except for the printed relative path of the CSV, and the CSV is byte-identical.
Dimensions pass \(T_0 = 2\pi\sqrt{L/g}\) is a time; \(c_2\) and \(\theta_0\) (rad) are dimensionless. An ODE run in physical units (\(L=2\), \(g=9.81\), \(\ddot\theta = -(g/L)\sin\theta\)) gives \(T/(2\pi\sqrt{L/g}) = 1.066334245579964\) at \(\theta_0=1\), equal to the CSV value \(1.0663342455799630\). The mass does not enter.
Symmetry \(\theta_0\to-\theta_0\) pass All odd coefficients vanish symbolically, both in the script and in my hypergeometric series. Radau gives \(T(+1)/T_0 = 1.0663342455799634\) and \(T(-1)/T_0 = 1.0663342455799625\).
Limit \(\theta_0\to0\) pass \(T\to T_0\), and \(T/T_0 - 1 = 6.25\times10^{-18}\) at \(\theta_0 = 10^{-8}\) (script output), which is \(\theta_0^2/16\).
Limit \(\theta_0\to\pi\) pass \(T/T_0 \to (2/\pi)\ln(4/\cos(\theta_0/2))\): \(7.235874068\) against \(7.235874065\) at 3.1415 rad (script output, consistent with \(K(k)\sim\ln(4/k')\)).
\(c_2\), \(c_4\) from \({}_2F_1(\tfrac12,\tfrac12;1;\sin^2(\theta_0/2))\) (independent SymPy expansion) pass Gives \(1, 0, 1/16, 0, 11/3072, 0, 173/737280, 0, 22931/1321205760, 0, 1319183/951268147200\). These match the standard pendulum series through \(\theta_0^{10}\) and the artefact through \(\theta_0^8\).
\(c_2\) from the period integral, no elliptic function pass I substituted \(\theta = \theta_0\sin\psi\), expanded the integrand in \(\theta_0\) as a polynomial in \(\sin\psi\) and integrated with Wallis' formula. This gives \(c_0=1\), \(c_2=1/16\), \(c_4=11/3072\) and \(c_6=173/737280\).
Lindstedt–Poincaré coefficients (hand check of S5) pass \(\Omega = 1 - \theta_0^2/8 + 7\theta_0^4/1536 + \dots\) gives \(\Omega^{-1/2} = 1 + \theta_0^2/16 + (3/512 - 7/3072)\theta_0^4 = 1 + \theta_0^2/16 + 11\theta_0^4/3072\).
Exact \(T/T_0\) by 50-digit quadrature against the CSV mpmath column (13 amplitudes) pass The integrand is in product form to avoid cancellation. The largest difference is \(4.7\times10^{-20}\), at the 20-digit precision of the stored strings.
Exact \(T/T_0\) by Radau ODE in \(\theta\) (rtol \(10^{-12}\)) against the CSV pass The largest difference is \(2.7\times10^{-15}\), at 3 rad.
CSV derived columns recomputed pass relerr_second_order agrees exactly. residual_over_theta0_4 agrees to within \(2\times10^{-18}\).
\(c_2\) from numerical data alone (3-point Richardson, quadrature at 0.001, 0.002, 0.004 rad) pass \(c_2 = 0.062500000000000000001\) and \(c_4 = 0.00358072916667\) (\(11/3072 = 0.00358072916667\)).
Numbers quoted in C-S1-2.md against .out pass I checked these numbers against the output: the agreements within \(1.3\times10^{-15}\) and \(1.3\times10^{-14}\), the slope 4.0014, the fitted \(c_2 = 0.062500003309\), the Richardson value \(0.062499994\), the relative errors at 0.1, 1, 2 and 3 rad, and the ratio of at least 6000 (it is \(3.58\times10^{-11}/5.3\times10^{-15}\approx 6800\)). The gap between residual\(/\theta_0^4\) at 0.01 rad and \(c_4\) is \(2.3\times10^{-8}\), which equals \(c_6\theta_0^2 = 2.35\times10^{-8}\), as expected.

Remarks

  • [cosmetic] C-S1-2.md, ## Flags, line 19: the flag says that conventions.md uses \(m\) for the mass (line 13). The current conventions.md uses \(M\) for the mass and states that \(m\) is kept for the elliptic parameter, so the flag is stale.
  • [cosmetic] C-S1-2.md, \(c_2\) from the numerical data alone: the fitted values carry errors of \(3\)–\(6\times10^{-9}\). The artefact attributes these errors to truncation of the fit, not to the integration, and my own extraction confirms this: at smaller amplitudes with a 3-term Richardson fit, \(1/16\) is recovered to 20 digits. Nothing to change.

Verdict

Confirmed. The computation establishes \(T = T_0(1 + \theta_0^2/16 + O(\theta_0^4))\), so \(c_2 = 1/16\), by two symbolic routes and several numerical routes. The symbolic routes are the elliptic-integral series and a Lindstedt–Poincaré expansion that uses no elliptic integral. The numerical routes are mpmath, SciPy, the AGM and a direct ODE integration. The script re-runs and reproduces its recorded output and data exactly. My independent checks reach \(1/16\) by routes the script does not use: the hypergeometric series, a direct expansion of the period integral, 50-digit quadrature and an implicit ODE solver. They also confirm \(c_4 = 11/3072\) and the higher coefficients against standard values. Since the series is analytic and even in \(\theta_0\), the \(O(\theta_0^4)\) remainder is justified. The only remark is cosmetic.

The summary of C-S1-2, by the agent who wrote it

Summary

Wrote computations/C-S1-2.{py,out,md} and computations/C-S1-2.periods.csv. Symbolic and numerical paths agreed.

Result

\(T(\theta_0) = T_0\,(1 + \theta_0^2/16 + 11\,\theta_0^4/3072 + 173\,\theta_0^6/737280 + 22931\,\theta_0^8/1321205760 + O(\theta_0^{10}))\), with \(T_0 = 2\pi\sqrt{L/g}\). So \(c_2 = 1/16\) and \(c_4 = 11/3072\), both exact rationals.

  • Symbolic. Two independent routes give the same coefficients. The first is the exact period \(T = (4/\omega_0)K(\sin(\theta_0/2))\), expanded in \(\theta_0\); it gives \(c_2\) through \(c_8\). The second is a Lindstedt–Poincaré expansion of the equation of motion, with no elliptic integral; it gives \(c_2\), \(c_4\) and \(c_6\), identical to the first.
  • Numerical. At 13 amplitudes from 0.01 to 3 rad, three evaluations of the exact \(T/T_0\) agree to within \(1.3\times10^{-15}\): mpmath at 40 digits, scipy.special.ellipk, and a pure-NumPy arithmetic-geometric-mean (AGM) evaluation of \(K\). A direct integration of the equation of motion with no elliptic function (DOP853, rtol \(10^{-13}\)) agrees with the mpmath value to within \(1.3\times10^{-14}\).
  • Residual scaling. The residual \(T/T_0 - 1 - \theta_0^2/16\) scales as \(\theta_0^{4.0014}\) on \([0.01, 0.3]\). At \(\theta_0 = 0.01\), residual\(/\theta_0^4 = 0.0035807526\), against \(c_4 = 0.0035807292\).
  • \(c_2\) from the ODE data alone. A fit gives \(c_2 = 0.062500003\) (error \(3\times10^{-9}\)), and Richardson extrapolation gives \(0.062499994\) (error \(6\times10^{-9}\)).
  • Accuracy of the second-order formula. Its relative error \([T_0(1+\theta_0^2/16) - T]/T\) is \(-3.6\times10^{-7}\) at 0.1 rad, \(-3.6\times10^{-3}\) at 1 rad, \(-5.9\times10^{-2}\) at 2 rad and \(-0.39\) at 3 rad. The formula always underestimates the period.

Flags

  • conventions.md uses the letter \(m\) for two things: the mass (line 13) and the elliptic parameter \(m = k^2\) (line 22). This computation uses \(m\) only for the parameter. The clash is harmless here, since the mass drops out of the period, but it could confuse later artefacts.

Task

Check, independently, that the period of the simple pendulum at amplitude \(\theta_0\) is \(T = T_0\,(1 + \theta_0^2/16 + O(\theta_0^4))\) with \(T_0 = 2\pi\sqrt{L/g}\), so \(c_2 = 1/16\). The brief asks for two paths:

  • Symbolic. Starting from the equation of motion, obtain the exact \(T(\theta_0)\) and expand \(T/T_0\) with SymPy, reporting \(c_2\) and \(c_4\) as exact rationals.
  • Numerical. Evaluate the exact period at amplitudes from about 0.01 to 3 rad by two routes: the closed form with \(K\), and a direct ODE integration. Compare both with \(T_0(1 + c_2\theta_0^2)\). Check the \(\theta_0^4\) scaling of the residual, and extract \(c_2\) from the numerical data alone.

The brief agrees with project.md (goal) and conventions.md: the equation of motion is \(\ddot\theta + \omega_0^2\sin\theta = 0\), \(\theta_0\) is the maximum angle, and \(K\) is written with the modulus \(k\).

Computation

All periods are given as the dimensionless ratio \(T/T_0\); equivalently \(\omega_0 = 1\) and \(T_0 = 2\pi\). To get a time in seconds, multiply by \(2\pi\sqrt{L/g}\).

Symbolic (SymPy 1.14).

  • S1. Energy integral. SymPy checks that the energy \(\tfrac12\dot\theta^2 - \omega_0^2\cos\theta\) is conserved on the equation of motion. This gives \(\dot\theta^2 = 2\omega_0^2(\cos\theta - \cos\theta_0)\), and by symmetry \(T = 4\int_0^{\theta_0} d\theta/|\dot\theta|\).
  • S2. Substitution. With \(\sin(\theta/2) = k\sin\phi\) and \(k = \sin(\theta_0/2)\), SymPy reduces the integrand to \(1/(\omega_0\sqrt{1-k^2\sin^2\phi})\). Literally, it returns the ratio of the two integrands as \(\cos\phi/|\cos\phi|\), which equals 1 on \([0,\pi/2]\); it is also equal to 1 to 18 digits at 6 random points. Hence \(T = (4/\omega_0)K(k)\) and \(T/T_0 = (2/\pi)K(\sin(\theta_0/2))\).
  • S3. Series of \(K\). \(K\) is expanded in the parameter \(m=k^2\) by integrating the binomial series of the integrand term by term. The result is identical to sympy.elliptic_k(m).series(m) (parameter \(m\)) and to \(\tfrac{\pi}{2}\sum_n\big[\binom{2n}{n}/4^n\big]^2 m^n\).
  • S4. Expansion in \(\theta_0\). The series of S3 is evaluated at \(m = \sin^2(\theta_0/2)\) and expanded in \(\theta_0\) through order 8. The odd coefficients vanish.
  • S5. Lindstedt–Poincaré, with no elliptic integral. With \(\tau = \omega t\), \(\Omega = \omega^2 = 1 + a_2\epsilon^2 + a_4\epsilon^4 + a_6\epsilon^6\) and \(\theta = \epsilon\cos\tau + \epsilon^3y_3 + \epsilon^5y_5 + \epsilon^7y_7\), the initial data are \(\theta(0)=\epsilon\) and \(\dot\theta(0)=0\), so that \(\theta_0=\epsilon\) exactly. Requiring no secular term at each order fixes the \(a_{2j}\). Then \(T/T_0 = \Omega^{-1/2}\).

Numerical (NumPy 2.4, SciPy 1.17, mpmath).

  • Closed form, \(T/T_0 = (2/\pi)K\), evaluated three ways:
    • mpmath.ellipk(m) at 40 digits, which takes the parameter \(m=\sin^2(\theta_0/2)\); this is the reference value;
    • scipy.special.ellipk(m), which also takes the parameter \(m\);
    • a pure-NumPy AGM, \(K(k) = \pi/(2\,\mathrm{AGM}(1, k'))\), which takes the complementary modulus \(k' = \cos(\theta_0/2)\).
  • Direct ODE integration. The equation integrated is \(u'' = -\sin(\theta_0 u)/\theta_0\), with \(u = \theta/\theta_0\), \(u(0)=1\) and \(u'(0)=0\). The integrator is scipy.integrate.solve_ivp with DOP853, rtol \(10^{-13}\) and atol \(10^{-15}\). The period is computed twice, from event location: as 4 times the first zero of \(u\), and as 2 times the time of the turning point at \(u=-1\).
  • Amplitudes: 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.5, 0.75, 1, 1.5, 2, 2.5, 3 rad.

Results

Symbolic. $\(K(m) = \frac{\pi}{2} + \frac{\pi m}{8} + \frac{9 \pi m^{2}}{128} + \frac{25 \pi m^{3}}{512} + \frac{1225 \pi m^{4}}{32768} + O(m^5)\)\( \)\(\frac{T}{T_0} = 1 + \frac{\theta_{0}^{2}}{16} + \frac{11 \theta_{0}^{4}}{3072} + \frac{173 \theta_{0}^{6}}{737280} + \frac{22931 \theta_{0}^{8}}{1321205760} + O(\theta_0^{10})\)\( \)\(c_2 = \frac{1}{16},\qquad c_4 = \frac{11}{3072},\qquad c_6 = \frac{173}{737280},\qquad c_8 = \frac{22931}{1321205760}\)\( In the Lindstedt–Poincaré route, the conditions on the secular terms give \)a_2 = -1/8\(, \)a_4 = 7/1536\( and \)a_6 = -19/184320\(. Then \)\Omega^{-1/2} = 1 + \theta_0^2/16 + 11\theta_0^4/3072 + 173\theta_0^6/737280 + O(\theta_0^8)$, which differs from the elliptic series by exactly 0.

Numerical (all values are \(T/T_0\), dimensionless; full table in the CSV):

\(\theta_0\) (rad) \(T/T_0\) (mpmath) ODE − mpmath \([T_0(1+\theta_0^2/16) - T]/T\) residual\(/\theta_0^4\)
0.01 1.00000625003580753 5.3e-15 −3.58e-11 0.00358075
0.1 1.00062535830773663 3.1e-15 −3.58e-07 0.00358308
0.5 1.01585253110143671 1.1e-15 −2.24e-04 0.00364050
1.0 1.06633424557996305 3.3e-15 −3.60e-03 0.00383425
2.0 1.32890445191509954 1.3e-14 −5.94e-02 0.00493153
3.0 2.57123394943214205 5.8e-15 −3.92e-01 0.01245351

\(c_2\) from the numerical data alone.

  • The ratio \((T/T_0 - 1)/\theta_0^2\), computed from the ODE data, is 0.062500358 at \(\theta_0 = 0.01\) and tends to \(1/16\) as \(\theta_0 \to 0\); at 0.01 it still contains \(c_4\theta_0^2 = 3.6\times10^{-7}\).
  • A least-squares fit of \(c_2 + c_4\theta_0^2 + c_6\theta_0^4\) on \(\theta_0\in[0.05, 0.5]\) (5 points) gives \(c_2 = 0.062500003309\) and \(c_4 = 0.00358032\) from the ODE data, and \(c_2 = 0.062500003308\) from the mpmath data.
  • Richardson extrapolation from the ODE data at 0.05 and 0.1 rad gives \(c_2 = 0.062499994\).
  • The remaining errors, of a few times \(10^{-9}\), come from truncating the fit, not from the integration.

Agreement

  • Symbolic, two routes. The elliptic-integral series (S3–S4) and the Lindstedt–Poincaré expansion of the equation of motion (S5) agree exactly through \(\theta_0^6\); the difference is identically 0. The series from SymPy's elliptic_k also agrees exactly.
  • Symbolic against numerical. The truncated series matches the mpmath exact value with a relative error that shrinks by the expected order:
    • at \(\theta_0=0.1\): \(-3.6\times10^{-7}\) at order 2, \(-2.3\times10^{-10}\) at order 4, \(-1.4\times10^{-16}\) at order 8;
    • at \(\theta_0=0.5\): \(-2.2\times10^{-4}\), \(-3.7\times10^{-6}\) and \(-1.4\times10^{-9}\) at the same orders.
  • Numerical routes. scipy, the AGM and mpmath agree to within \(1.3\times10^{-15}\). The ODE integration (quarter period) agrees with mpmath to within \(1.3\times10^{-14}\) at every amplitude. The half-period estimate agrees to within \(1.6\times10^{-14}\), except \(9.4\times10^{-13}\) at 3 rad, close to the separatrix. These differences are at least 6000 times smaller than the relative error of the second-order formula at every amplitude (the smallest of those errors is \(3.6\times10^{-11}\), at 0.01 rad), so the comparison with the second-order formula gives the same result against either route.
  • \(c_2\). The value fitted from numerical data alone, 0.0625000033, matches the exact \(1/16\) to within \(3.3\times10^{-9}\).

Sanity checks

  • Small amplitude. At \(\theta_0 = 10^{-8}\), mpmath gives \(T/T_0 - 1 = 6.25\times10^{-18}\), which equals \(\theta_0^2/16\).
  • Scaling of the residual. The log–log slope of \(T/T_0 - 1 - \theta_0^2/16\) against \(\theta_0\) on \([0.01, 0.3]\) is 4.0014 from the mpmath data and 4.0014 from the ODE data. Residual\(/\theta_0^4\) tends to \(c_4 = 11/3072 \approx 0.0035807\).
  • Near the separatrix, \(\theta_0\to\pi\). \(T/T_0\) approaches \((2/\pi)\ln(4/\cos(\theta_0/2))\): 3.348496 against 3.348203 at 3.1 rad, and 7.2358741 against 7.2358741 at 3.1415 rad. The period diverges logarithmically, as expected.
  • Sign. \(c_2 > 0\): larger swings are slower. The second-order formula underestimates \(T\) at every amplitude tested.
  • Dimensions. \(T/T_0\) is dimensionless, and the mass drops out at the first step (S1).

Data files

  • computations/C-S1-2.periods.csv: 13 rows (amplitudes \(\theta_0\) from 0.01 to 3 rad) × 11 columns. The columns are:
    • theta0_rad, the amplitude in rad;
    • \(T/T_0\) (dimensionless) from mpmath, given as a 20-digit string, and from scipy, the AGM, the ODE quarter period and the ODE half period;
    • the second-order value \(1 + \theta_0^2/16\);
    • the relative error of the second-order formula against mpmath;
    • the residual \(T/T_0 - 1 - \theta_0^2/16\), and the residual divided by \(\theta_0^4\);
    • ODE minus mpmath.
The card's own text

This answers the goal of project.md: the coefficient of the \(\theta_0^2\) correction to the small-oscillation period.

Derivation D-S1-1 obtains it in two ways. First, energy conservation gives the exact period \(T(\theta_0) = 4\sqrt{L/g}\,K(\sin(\theta_0/2))\), with \(K\) written with the modulus \(k\) (see conventions.md); expanding \(K\) and \(k = \sin(\theta_0/2)\) gives \(T/T_0 = 1 + \theta_0^2/16 + 11\,\theta_0^4/3072 + O(\theta_0^6)\). Second, a Poincaré–Lindstedt calculation on \(\sin\theta \approx \theta - \theta^3/6\) gives the same \(c_2\).

Assumptions: point mass, massless rigid rod, no friction, uniform gravity, planar motion, libration (\(0 < \theta_0 < \pi\)), \(\theta_0\) in radians. The next coefficient \(c_4 = 11/3072\) is stated by D-S1-1 but is not the subject of this card.