pendulum
Rigid pendulum released from rest at any amplitude, with optional viscous damping: exact period by the arithmetic-geometric mean (T/T₀ = 1/AGM(1, cos(a/2))), the error of the small-angle formula and the amplitude up to which it holds, an RK4 time history with its period, energy drift, speed and rod tension at the bottom, and the measured decay rate of the swing.
Writes trace.csv and peaks.csv.
- Field
- Dynamics and control
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 0.05 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001small-angle formula T₀ = 2 π √(L/g): L = 0.25 m with g = π² m/s² is exactly 1 s; at 0.1° the ratio is the textbook series 1 + a^2/16 + 11 a^4/3072 = 1.00000019038592 (closed forms, 10⁻⁹)passed
small_angle_period_s1 ± 10⁻⁹1lockedunder 0.01 % of the tolerance usedperiod_ratio1 ± 10⁻⁹1lockedunder 0.01 % of the tolerance usednatural_frequency_rad_per_s6.28319 ± 6.3 × 10⁻⁹6.28319lockedunder 0.01 % of the tolerance usedr000290°: T/T₀ = 2K(1/√2)/π = Γ(1/4)² / (2 π¹.5) = 1.1803405990161 (lemniscate case; Abramowitz & Stegun table 17.1, K(45°) = 1.85407467730137); small-angle error 1/1.18034 - 1 = -15.2787 %; closed forms, 10⁻⁹passed
period_ratio1.18034 ± 1.2 × 10⁻⁹1.18034lockedunder 0.01 % of the tolerance usedexact_period_s2.36825 ± 2.4 × 10⁻⁹2.36825lockedunder 0.01 % of the tolerance usedsmall_angle_error_pct-15.2787 ± 1.5 × 10⁻⁷-15.2787lockedunder 0.01 % of the tolerance usedsmall_angle_ok= falsefalselockedexact matchr000360°: T/T₀ = 2K(1/2)/π = 1.0731820071494 (Abramowitz & Stegun table 17.1, K(30°) = 1.68575035481260; checked by the power series in k²); closed form, 10⁻⁹passed
period_ratio1.07318 ± 1.1 × 10⁻⁹1.07318lockedunder 0.01 % of the tolerance usedr0004120°: T/T₀ = 2K(sin 60°)/π = 1.3728805006183 (Abramowitz & Stegun table 17.1, K(60°) = 2.15651564749964); closed form, 10⁻⁹passed
period_ratio1.37288 ± 1.4 × 10⁻⁹1.37288lockedunder 0.01 % of the tolerance usedr0005RK4 against exact answers, release from horizontal with L = g so T₀ = 2 π: period 2 π x 1.18034059901610 = 7.41629870920549 s, bottom speed √(2 g L) = g √2, rod tension 3 x weight, energy conserved. RK4 at 2000 steps per period has a global error near (w h)⁴ = 2 × 10⁻¹⁰, so 10⁻⁷ on the readings and 10⁻⁸ on the energy driftpassed
small_angle_period_s6.28319 ± 6.3 × 10⁻⁹6.28319lockedunder 0.01 % of the tolerance usedrk4_period_s7.4163 ± 7.4 × 10⁻⁷7.4163lockedunder 0.01 % of the tolerance usedrk4_period_rel_error≤ 10⁻⁷6.97125 × 10⁻¹³lockedinside the rangebottom_speed_m_per_s13.8687 ± 1.4 × 10⁻⁸13.8687lockedunder 0.01 % of the tolerance usedrk4_bottom_speed_m_per_s13.8687 ± 1.4 × 10⁻⁶13.8687lockedunder 0.01 % of the tolerance usedbottom_tension_over_weight3 ± 3 × 10⁻⁷3lockedunder 0.01 % of the tolerance usedenergy_initial_J_per_kg96.1704 ± 9.6 × 10⁻⁸96.1704lockedunder 0.01 % of the tolerance usedenergy_drift_rel≤ 10⁻⁸1.08003 × 10⁻¹²lockedinside the rangeenergy_final_fraction1 ± 10⁻⁸1lockedunder 0.01 % of the tolerance usedr0006light damping, linear theory: ζ = 0.02 with w₀ = 1 rad/s gives an envelope exp(-ζ w₀ t), so decay rate 0.02 /s, period 2 π / √(1 - ζ²) = 6.28444232135785 s, amplitude ratio per cycle exp(-2 π ζ / √(1 - ζ²)) = 0.881889207074743. Run at 0.1°, where sin(θ) differs from θ by a^2/6 = 5 × 10⁻⁷, hence 2 × 10⁻⁶passed
decay_rate_per_s0.02 ± 4 × 10⁻⁸0.02locked3 % of the tolerance useddecay_rate_theory_per_s0.02 ± 2 × 10⁻¹¹0.02lockedunder 0.01 % of the tolerance useddamping_ratio_measured0.02 ± 4 × 10⁻⁸0.02locked3 % of the tolerance usedrk4_period_s6.28444 ± 1.3 × 10⁻⁵6.28444locked3.4 % of the tolerance useddamped_period_small_angle_s6.28444 ± 6.3 × 10⁻⁹6.28444lockedunder 0.01 % of the tolerance usedamplitude_ratio_per_cycle0.881889 ± 1.8 × 10⁻⁶0.881889locked0.81 % of the tolerance usedhalf_amplitude_time_s34.6574 ± 6.9 × 10⁻⁵34.6574locked3 % of the tolerance usedquality_factor25 ± 2.5 × 10⁻⁸25lockedunder 0.01 % of the tolerance usedr0007where the small-angle formula stops being good: by the series T/T₀ = 1 + a^2/16 + 11 a^4/3072, so T₀/T = 1 - a^2/16 + a^4/3072, a period error of 10⁻⁴ % is reached at a = 0.004 rad x (1 + 4 × 10⁻⁸) = 0.2291831276°; 10° (error about a^2/16 = 0.19 %) is outside that tolerance; series truncation is below 10⁻⁹ here, 10⁻⁶passed
small_angle_limit_deg0.229183 ± 2.3 × 10⁻⁷0.229183lockedunder 0.01 % of the tolerance usedsmall_angle_ok= falsefalselockedexact matchr0008critical damping and beyond does not swing: ζ = 2 gives no zero crossing, so no period (null) and energy only falls (final fraction below 1)passed
turning_points= 11lockedexact matchenergy_final_fraction0 to 14.89088 × 10⁻⁵lockedinside the rangequality_factor0.25 ± 2.5 × 10⁻¹⁰0.25lockedunder 0.01 % of the tolerance used
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
length_m | m | 1.0 | Pivot to the centre of the bob (point mass on a massless rigid rod). |
gravity_m_per_s2 | m/s² | 9.80665 | Local gravity. Default is standard gravity (exact by definition). |
amplitude_deg | deg | 30.0 | Release angle from the hanging position; released from rest. |
damping_ratio | 1 | 0.0 | Fraction of critical damping ζ in θ'' + 2 ζ w₀ θ' + w₀² sin(θ) = 0. 0 is no damping. |
periods | 1 | 10 | Length of the time history, in exact undamped periods at this amplitude. |
steps_per_period | 1 | 2000 | RK4 steps in one exact period. |
small_angle_tolerance_pct | % | 1.0 | Period error accepted from T₀ = 2 π √(L/g); sets the verdict and small_angle_limit_deg. |
Readings
| Name | Unit | Meaning |
|---|---|---|
small_angle_period_s | s | T₀ = 2 π √(L/g). |
exact_period_s | s | Undamped period at this amplitude, T₀ / AGM(1, cos(a/2)). |
period_ratio | 1 | T / T₀ = 2 K(sin(a/2)) / π. |
small_angle_error_pct | % | (T₀ - T) / T: negative, the small-angle formula reads short. |
small_angle_ok | true when the error is within small_angle_tolerance_pct. | |
small_angle_limit_deg | deg | Largest amplitude at which T₀ stays within the tolerance. |
natural_frequency_rad_per_s | rad/s | w₀ = √(g/L). |
rk4_period_s | s | Mean period of the time history, from its zero crossings; null when it never swings through. |
rk4_period_rel_error | 1 | |RK4 period - exact| / exact, no damping only. |
energy_initial_J_per_kg | J/kg | g L (1 - cos a). |
energy_drift_rel | 1 | Largest |E - E₀| / E₀ over the history, no damping only. |
energy_final_fraction | 1 | E at the end over E at release. |
bottom_speed_m_per_s | m/s | √(2 g L (1 - cos a)): no damping, closed form. |
rk4_bottom_speed_m_per_s | m/s | Bob speed at the first pass through the bottom, from the time history (with damping). |
bottom_tension_over_weight | 1 | Rod tension over the bob's weight at the first pass through the bottom, 1 + v² / (g L). |
decay_rate_per_s | 1/s | Measured: ln(first amplitude / last turning point) / time between them. Null without damping. |
decay_rate_theory_per_s | 1/s | ζ w₀, the small-angle envelope rate. |
damping_ratio_measured | 1 | decay_rate_per_s / w₀. |
amplitude_ratio_per_cycle | 1 | Amplitude after one cycle over the amplitude before, from the measured rate and period. |
half_amplitude_time_s | s | ln 2 / measured decay rate. |
damped_period_small_angle_s | s | T₀ / √(1 - ζ²). |
quality_factor | 1 | 1 / (2 ζ). |
amplitude_final_deg | deg | Size of the last turning point in the history. |
turning_points | 1 | |
steps | 1 | |
step_s | s | |
duration_s | s | |
warnings | Plain-word cautions. | |
trace_file | out/trace.csv: t_s, theta_deg, omega_rad_per_s, energy_J_per_kg (at most about 4000 rows). | |
peaks_file | out/peaks.csv: t_s, theta_deg, amplitude_deg at every turning point. |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.