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 4th-order Runge-Kutta (RK4) integration 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 computational scripts and is immediately followed by a dedicated chapter of fully solved exercises acting as an open-ended laboratory.

I

Foundations and Simulations

Available Now

We begin with AP-level concepts (kinematics, SHM, energy conservation) and push beyond them to derive exact analytical solutions. Here, we introduce our first Python scripts to visualize dynamics and phase spaces.

II

Exact Solutions and Machine Learning

In Progress

Stripping away standard idealizations, we use heavier computation (RK4 integration) to solve the exact pendulum. We then take our first leap into machine learning by training Neural Networks to learn these dynamics.

III

Explorations in Modern Dynamics

In Progress

With a strong foundation built, we shift to broad exploration. We investigate non-inertial reference frames, Koopman operator theory, and Reservoir Computing, treating the final exercises as a creative sandbox.

ch06/pinn_training.py
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.