Companion Website & Code Repository

Solving the Pendulum with Physics, Code, and AI.

A progressive journey from high school Mechanics to Neural Networks. By systematically analyzing the pendulum, discover that physics, pure mathematics, and machine learning are not isolated silos, but interconnected lenses.

By Horos Kyklos
Leanpub (PDF) | Amazon (Print) Coming Soon

A Tangible Anchor for Advanced Concepts

The simple pendulum is typically relegated to the first few weeks of an introductory physics course. However, when you push beyond the standard small-angle approximation, it reveals itself as a powerful theoretical laboratory.

Classical Mechanics

Starting with kinematics and Newton's Second Law, we derive equations of motion, tension, and phase portraits. We bridge standard AP Physics directly into exact rigid body dynamics.

Computational Physics

Continuous periodic systems accumulate errors rapidly. Learn to solve the exact large-angle pendulum using symplectic integrators and 4th-order Runge-Kutta (RK4) via hands-on Python scripts.

Machine Learning

The pendulum is the perfect baseline for AI. We use JAX and Google Colab to train Physics-Informed Neural Networks (PINNs) and explore Physical Reservoir Computing.

The Structure of the Journey

To help you pace your learning, the book is divided into three main arcs. Each theory chapter is tightly integrated with runnable Python notebooks and is immediately followed by a dedicated chapter of fully solved exercises acting as an open-ended laboratory.

I

Foundations and First Simulations

Available Now

We begin with AP-level mechanics (kinematics, SHM, energy conservation) and push beyond them to derive exact Jacobi elliptic solutions, Fourier power spectra, and rigid-body dynamics—paired with 15 fully solved exercises and our first Python visualizations.

II

Numerical Methods, Piecewise Models & Machine Learning

Available Now

Stripping away standard idealizations, we analyze symplectic integrators (Euler-Cromer, Velocity Verlet) and 4th-order Runge-Kutta (RK4), explore adiabatic invariants and piecewise-linear surrogates (leading to Mathieu's equation and parametric resonance), and train JAX-based Physics-Informed Neural Networks (PINNs).

III

Explorations in Modern Dynamics & AI

Available Now

With a strong foundation built, we shift to broad exploration: Velocity and Acceleration Hodographs, non-inertial reference frames, hybrid jumping systems, 1D Chaos Theory, and Physical Reservoir Computing—treating the final exercises as a creative sandbox that turns a pendulum into an analog computer.

chapter4/pinn_pendulum_jax.ipynb
import jax.numpy as jnp
from jax import grad, jit, vmap

# Define the Physics-Informed Loss Function
def physics_loss(params, t):
    theta = neural_network(params, t)
    
    # d^2(theta)/dt^2 + (g/L)*sin(theta) = 0
    theta_t = grad(neural_network, argnums=1)
    theta_tt = grad(theta_t, argnums=1)
    
    residual = theta_tt(params, t) + (g/L) * jnp.sin(theta)
    return jnp.mean(residual**2)

Ready to run the simulations?

Open Script Directory

A Toolkit for Educators & Self-Learners

Teachers of AP Physics or freshman mechanics often struggle to find rigorous, ready-to-use materials that push beyond the standard curriculum. Because every advanced topic is anchored to the universally taught simple pendulum, educators can easily integrate these chapters as honors-level extensions, capstone projects, or computational labs. For software developers, data scientists, and curious independent learners, the book provides a focused, math-first bridge into modern physics and AI without the cognitive overload of constantly changing theoretical contexts.

100% Fully Solved Exercises
JAX Colab Ready Code
Available Now

Get Your Copy of the Book

Choose your preferred format below. Both digital and print editions include full access to the open-source companion scripts and interactive Google Colab notebooks.

Digital Edition PDF

Leanpub

Ideal for reading on tablets or laptops alongside your code editor. Includes a DRM-free PDF download, clickable hyperlinks to every Colab notebook, and free lifetime updates.

Get Digital Book on Leanpub
Print Edition In Progress
Paperback

Amazon

Prefer working through derivations with pen and paper? The physical paperback edition will be released on Amazon once Parts II and III are finalized. In the meantime, Leanpub readers receive free lifetime PDF updates as new chapters are published.

Print Edition Coming Soon
Feedback & Questions

Contact the Author

Have a question about a derivation, found a typo, or using the book in your course? Send a private message below.

Your message is sent privately to the author and is never posted publicly.