pendulum
Rigid pendulum released from rest at any amplitude, with optional viscous damping: exact period by the arithmetic-geometric mean (T/T0 = 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 T0 = 2 pi sqrt(L/g): L = 0.25 m with g = pi^2 m/s^2 is exactly 1 s; at 0.1 deg the ratio is the textbook series 1 + a^2/16 + 11 a^4/3072 = 1.00000019038592 (closed forms, 1e-9)passed
small_angle_period_s1 ± 1e-091lockedunder 0.01 % of the tolerance usedperiod_ratio1 ± 1e-091lockedunder 0.01 % of the tolerance usednatural_frequency_rad_per_s6.28319 ± 6.3e-096.28319lockedunder 0.01 % of the tolerance usedr000290 deg: T/T0 = 2K(1/sqrt 2)/pi = Gamma(1/4)^2 / (2 pi^1.5) = 1.1803405990161 (lemniscate case; Abramowitz & Stegun table 17.1, K(45 deg) = 1.85407467730137); small-angle error 1/1.18034 - 1 = -15.2787 %; closed forms, 1e-9passed
period_ratio1.18034 ± 1.2e-091.18034lockedunder 0.01 % of the tolerance usedexact_period_s2.36825 ± 2.4e-092.36825lockedunder 0.01 % of the tolerance usedsmall_angle_error_pct-15.2787 ± 1.5e-07-15.2787lockedunder 0.01 % of the tolerance usedsmall_angle_ok= falsefalselockedexact matchr000360 deg: T/T0 = 2K(1/2)/pi = 1.0731820071494 (Abramowitz & Stegun table 17.1, K(30 deg) = 1.68575035481260; checked by the power series in k^2); closed form, 1e-9passed
period_ratio1.07318 ± 1.1e-091.07318lockedunder 0.01 % of the tolerance usedr0004120 deg: T/T0 = 2K(sin 60 deg)/pi = 1.3728805006183 (Abramowitz & Stegun table 17.1, K(60 deg) = 2.15651564749964); closed form, 1e-9passed
period_ratio1.37288 ± 1.4e-091.37288lockedunder 0.01 % of the tolerance usedr0005RK4 against exact answers, release from horizontal with L = g so T0 = 2 pi: period 2 pi x 1.18034059901610 = 7.41629870920549 s, bottom speed sqrt(2 g L) = g sqrt 2, rod tension 3 x weight, energy conserved. RK4 at 2000 steps per period has a global error near (w h)^4 = 2e-10, so 1e-7 on the readings and 1e-8 on the energy driftpassed
small_angle_period_s6.28319 ± 6.3e-096.28319lockedunder 0.01 % of the tolerance usedrk4_period_s7.4163 ± 7.4e-077.4163lockedunder 0.01 % of the tolerance usedrk4_period_rel_error≤ 1e-076.97125e-13lockedinside the rangebottom_speed_m_per_s13.8687 ± 1.4e-0813.8687lockedunder 0.01 % of the tolerance usedrk4_bottom_speed_m_per_s13.8687 ± 1.4e-0613.8687lockedunder 0.01 % of the tolerance usedbottom_tension_over_weight3 ± 3e-073lockedunder 0.01 % of the tolerance usedenergy_initial_J_per_kg96.1704 ± 9.6e-0896.1704lockedunder 0.01 % of the tolerance usedenergy_drift_rel≤ 1e-081.08003e-12lockedinside the rangeenergy_final_fraction1 ± 1e-081lockedunder 0.01 % of the tolerance usedr0006light damping, linear theory: zeta = 0.02 with w0 = 1 rad/s gives an envelope exp(-zeta w0 t), so decay rate 0.02 /s, period 2 pi / sqrt(1 - zeta^2) = 6.28444232135785 s, amplitude ratio per cycle exp(-2 pi zeta / sqrt(1 - zeta^2)) = 0.881889207074743. Run at 0.1 deg, where sin(theta) differs from theta by a^2/6 = 5e-7, hence 2e-6passed
decay_rate_per_s0.02 ± 4e-080.02locked3 % of the tolerance useddecay_rate_theory_per_s0.02 ± 2e-110.02lockedunder 0.01 % of the tolerance useddamping_ratio_measured0.02 ± 4e-080.02locked3 % of the tolerance usedrk4_period_s6.28444 ± 1.3e-056.28444locked3.4 % of the tolerance useddamped_period_small_angle_s6.28444 ± 6.3e-096.28444lockedunder 0.01 % of the tolerance usedamplitude_ratio_per_cycle0.881889 ± 1.8e-060.881889locked0.81 % of the tolerance usedhalf_amplitude_time_s34.6574 ± 6.9e-0534.6574locked3 % of the tolerance usedquality_factor25 ± 2.5e-0825lockedunder 0.01 % of the tolerance usedr0007where the small-angle formula stops being good: by the series T/T0 = 1 + a^2/16 + 11 a^4/3072, so T0/T = 1 - a^2/16 + a^4/3072, a period error of 1e-4 % is reached at a = 0.004 rad x (1 + 4e-8) = 0.2291831276 deg; 10 deg (error about a^2/16 = 0.19 %) is outside that tolerance; series truncation is below 1e-9 here, 1e-6passed
small_angle_limit_deg0.229183 ± 2.3e-070.229183lockedunder 0.01 % of the tolerance usedsmall_angle_ok= falsefalselockedexact matchr0008critical damping and beyond does not swing: zeta = 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.89088e-05lockedinside the rangequality_factor0.25 ± 2.5e-100.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^2 | 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 zeta in theta'' + 2 zeta w0 theta' + w0^2 sin(theta) = 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 T0 = 2 pi sqrt(L/g); sets the verdict and small_angle_limit_deg. |
Readings
| Name | Unit | Meaning |
|---|---|---|
small_angle_period_s | s | T0 = 2 pi sqrt(L/g). |
exact_period_s | s | Undamped period at this amplitude, T0 / AGM(1, cos(a/2)). |
period_ratio | 1 | T / T0 = 2 K(sin(a/2)) / pi. |
small_angle_error_pct | % | (T0 - 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 T0 stays within the tolerance. |
natural_frequency_rad_per_s | rad/s | w0 = sqrt(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 - E0| / E0 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 | sqrt(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^2 / (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 | zeta w0, the small-angle envelope rate. |
damping_ratio_measured | 1 | decay_rate_per_s / w0. |
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 | T0 / sqrt(1 - zeta^2). |
quality_factor | 1 | 1 / (2 zeta). |
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.