The Computational Pendulum

Master Code Directory

Welcome to the companion code repository. This page organizes all Python scripts referenced throughout the textbook. For the best learning experience, you can view the raw code on GitHub or launch the scripts directly in an interactive Google Colab notebook environment.

File Path Description Actions
Part I: Foundations — Chapter 2: Pendulum Fundamentals
scripts/chapter2/energy_phase.ipynb Energy and Phase Space for the Simple Pendulum
scripts/chapter2/small_angle_tension.ipynb Pendulum Tension in the small angle limit
scripts/chapter2/exact_vs_small_angle.ipynb Comparison of angle exact solution with the small angle approximation
scripts/chapter2/exact_pendulum_period.ipynb Period T of the simple pendulum: Exact vs small angle and oscillation and rotation cases
scripts/chapter2/relative_power.ipynb Relative Power harmonic contribution for the simple pendulum oscillations
scripts/chapter2/relative_power_oscillation_rotation.ipynb Comparison of Relative Power harmonic contribution for oscillations vs rotations of the simple pendulum.
Part I: Foundations — Chapter 3: Chapter 2 Exercises
scripts/chapter3/artist_trapeze_velocity.ipynb Trapeze Artist Forward Velocity vs Bar Final Swing Direction
scripts/chapter3/wrecking_ball.ipynb Wrecking ball: θf as a function of θ0 for several values of k/W
scripts/chapter3/pendulum_detachment_trajectories.ipynb Trajectories of the detached pendulum CM and rotation about the CM
scripts/chapter3/pendulum_detachment_momentum.ipynb Rate of Change of Total Angular Momentum in Free-Flight for each detached pendulum
scripts/chapter3/pivoting_rod_phase_space.ipynb Comparison of the phase space of a uniform rigid rod with the one for a simple pendulum.
scripts/chapter3/pivoting_rod_bending.ipynb Distribution of the internal shear force V(x) and bending moment M(x) along the length of the falling rod.
scripts/chapter3/pendulum_wrapping_around_peg.ipynb Exact wrapping time vs upper and lower bound times.
scripts/chapter3/small_mass_hanging_motion.ipynb Radial Oscillations vs Rotational Motion of 𝑚 under small oscillations of 𝑚2.
scripts/chapter3/small_mass_hanging_motion_large_period.ipynb Radial oscillation period of m under large oscillations of m2. Comparison with Radial oscillation period of m under small oscillations of m2.
scripts/chapter3/mass_hanging_motion_large_trajectory.ipynb Radial Oscillations vs Rotational Motion of m under large oscillations of m2.
scripts/chapter3/angled_strike.ipynb Snap time, snap angle and maximum angle of oscillation vs angle.
scripts/chapter3/pendulum_bug_small_frequency.ipynb Pendulum frequency as the Bug Crawls Outward (slow bug, small angle approximation).
scripts/chapter3/pendulum_bug_small_angle_max.ipynb Normalized Maximum Pendulum Angle as the Bug Crawls Outward (slow bug, small angle approximation).
Part II: Approximations — Chapter 4: Pendulum Approximations
scripts/chapter4/euler_cromer_exact.ipynb Simple Pendulum solution comparison: Euler, Cromer and Exact.
scripts/chapter4/verlet_cromer_exact.ipynb Simple Pendulum solution comparison: Verlet, Cromer and Exact.
scripts/chapter4/period_cromer.ipynb Period of simple pendulum computed by Cromer’s method and compared to Exact and small angle period.
scripts/chapter4/pendulum_bug_slow_exploration.ipynb Numerical Exploration of the bug on a pendulum equation of motion in the Slow Approximation via 4th order Runge-Kutta.
scripts/chapter4/pinn_1_hidden_layer.ipynb 1 Hidden Layer PINN to solve the pendulum equation for the first 5 secs. Drop angle is 𝜋/4=45∘ from rest.
scripts/chapter4/pinn_1_hidden_layer_time_break.ipynb 1 Hidden Layer PINN to solve the pendulum equation for the first 25 secs using 5 secs domain decomposition. Drop angle is 𝜋/4=45∘.
scripts/chapter4/pinn_1_hidden_layer_time_break_microstepping.ipynb 1 Hidden Layer PINN to solve the pendulum equation for the first 25 secs using 1 sec microstepping and hardened constraints. Drop angle is π/4 = 45◦ from rest.
scripts/chapter4/pinn_1_hidden_layer_15secs_150000fun.ipynb 1 Hidden Layer PINN to solve the pendulum equation for the first 15 secs using increased maxfun=150,000. Drop angle is π/4 = 45◦ from rest.
scripts/chapter4/pinn_1_hidden_layer_jax.ipynb Nonlinear Pendulum (25s): JAX 1-Layer PINN vs Exact vs Linear.
scripts/chapter4/pinn_2_hidden_layer_jax.ipynb 2 Hidden Layer PINN to solve the pendulum equation for the first 25 secs using JAX. Drop angle is 𝜋/4=45∘ from rest
scripts/chapter4/pinn_1_2_hidden_layer_scaled_jax.ipynb Comparison of 1, 2 hidden layer PINN solution with exact and small angle approximation. Drop angle is 𝜋/4=45∘
scripts/chapter4/pinn_2_hidden_layer_sequential_jax.ipynb 2 layer PINN solution to the pendulum equation in the [0,50sec] range using sequential PINNs at 10 secs intervals.. Drop angle is 𝜋/4=45∘
Part II: Approximations — Chapter 5: Chapter 4 Exercises
scripts/chapter5/mean_tension_libration.ipynb Average pendulum tension in the libration regime ( 0∘<𝜃<180∘ ).
scripts/chapter5/mean_tension_overall.ipynb Average pendulum tension in the libration and rotation regimes ( 0∘<𝜃<360∘ ).
scripts/chapter5/angle_deception.ipynb Euler-Cromer and Velocity Verlet descent time from rest compared.
scripts/chapter5/magic_kick.ipynb The Magic Kick: Shifting 𝛽𝑐 by Adding Initial Velocity.
scripts/chapter5/pendulum_bug_work.ipynb Verification of the Work-Energy Theorem Across All Behavioral Regimes (small angle, oscillation, rotation). Slow bug motion.
scripts/chapter5/pendulum_bug_oscillation_rotation_slow.ipynb Transition from rotation to oscillation (and back).
scripts/chapter5/mathieu_tongues.ipynb STRUTT DIAGRAM (Parametric Resonance Tongues for Mathieu's Equation).
scripts/chapter5/pinn_pendulum_gravity.ipynb Using 2 hidden layer PINN to find planet gravity from pendulum angle measurements.
scripts/chapter5/pinn_pendulum_damping.ipynb Finding rusty pivot damping using 2 hidden layer PINN.
scripts/chapter5/pinn_drop.ipynb Discovering the trajectory of an object via 2 hidden layer PINN.
scripts/chapter5/pinn_pendulum_period.ipynb Discovering the period of a pendulum dropped from 𝜃0=150∘ via a 2 hidden layer PINN.
Part III: Explorations — Chapter 6: Pendulum Explorations
scripts/chapter6/velocity_hodograph.ipynb Simple Pendulum Velocity Hodograph.
scripts/chapter6/pendulum_jumping_cases_1_2.ipynb Parametric Pumping and Active Damping of a pendulum via a jumping bug.
scripts/chapter6/chaotic_1d_parallel_bug_explorer.ipynb Exploration of the 1D parallel bug jump behavior using tools to diagnose chaotic and non chaotic behavior of the pendulum.
scripts/chapter6/reservoir_1d_bug_lab.ipynb The Temporal XOR Gate, Wave Physics — Turning a Sine Wave into a 90◦-Shifted Cosine AND a Double-Frequency Wave, Engineering Control — A 2-Step Nonlinear Echo Filter (Polynomial Memory Task) solved using 1D jump bug on a pendulum reservoir computer.
Part III: Explorations — Chapter 7: Chapter 6 Exercises
scripts/chapter7/acceleration_hodograph.ipynb Simple Pendulum Acceleration Hodograph.
scripts/chapter7/pendulum_elevator_trajectories.ipynb Pendulum Trajectories in an Accelerating Elevator.
scripts/chapter7/pendulum_train_trajectories.ipynb Pendulum Trajectories in a Horizontally Accelerating Train.
scripts/chapter7/jumping_pendulum_energy_vs_time.ipynb Jumping Pendulum Energy vs Time.
scripts/chapter7/jumping_pendulum_return_maps.ipynb Jumping Pendulum Return Map comparison.
scripts/chapter7/jumping_pendulum_phase_space.ipynb Jumping Pendulum Phase space.
scripts/chapter7/jumping_pendulum_real_trajectories.ipynb Jumping Pendulum Spatial Trajectories.
scripts/chapter7/jumping_pendulum_soft_hard.ipynb Jumping Pendulum Spatial Trajectories Soft vs Stiff Strings.
scripts/chapter7/pendulum_jumping_bug_5_regimes.ipynb Jumping Bug 5 motions.
scripts/chapter7/mechanism_1_sawtooth_bug_explorer.ipynb Chaos and the 8 Threshold-Switched Jumping Bug motions.
scripts/chapter7/ballistic_2d_jump_simulation.ipynb True 2D Ballistic Jumping Bug Simulation.
scripts/chapter7/jumping_bug_chaos_dashboard.ipynb 1D & 2D Maps for Parallel and Ballistic Jumping Bugs Simulation.
scripts/chapter7/reservoir_1d_physics_exercises_lab.ipynb 1D bug reservoir computer exercises lab.
Legend: View Repository Run Google Colab
Download ZIP archive ↓