From falling apples to elliptical orbits
Around 1600, Johannes Kepler, working from Tycho Brahe's careful naked-eye observations of Mars, found three empirical laws: planets move on ellipses with the Sun at a focus; the line from the Sun to a planet sweeps out equal areas in equal times; and the square of the period is proportional to the cube of the orbit's size. Two generations later Isaac Newton showed that all three follow from a single differential equation — his second law with a force varying as the inverse square of distance. It was the first great triumph of mathematical physics, and its methods are still the ones engineers use to put a satellite into orbit over Nairobi or to design a building in Santiago that survives earthquakes.
This lesson develops classical mechanics as mathematics: Newton's laws as ordinary differential equations, conservation laws as the tool that makes them solvable, the Kepler problem solved completely, oscillators from the pendulum to resonance, and Lagrange's reformulation through the principle of stationary action. It assumes ordinary differential equations and multivariable calculus (gradients, the chain rule, line integrals); the orbits are the conic sections of school geometry.
State, force and what stays the same
The state of a particle at an instant is its position and its velocity: knowing where a ball is does not tell you where it will be, but knowing where it is and how it is moving does — once you know the forces. Newton's second law is a second-order ODE, so by the Picard–Lindelöf theorem position and velocity at one instant determine the motion (for Lipschitz forces).
Solving such equations in closed form is usually impossible, but some combinations of position and velocity do not change along the motion — conserved quantities, such as energy and angular momentum. Each one confines the motion to a smaller set and lowers the effective dimension of the problem. For a ball rolling in a valley, conservation of energy alone tells you how high it will climb and how fast it moves at the bottom. For a planet, energy and angular momentum together are enough to find the orbit exactly.
Definitions
A particle of mass has position , velocity , acceleration and momentum .
Definition— Newton's laws
(1) In an inertial frame, a body on which no net force acts moves with constant velocity. (2) : the net force on a particle equals its mass times its acceleration (more generally ). (3) If body 1 exerts a force on body 2, then body 2 exerts on body 1.
Definition— work, kinetic energy and conservative forces
The kinetic energy is . The work done by a force field along a path is the line integral . A force field is conservative if for a function , the potential energy; the total energy is .
Definition— angular momentum and central forces
The angular momentum about the origin is , and the torque of a force is . A force is central if it always points along : with — for example gravity towards a fixed Sun.
Definition— Lagrangian and action
For a system described by generalised coordinates (angles, distances, …), the Lagrangian is , and the action of a path , , is .
The weight of a body is the gravitational force on it, near the Earth's surface, where . Mass is measured in kilograms; weight, a force, in newtons.
Worked examples
Example— A projectile
With constant gravity and no air resistance, and . Integrating twice from launch at the origin — a football kicked from the ground, say — with speed at angle :
Eliminating gives a parabola (Galileo). The projectile lands at , at distance , largest for . The mass does not appear: in a vacuum, all bodies fall alike.
With linear air resistance , the horizontal equation is linear and gives : the range is now bounded however long the flight.
Example— Mass and weight on the Moon
An astronaut of mass kg weighs about N on Earth and about N on the Moon. Her mass — her resistance to acceleration — is the same kg in both places: pushing her sideways from rest to m/s in one second takes the same N horizontal force on the Moon as on Earth.
Example— The harmonic oscillator
A mass on a spring obeys Hooke's law , so , that is with . The solutions are , with period independent of the amplitude. The potential energy is , and is constant.
The harmonic oscillator is universal: near any point where a smooth potential has a strict minimum (), Taylor's theorem gives , so small oscillations have angular frequency — to first approximation, with an error controlled by the cubic remainder.
Conservation laws
Theorem— Theorem (work–energy theorem and conservation of energy)
Along any motion , the change in kinetic energy equals the work done: . If is conservative, the total energy is constant.
Proof
; integrate. If , then by the chain rule , so , and a function with zero derivative on an interval is constant.
∎
In one dimension, energy conservation reduces Newton's equation to a first-order one: gives . The motion is confined to , reverses at turning points where , and between turning points (with ) it is periodic with period
For the pendulum released from rest at angle , this integral is an elliptic integral, — larger than the small-angle value , by about for (see the computation below).
The pendulum's phase plane (θ, θ′)
Closed curves are swings (energy below the top); wavy curves are full rotations; the curves through (±π, 0) separate them. Each curve is a level set of the energy.
x′ = y, y′ = −sin(x)
Click the plane to start a trajectory, or type a start point below.
Trajectories: 4. They are numerical approximations (fourth-order Runge–Kutta), not exact formulas.
Nonlinear system. Equilibria found numerically in this window, classified by their linearisation (Jacobian matrix):
- 1. (−6.283, 0): centre: closed orbits around it (λ = 0 ± 1i)
- 2. (−3.142, 0): saddle (unstable) (λ = −1, 1)
- 3. (0, 0): centre: closed orbits around it (λ = 0 ± 1i)
- 4. (3.142, 0): saddle (unstable) (λ = −1, 1)
- 5. (6.283, 0): centre: closed orbits around it (λ = 0 ± 1i)
A centre of the linearisation is inconclusive for a nonlinear system: the true orbits may close up (as for the pendulum and predator–prey) or spiral slowly.
Theorem— Theorem (conservation of momentum)
For two particles interacting only with each other, with , and , the total momentum is constant, and the centre of mass moves with constant velocity.
Proof
by the third law, and .
∎
The relative position satisfies , i.e. with the reduced mass . So the two-body problem reduces to a one-body problem; for gravity, gives , exactly the problem of one body attracted to a fixed centre of "mass" .
Theorem— Theorem (central forces: angular momentum and planar motion)
Under a central force, the angular momentum is constant. If , the motion stays in the plane through the origin perpendicular to ; if , it stays on a line through the origin.
Proof
, since the cross product of parallel vectors vanishes. For every , , because is perpendicular to ; so lies in the plane . If then at all times (where ), so the direction is constant (its derivative is the component of perpendicular to ) and the motion is radial.
∎
The Kepler problem
Take the plane of motion with polar coordinates , and unit vectors and . Differentiating with and :
The angular momentum has magnitude .
Theorem— Theorem (Kepler's second law)
Under any central force, the radius vector sweeps out area at the constant rate .
Proof
In time the radius sweeps a thin sector of angle and area (precisely: the area swept between angles and is , and we change variables to ). So , constant by the previous theorem.
∎
For a central force , the radial component of Newton's law is . Using to eliminate :
The radial motion is one-dimensional motion in the effective potential ; the term is a "centrifugal barrier" that keeps a body with away from the centre.
The effective potential for gravity (m = k = 1)
An orbit with energy E between the minimum and 0 bounces between two turning radii: a bound orbit. With E ≥ 0 it escapes.
- effective potential
- gravitational potential −k/r
- effective potential: y = −0.5
- gravitational potential −k/r: y = −1
Theorem— Theorem (Kepler's first law: the orbits are conics)
Let with (for gravity, ), and . Then the orbit is
a conic section with a focus at the centre of force: an ellipse if (a circle if ), a parabola if , and a branch of a hyperbola if .
Proof
Binet's equation. Since , we may use as the parameter. Put and write . Then , and . Substituting into , with :
Solving it. This is a harmonic oscillator in with a constant forcing term; its general solution is with constants and . So .
It is a conic. Take . With , , the equation says ; squaring, , i.e. . For this is an ellipse with one focus at the origin, for a parabola, for a hyperbola.
Eccentricity and energy. At the point closest to the centre (perihelion), and , so . Using , this is . Hence , and exactly when .
∎
Theorem— Theorem (Kepler's third law)
For an elliptic orbit with semi-major axis , the period satisfies
Proof
The perihelion and aphelion distances are and , so , , and the semi-minor axis is . By the second law the area is swept at rate , so and
using . For gravity , and the planet's mass cancels.
∎
For two bodies (a planet that is not negligibly light), replace by the reduced mass and by ; Kepler's third law then holds up to the factor , which is for Jupiter. The value , obtained by combining with , shows that the size of an orbit depends only on its energy.
Kepler orbits r = p / (1 + e cos θ)
Slide the eccentricity e from a circle (e = 0) towards a long ellipse; the Sun stays at a focus. At e = 1 the orbit opens into a parabola.
- r = p/(1 + e·cos(θ))
- (0.242, 0.242) · r = 0.342
Damped and driven oscillators
Add friction proportional to velocity: , or with and . The energy now satisfies : it decreases. The characteristic roots give three regimes (see the ODE lesson):
- underdamped (): with — decaying oscillations;
- critically damped (): — the fastest return without oscillating, roughly what a car's shock absorbers aim for;
- overdamped (): a sum of two decaying exponentials.
Theorem— Proposition (forced oscillations and resonance)
For , the equation has the particular solution with
and every solution approaches as .
Proof
Look for a complex solution of : substituting gives . Write with ; then , and since the equation has real coefficients, solves the real equation. Any other solution differs from by a solution of the damped homogeneous equation, which decays like (or faster).
∎
When the damping is small, the amplitude is largest for driving frequencies near the natural frequency : at it is , which grows without bound as . This is resonance — useful in radio tuners and musical instruments, dangerous in machinery and structures.
Resonance curves
Lower the damping and the peak near Ω = ω₀ grows like 1/(2γ/ω₀).
- amplitude A(Ω), in units of F₀/(mω₀²)
- amplitude A(Ω), in units of F₀/(mω₀²): y = 5
Lagrangian mechanics and stationary action
Newton's law needs Cartesian coordinates and forces, including the forces of constraint that keep a bead on its wire or a pendulum bob on its circle. Lagrange (1788) found a formulation in any coordinates, with constraints built in. Its modern form is Hamilton's principle (1834): the motion between times and makes the action stationary among all paths with the same endpoints.
Theorem— Lemma (fundamental lemma of the calculus of variations)
If is continuous on and for every function with , then .
Proof
Suppose at some in the open interval (the case is symmetric, and the endpoints follow by continuity). By continuity on some . Let for and otherwise; it is (it vanishes to third order at ), non-negative, and positive at . Then , a contradiction.
∎
Theorem— Theorem (Euler–Lagrange equations)
Let be , and let be a path such that, for every variation vanishing at and , . Then for each ,
Proof
Differentiating under the integral sign (legitimate since the integrand is in on a compact set) and integrating by parts,
the boundary terms vanishing because . Taking with only the -th component non-zero, the fundamental lemma gives the -th equation.
∎
Example— Three Lagrangians
- A particle in a potential, Cartesian coordinates: . Then and , so the Euler–Lagrange equations are : Newton's law.
- The pendulum, with the angle as coordinate: and , so , i.e. . The tension in the rod never appears.
- A central force in polar coordinates: . The -equation is — conservation of angular momentum, because does not depend on — and the -equation is , the radial equation used above.
Theorem— Proposition (conserved quantities from the Lagrangian)
Along solutions of the Euler–Lagrange equations: (1) if does not depend on (a cyclic coordinate), the conjugate momentum is constant; (2) if does not depend explicitly on , the energy function is constant. When is a quadratic form in the velocities and does not depend on them, .
Proof
(1) is the -th Euler–Lagrange equation. (2) By the chain rule,
which is . If , Euler's theorem on homogeneous functions gives , so .
∎
These are the simplest cases of Noether's theorem (Emmy Noether, 1918): every continuous symmetry of the action gives a conserved quantity — translations give momentum, rotations angular momentum, time translations energy.
Mechanics in Lean
Mathlib has no physics, but it has the calculus to state Newton's law exactly: a motion is a pair with HasDerivAt r (v t) t and HasDerivAt v (a t) t. Each conservation law is then proved as in the lesson: differentiate the conserved quantity, get , and conclude it is constant.
First, uniform gravity — position, velocity and acceleration of a projectile:
/-- A projectile in uniform gravity: the height `y(t) = y₀ + v₀ t - g t²/2` has velocity
`v(t) = v₀ - g t`, whose derivative is the constant acceleration `-g`. -/
theorem projectile (y₀ v₀ g t : ℝ) :
HasDerivAt (fun s => y₀ + v₀ * s - g * s ^ 2 / 2) (v₀ - g * t) t ∧
HasDerivAt (fun s => v₀ - g * s) (-g) t := by
constructor
· have h := (((hasDerivAt_id' t).const_mul v₀).const_add y₀).sub
((hasDerivAt_pow 2 t).const_mul g |>.div_const 2)
convert h using 1
push_cast
ring
· have h := ((hasDerivAt_id' t).const_mul g).const_sub v₀
convert h using 1
ringConservation of energy, in any real inner product space (so in , but also for systems with many particles), for a force given by Mathlib's HasGradientAt. The proof is the human one: .
/-- **Conservation of energy** for a conservative force, in any (real inner product) space.
Suppose the particle of mass `m ≠ 0` moves by Newton's law with force `F = -∇V`: `r' = v` and
`v' = -(1/m) ∇V(r)`. Then the total energy `E = ½ m ⟪v, v⟫ + V(r)` is constant. Proof: by the
product and chain rules, `E' = m ⟪v, v'⟫ + ⟪∇V(r), r'⟫ = -⟪v, ∇V(r)⟫ + ⟪∇V(r), v⟫ = 0`. -/
theorem energy_conservation {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[CompleteSpace E] {m : ℝ} (hm : m ≠ 0) {V : E → ℝ} {gradV : E → E}
(hV : ∀ x, HasGradientAt V (gradV x) x) {r v : ℝ → E}
(hr : ∀ t, HasDerivAt r (v t) t) (hv : ∀ t, HasDerivAt v (-(1 / m) • gradV (r t)) t)
(s t : ℝ) :
m / 2 * inner ℝ (v s) (v s) + V (r s) = m / 2 * inner ℝ (v t) (v t) + V (r t) := by
have hE : ∀ τ, HasDerivAt (fun τ => m / 2 * inner ℝ (v τ) (v τ) + V (r τ)) 0 τ := by
intro τ
have hkin := ((hv τ).inner ℝ (hv τ)).const_mul (m / 2)
have hpot := (hasGradientAt_iff_hasFDerivAt.mp (hV (r τ))).comp_hasDerivAt τ (hr τ)
have h := hkin.add hpot
convert h using 1
· rfl
· simp only [InnerProductSpace.toDual_apply_apply, inner_smul_right, inner_smul_left,
real_inner_comm (gradV (r τ)) (v τ), RCLike.conj_to_real]
field_simp
ring
exact is_const_of_deriv_eq_zero (fun τ => (hE τ).differentiableAt) (fun τ => (hE τ).deriv) s tAngular momentum. The library facts and , then conservation of under any force parallel to (checked coordinate by coordinate), and its consequence that the motion is planar:
/-- The cross product of a vector with itself is zero (Mathlib's `cross_self`). It is why the
term `v × (m v)` drops out of `d/dt (r × m v) = v × m v + r × m v'`. -/
theorem cross_self_zero (v : Fin 3 → ℝ) : v ⨯₃ v = 0 :=
cross_self v/-- **Conservation of angular momentum** under a central force. If `r' = v` and `v' = k(t) r`
(acceleration always parallel to the position vector, as for any central force), then
`L = r × v` has derivative `v × v + r × (k r) = 0`, so it is constant. We check the derivative
coordinate by coordinate (`hasDerivAt_pi`). -/
theorem angular_momentum_conserved {r v : ℝ → Fin 3 → ℝ} {k : ℝ → ℝ}
(hr : ∀ t, HasDerivAt r (v t) t) (hv : ∀ t, HasDerivAt v (k t • r t) t) (s t : ℝ) :
r s ⨯₃ v s = r t ⨯₃ v t := by
have hL : ∀ τ, HasDerivAt (fun τ => r τ ⨯₃ v τ) 0 τ := by
intro τ
rw [hasDerivAt_pi]
have hri : ∀ i, HasDerivAt (fun τ => r τ i) (v τ i) τ := hasDerivAt_pi.mp (hr τ)
have hvi : ∀ i, HasDerivAt (fun τ => v τ i) (k τ * r τ i) τ := by
intro i
simpa using hasDerivAt_pi.mp (hv τ) i
intro i
fin_cases i
· have h := ((hri 1).mul (hvi 2)).sub ((hri 2).mul (hvi 1))
convert h using 1
· funext τ; simp [cross_apply]
· simp; ring
· have h := ((hri 2).mul (hvi 0)).sub ((hri 0).mul (hvi 2))
convert h using 1
· funext τ; simp [cross_apply]
· simp; ring
· have h := ((hri 0).mul (hvi 1)).sub ((hri 1).mul (hvi 0))
convert h using 1
· funext τ; simp [cross_apply]
· simp; ring
exact is_const_of_deriv_eq_zero (fun τ => (hL τ).differentiableAt) (fun τ => (hL τ).deriv) s t/-- A vector is perpendicular to its cross product with any other vector:
`r · (r × v) = 0` (Mathlib's `dot_self_cross`). -/
theorem dot_self_cross_zero (r v : Fin 3 → ℝ) : r ⬝ᵥ (r ⨯₃ v) = 0 :=
dot_self_cross r v/-- **Central-force motion is planar.** Under the hypotheses of `angular_momentum_conserved`,
the position `r(t)` is perpendicular to the constant vector `L = r(0) × v(0)` at every time,
so (when `L ≠ 0`) the particle stays in the plane through the origin perpendicular to `L`. -/
theorem motion_in_plane {r v : ℝ → Fin 3 → ℝ} {k : ℝ → ℝ}
(hr : ∀ t, HasDerivAt r (v t) t) (hv : ∀ t, HasDerivAt v (k t • r t) t) (t : ℝ) :
r t ⬝ᵥ (r 0 ⨯₃ v 0) = 0 := by
rw [angular_momentum_conserved hr hv 0 t]
exact dot_self_cross_zero (r t) (v t)Kepler's first law, in two formal pieces: the conic solves Binet's equation , and a curve is the conic in Cartesian coordinates:
/-- The orbit equation. With `u = 1/r` as a function of the polar angle `θ`, the inverse-square
law gives Binet's equation `u'' + u = 1/p`. Its solutions `u(θ) = (1 + e cos θ)/p` (for constants
`e`, `p` with `p ≠ 0`) indeed satisfy it: `u' = -(e/p) sin θ`, `u'' = -(e/p) cos θ`. -/
theorem binet_conic (e p θ : ℝ) :
HasDerivAt (fun φ => (1 + e * cos φ) / p) (-(e / p) * sin θ) θ ∧
HasDerivAt (fun φ => -(e / p) * sin φ) (1 / p - (1 + e * cos θ) / p) θ := by
constructor
· have h := (((hasDerivAt_cos θ).const_mul e).const_add 1).div_const p
convert h using 1
ring
· have h := (hasDerivAt_sin θ).const_mul (-(e / p))
convert h using 1
ring/-- **Kepler's first law, the geometric step.** If a point at distance `r ≥ 0` from the origin and
polar angle `θ` lies on the orbit `r (1 + e cos θ) = p`, then its Cartesian coordinates
`x = r cos θ`, `y = r sin θ` satisfy `(1 - e²) x² + 2 p e x + y² = p²`: a conic with a focus at
the origin — an ellipse if `0 ≤ e < 1` (a circle if `e = 0`), a parabola if `e = 1`, a hyperbola
branch if `e > 1`. Proof: `r = p - e x`, and `x² + y² = r²`. -/
theorem orbit_is_conic {r θ e p : ℝ} (horbit : r * (1 + e * cos θ) = p) :
(1 - e ^ 2) * (r * cos θ) ^ 2 + 2 * p * e * (r * cos θ) + (r * sin θ) ^ 2 = p ^ 2 := by
have hr : r = p - e * (r * cos θ) := by linarith
have hpyth : (r * cos θ) ^ 2 + (r * sin θ) ^ 2 = r ^ 2 := by
have := sin_sq_add_cos_sq θ
calc (r * cos θ) ^ 2 + (r * sin θ) ^ 2 = r ^ 2 * (sin θ ^ 2 + cos θ ^ 2) := by ring
_ = r ^ 2 := by rw [this, mul_one]
calc (1 - e ^ 2) * (r * cos θ) ^ 2 + 2 * p * e * (r * cos θ) + (r * sin θ) ^ 2
= ((r * cos θ) ^ 2 + (r * sin θ) ^ 2) - (e * (r * cos θ)) ^ 2
+ 2 * p * (e * (r * cos θ)) := by ring
_ = r ^ 2 - (e * (r * cos θ)) ^ 2 + 2 * p * (e * (r * cos θ)) := by rw [hpyth]
_ = (p - e * (r * cos θ)) ^ 2 - (e * (r * cos θ)) ^ 2 + 2 * p * (e * (r * cos θ)) := by
rw [← hr]
_ = p ^ 2 := by ringThe two algebraic computations behind the relation between energy and eccentricity, and behind the third law (the inputs — the perihelion distance, the area of the ellipse and the areal velocity — are taken from the human proofs):
/-- **Energy determines the shape.** At perihelion the radial velocity is `0` and
`r = p/(1 + e)`, so the energy is `E = L²/(2 m r²) - k/r`. With `p = L²/(m k)` this equals
`k (e² - 1)/(2p)`: hence `e < 1` (an ellipse) exactly when `E < 0`. -/
theorem eccentricity_energy {m k L e : ℝ} (hm : 0 < m) (hk : 0 < k) (hL : L ≠ 0)
(he : 0 ≤ e) :
let p := L ^ 2 / (m * k)
let r := p / (1 + e)
L ^ 2 / (2 * m * r ^ 2) - k / r = k * (e ^ 2 - 1) / (2 * p) := by
intro p r
have hp : p ≠ 0 := by positivity
have h1e : 1 + e ≠ 0 := by positivity
have hr : r ≠ 0 := div_ne_zero hp h1e
have hpL : L ^ 2 = p * (m * k) := by
simp only [p]; field_simp
simp only [r]
rw [hpL]
field_simp
ring/-- **Kepler's third law, the algebraic step.** An ellipse with semi-latus rectum
`p = L²/(m k)` and semi-major axis `a` has semi-minor axis `b` with `b² = p a` (since
`a = p/(1 - e²)` and `b = a √(1 - e²)`). Its area `πab` is swept at the constant rate `L/(2m)`,
so the period is `T = πab / (L/(2m))`. Then `T² = 4π² m a³ / k`. -/
theorem kepler_third_law {m k L a b T : ℝ} (hm : 0 < m) (hk : 0 < k) (hL : L ≠ 0)
(hb : b ^ 2 = L ^ 2 / (m * k) * a) (hT : T = π * a * b / (L / (2 * m))) :
T ^ 2 = 4 * π ^ 2 * m * a ^ 3 / k := by
have hm0 : m ≠ 0 := hm.ne'
have hk0 : k ≠ 0 := hk.ne'
rw [hT]
calc (π * a * b / (L / (2 * m))) ^ 2 = 4 * π ^ 2 * m ^ 2 * a ^ 2 * b ^ 2 / L ^ 2 := by
field_simp
ring
_ = 4 * π ^ 2 * m * a ^ 3 / k := by
rw [hb]
field_simpThe damped oscillator: solves :
/-- The underdamped oscillator `x'' + 2γ x' + ω₀² x = 0` with `ω₀² = γ² + ω²` is solved by
`x(t) = e^{-γt} cos(ωt)`: we compute its velocity `v` and check `v' = -2γ v - ω₀² x`. -/
theorem damped_oscillator (γ ω t : ℝ) :
HasDerivAt (fun s => exp (-γ * s) * cos (ω * s))
(exp (-γ * t) * (-γ * cos (ω * t) - ω * sin (ω * t))) t ∧
HasDerivAt (fun s => exp (-γ * s) * (-γ * cos (ω * s) - ω * sin (ω * s)))
(-2 * γ * (exp (-γ * t) * (-γ * cos (ω * t) - ω * sin (ω * t)))
- (γ ^ 2 + ω ^ 2) * (exp (-γ * t) * cos (ω * t))) t := by
have hl : ∀ c : ℝ, HasDerivAt (fun s => c * s) c t := fun c => by
simpa using (hasDerivAt_id' t).const_mul c
have he := (hl (-γ)).exp
constructor
· have h := he.mul (hl ω).cos
convert h using 1
ring
· have h := he.mul ((((hl ω).cos).const_mul (-γ)).sub (((hl ω).sin).const_mul ω))
convert h using 1
simp only [Pi.sub_apply]
ringWhat is and is not formalised. Independently proved: the projectile, energy conservation for conservative forces, conservation of angular momentum and planarity under central forces, the Binet solution, the conic identity, the algebra of the energy–eccentricity relation and of the third law, and the damped oscillator. Cited from Mathlib: the two cross-product identities. Not formalised: the derivation of Binet's equation from Newton's law (the change of parameter from to ), the area of an ellipse and the areal-velocity argument of Kepler's second law, the reduction of the two-body problem, the resonance formula, and the Euler–Lagrange equations, whose proof needs differentiation under the integral sign and the fundamental lemma — all within reach of Mathlib, but not done here.
Simulating orbits and pendulums
Integrating Newton's equations numerically is how real orbits are computed. But the choice of method matters: the velocity Verlet (leapfrog) method, used in molecular dynamics and celestial mechanics, respects the geometry of mechanics — it is symplectic and conserves angular momentum exactly for central forces — while the explicit Euler method spirals outwards and gains energy. The first experiment checks Kepler's predictions (eccentricity, perihelion, aphelion and period) against a simulation:
"""Kepler's laws from Newton's law, numerically - and why the integrator matters.
We integrate r'' = -r / |r|^3 (units with GM = 1) from r(0) = (1, 0),
v(0) = (0, 1.2). Theory: energy E = -0.28, angular momentum L = 1.2, an
ellipse with eccentricity e = sqrt(1 + 2 E L^2) = 0.44, semi-major axis
a = -1/(2E), perihelion a(1 - e) = 1 and period 2 pi a^(3/2). The velocity
Verlet (leapfrog) method conserves L exactly (up to rounding) and keeps E
within a small bounded band; explicit Euler spirals outwards, gaining energy.
Runs unchanged in the browser (Pyodide) using only the standard library.
"""
import math
def accel(x, y):
"""Inverse-square attraction towards the origin, GM = 1."""
r3 = (x * x + y * y) ** 1.5
return -x / r3, -y / r3
def energy(x, y, vx, vy):
"""Energy per unit mass: kinetic plus potential -1/r."""
return 0.5 * (vx * vx + vy * vy) - 1 / math.hypot(x, y)
def ang_mom(x, y, vx, vy):
"""Angular momentum per unit mass, x vy - y vx."""
return x * vy - y * vx
def verlet_step(state, h):
"""One velocity Verlet (leapfrog) step."""
x, y, vx, vy = state
ax, ay = accel(x, y)
vx, vy = vx + h / 2 * ax, vy + h / 2 * ay
x, y = x + h * vx, y + h * vy
ax, ay = accel(x, y)
return x, y, vx + h / 2 * ax, vy + h / 2 * ay
def euler_step(state, h):
"""One explicit Euler step."""
x, y, vx, vy = state
ax, ay = accel(x, y)
return x + h * vx, y + h * vy, vx + h * ax, vy + h * ay
def run(step, state, h, n):
"""Apply n steps; return the list of states (including the initial one)."""
states = [state]
for _ in range(n):
state = step(state, h)
states.append(state)
return states
def first_return_time(states, h):
"""Time of the first upward crossing of y = 0 with x > 0 after the start."""
for i in range(1, len(states)):
(x0, y0, _, _), (x1, y1, _, _) = states[i - 1], states[i]
if i > 1 and y0 < 0 <= y1 and x1 > 0:
return (i - 1 + (-y0) / (y1 - y0)) * h
return None
def kepler_predictions(state):
"""Energy, angular momentum, eccentricity, semi-major axis and period."""
E = energy(*state)
L = ang_mom(*state)
e = math.sqrt(1 + 2 * E * L * L)
a = -1 / (2 * E)
return E, L, e, a, 2 * math.pi * a**1.5
def main():
start = (1.0, 0.0, 0.0, 1.2)
E, L, e, a, T = kepler_predictions(start)
print(f"Theory: E = {E:.4f}, L = {L:.4f}, e = {e:.4f}, a = {a:.4f}")
print(f" perihelion {a * (1 - e):.4f}, aphelion {a * (1 + e):.4f},"
f" period {T:.4f}")
h, n = 0.001, 60000 # about four orbits
for name, step in [("Verlet", verlet_step), ("Euler", euler_step)]:
states = run(step, start, h, n)
radii = [math.hypot(s[0], s[1]) for s in states]
energies = [energy(*s) for s in states]
momenta = [ang_mom(*s) for s in states]
print(f"{name} (h = {h}, {n} steps):")
e_drift = max(abs(en - E) for en in energies)
print(f" max |E(t) - E(0)| = {e_drift:.2e}")
drift = max(abs(m - L) for m in momenta)
print(f" max |L(t) - L(0)| = {drift:.2e}")
print(f" r ranges over [{min(radii):.4f}, {max(radii):.4f}]")
ret = first_return_time(states, h)
shown = f"{ret:.4f}" if ret else "none"
print(f" first return to the x-axis at t = {shown}")
print()
print("Epistemic status: numerical integration of one orbit. Verlet keeps L")
print("constant to rounding error and E in a narrow band, matching Kepler's")
print("predictions to several digits; Euler drifts outwards. The laws")
print("themselves are theorems proved in the lesson, not consequences of")
print("this simulation.")
if __name__ == "__main__":
main()The second compares three answers to "how long does a pendulum take to swing?": the small-angle law, the exact formula from energy conservation (an elliptic integral, which Gauss's arithmetic–geometric mean evaluates with astonishing speed), and a simulation.
"""The period of a pendulum: small-angle law, exact formula and simulation.
For theta'' = -(g/l) sin theta released from rest at amplitude theta0,
conservation of energy gives the exact period
T = 4 sqrt(l/g) K(k), k = sin(theta0 / 2),
where K is the complete elliptic integral of the first kind. Gauss's
arithmetic-geometric mean computes it: K(k) = pi / (2 AGM(1, sqrt(1 - k^2))).
We compare this with the small-angle period 2 pi sqrt(l/g), with the series
T0 (1 + theta0^2/16 + 11 theta0^4/3072), and with a numerical simulation.
Runs unchanged in the browser (Pyodide) using only the standard library.
"""
import math
def agm(a, b, tol=1e-15):
"""Arithmetic-geometric mean of positive a and b."""
if a <= 0 or b <= 0:
raise ValueError("AGM needs positive numbers")
while abs(a - b) > tol * a:
a, b = (a + b) / 2, math.sqrt(a * b)
return a
def exact_period(theta0, omega0=1.0):
"""Exact period 2 pi / (omega0 AGM(1, cos(theta0/2))), for 0 <= theta0 < pi."""
if not 0 <= theta0 < math.pi:
raise ValueError("amplitude must lie in [0, pi)")
return 2 * math.pi / (omega0 * agm(1.0, math.cos(theta0 / 2)))
def series_period(theta0, omega0=1.0):
"""Two-term series T0 (1 + theta0^2/16 + 11 theta0^4/3072)."""
t0 = 2 * math.pi / omega0
return t0 * (1 + theta0**2 / 16 + 11 * theta0**4 / 3072)
def simulated_period(theta0, h=1e-3):
"""Period from velocity Verlet: four times the time to first reach theta = 0."""
theta, omega, t = theta0, 0.0, 0.0
while True:
a = -math.sin(theta)
omega_half = omega + h / 2 * a
new_theta = theta + h * omega_half
omega = omega_half + h / 2 * (-math.sin(new_theta))
if new_theta <= 0 < theta:
frac = theta / (theta - new_theta)
return 4 * (t + frac * h)
theta, t = new_theta, t + h
def main():
print("Pendulum with g/l = 1 (small-angle period 2 pi = 6.283185)")
print("amplitude exact (AGM) series simulated exact / 2pi")
for degrees in [5, 30, 60, 90, 120, 150, 170]:
theta0 = math.radians(degrees)
ex = exact_period(theta0)
se = series_period(theta0)
si = simulated_period(theta0)
ratio = ex / (2 * math.pi)
print(f" {degrees:3d} deg {ex:9.6f} {se:9.6f} {si:9.6f}"
f" {ratio:8.4f}")
print("Small swings are almost isochronous (Galileo's observation), but a")
print("swing of 90 degrees takes 18% longer, and the period grows without")
print("bound as the amplitude approaches 180 degrees (the inverted pendulum")
print("is an unstable equilibrium).")
print()
print("Epistemic status: the exact column evaluates a proved formula")
print("(energy conservation plus Gauss's AGM identity for elliptic")
print("integrals) in floating point; the simulated column is numerical")
print("evidence that agrees with it to about six digits.")
if __name__ == "__main__":
main()Both are numerical: the exact period formula is a theorem evaluated in floating point, and the simulations are evidence that agrees with the theory to many digits — not a substitute for the proofs above.
Exercises
1. Classical mechanics
Warm-upHumanA football is kicked from the ground at , at above the horizontal. Ignoring air resistance and taking , how far away (in metres) does it land?
2. Classical mechanics
Warm-upHumanAn astronaut has mass kg. On the Moon (), which statement is correct?
3. Classical mechanics
Warm-upHumanA hockey puck slides in a straight line at constant speed across perfectly frictionless ice. What is the net horizontal force on it?
4. Classical mechanics
CoreHumanA mass of kg hangs on a spring of stiffness . What is the angular frequency of its small oscillations, in rad/s?
5. Classical mechanics
CoreHumanAn asteroid orbits the Sun on an ellipse with semi-major axis AU (Earth's is AU, with period year). Using Kepler's third law, what is its period in years?
6. Classical mechanics
CoreHumanA particle moves under a central force (always pointing along the line to the origin). Which of the following are guaranteed to be constant? (Select all that apply.)
7. Classical mechanics
StretchHumanA comet moves under the Sun's gravity with total energy and angular momentum . What is the shape of its orbit?
8. Classical mechanics
StretchHumanFor a particle in the plane under a central potential, . What is the Euler–Lagrange equation for ?
9. Classical mechanics
StretchFormalIn Lean, r v : ℝ → Fin 3 → ℝ describe a motion with hr : ∀ t, HasDerivAt r (v t) t. Which extra hypothesis expresses “the force is central”, so that r t ⨯₃ v t is constant?
10. Classical mechanics
StretchComputationalWrite verlet(x0, v0, h, n, accel) implementing the velocity Verlet method for : each step does , then , then . Return the final (x, v). Test it on the harmonic oscillator : after one period the state should return to its start, and the energy should stay almost constant.
Common misconceptions
Misconception
"A force is needed to keep an object moving." Newton's first law says the opposite: with no net force, velocity stays constant. Everyday experience misleads because friction and air resistance are forces that slow things down; a hockey puck on smooth ice, or a space probe coasting between planets, keeps moving with no push. A force is needed to change velocity — to speed up, slow down or turn.
Misconception
"Mass and weight are the same thing." Mass (, in kg) measures resistance to acceleration and is the same everywhere; weight (, in newtons) is the gravitational force and depends on where you are — about one sixth as much on the Moon. Bathroom scales measure a force and are calibrated to display kilograms for Earth's . (That all bodies fall with the same acceleration, because gravitational and inertial mass are equal, is a deep experimental fact — the starting point of general relativity.)
Misconception
"A planet in orbit feels an outward centrifugal force that balances gravity." In an inertial frame the only force on the planet is gravity, which points inwards and supplies the centripetal acceleration of circular motion. "Centrifugal force" is a fictitious force that appears only when one describes the motion in a rotating frame of reference.
Misconception
"Nature minimises the action." The principle is that the action is stationary. For short time intervals the true path does minimise it, but not in general: for a harmonic oscillator of period , the true path is not a minimum among paths over a time interval longer than (the first conjugate point, in Jacobi's theory).
Misconception
"Heavier objects fall faster." Without air resistance, all bodies near the Earth fall with the same acceleration : the mass cancels in . With air resistance the drag force depends on shape and speed, which is why a feather and a hammer fall differently on Earth — and identically on the Moon, as the Apollo 15 astronauts showed in 1971.
Many ways of seeing
Geometry— Configuration spaces, phase space and the hidden symmetry of Kepler orbits
The positions of a mechanical system form a configuration space, typically a manifold: a circle for a pendulum, a torus for a double pendulum, the rotation group for a rigid body. Positions and momenta together form phase space, the cotangent bundle , which carries a canonical symplectic form; Hamilton's equations , say that the motion is the flow of the vector field determined by the energy and this form (see symplectic geometry). The Kepler problem has a striking geometric feature: besides , the Laplace–Runge–Lenz vector is conserved. It points to the perihelion and has length , and gives the conic equation in one line. Its conservation reflects a hidden four-dimensional rotational symmetry of the bound orbits (exploited by Fock in 1935 for the hydrogen atom) and explains why the orbits close.
Topology— Cylinders, tori and stability
The pendulum's phase space is a cylinder : the angle is periodic, the angular velocity is not. Its energy levels are circles (swings), curves winding round the cylinder (rotations), and two separatrices through the unstable top position. More generally, the Liouville–Arnold theorem says that if a system with degrees of freedom has independent conserved quantities in involution, every compact connected level set is an -dimensional torus, on which the motion is quasi-periodic. Do these tori survive small perturbations, such as the pull of Jupiter on Earth? The KAM theorem (Kolmogorov 1954, Arnold 1963, Moser 1962) says that, under non-degeneracy conditions, most of them do — the ones whose frequencies are "sufficiently irrational" — while resonant tori break up, giving chaotic zones. Topology and number theory meet in the stability of the solar system. See dynamical systems.
Algebra— Poisson brackets and the Lie algebra of conserved quantities
For functions on phase space, the Poisson bracket makes them a Lie algebra, and Hamilton's equations become . So is conserved exactly when , and conserved quantities form a Lie subalgebra. The components of angular momentum satisfy and its cyclic permutations — the Lie algebra of the rotation group — and, for negative energies, together with a rescaled Runge–Lenz vector spans . Replacing Poisson brackets by commutators of operators is Dirac's route from classical to quantum mechanics, and Noether's theorem becomes a statement about Lie group actions (the moment map).
Analysis— The calculus of variations
The Euler–Lagrange equations are the first-order condition of an optimisation problem in an infinite-dimensional space of paths. The same mathematics finds the brachistochrone (the curve of fastest descent, a cycloid — Johann Bernoulli's challenge of 1696), geodesics on surfaces, minimal surfaces such as soap films, and the shapes of hanging chains. Second-order conditions are subtler than in finite dimensions: the Legendre condition and the absence of conjugate points (Jacobi) are what make a stationary path a local minimum. Proving that minimisers exist — the "direct method", using compactness in function spaces — became a major theme of twentieth-century analysis, motivated by Hilbert's 20th problem.
Probability— Phase-space volume and statistical mechanics
Liouville's theorem: the flow of Hamilton's equations preserves volume in phase space (the vector field has divergence ). For a gas of molecules we cannot follow trajectories, but we can ask how a probability distribution on phase space evolves — and Liouville's theorem says the uniform distribution on an energy level (the microcanonical ensemble) is invariant. Boltzmann's hope that time averages equal such ensemble averages (the ergodic hypothesis) led to ergodic theory. Volume preservation alone already gives the Poincaré recurrence theorem: for a system confined to a bounded region of phase space, almost every initial state is revisited arbitrarily closely, again and again.
Physics— Why orbits close, and where Newton is not enough
Bertrand's theorem (1873): among central forces , only the inverse-square law and Hooke's law have the property that every bounded orbit is closed. For any other law, orbits precess. Mercury's perihelion does precess, by about per century relative to the distant stars. About of this is explained by the pull of the other planets, but per century remained unexplained by Newtonian mechanics until Einstein's general relativity in 1915 (see relativity). Classical mechanics also fails at small scales, where quantum mechanics replaces trajectories by wave functions; yet the Lagrangian and Hamiltonian formalisms developed here survive both revolutions, in Feynman's sum over paths and in the Hamiltonian operator.
History and global context
- Before Newton. The Mohist Canon (China, around the 4th–3rd centuries BCE) contains statements about force and motion that some historians read as anticipating inertia. Aristotle held that motion requires a continuing cause; John Philoponus in 6th-century Alexandria and Ibn Sīnā (Avicenna) in 11th-century Persia criticised this with theories of an "impetus" imparted to a moving body, developed further by Jean Buridan in 14th-century Paris. Galileo Galilei established the laws of falling bodies and the parabolic path of projectiles (Two New Sciences, 1638).
- Kepler. Johannes Kepler published his first two laws in Astronomia nova (1609) and the third in Harmonices mundi (1619), working from Tycho Brahe's observations. Christiaan Huygens built the pendulum clock (1656) and found the formula for centripetal acceleration (Horologium oscillatorium, 1673).
- Newton. Isaac Newton's Philosophiæ Naturalis Principia Mathematica (1687) stated the laws of motion and universal gravitation and derived Kepler's laws, largely in geometric language. Émilie du Châtelet's French translation of the Principia with her commentary (published posthumously in 1756 and 1759) remains the standard French edition, and her advocacy of vis viva (kinetic energy) helped shape the concept of energy.
- Analytical mechanics. Leonhard Euler wrote Newton's law as differential equations in Cartesian components (1750s) and derived the equations of rigid-body motion. Jean le Rond d'Alembert stated his principle of virtual work for dynamics (1743). Joseph-Louis Lagrange's Mécanique analytique (1788) contained no figures, by design. William Rowan Hamilton (1834–35) reformulated mechanics with his principle and canonical equations, developed further by Carl Jacobi.
- Symmetry and chaos. Emmy Noether proved her theorem connecting symmetries and conservation laws (1918). Henri Poincaré's study of the three-body problem (1890) revealed chaotic motion, and Andrey Kolmogorov, Vladimir Arnold and Jürgen Moser established the KAM theory of stability (1954–63).
Further reading
- John R. Taylor, Classical Mechanics (2005) — a clear undergraduate text covering everything in this lesson, with Lagrangian mechanics and chaos.
- Vladimir I. Arnold, Mathematical Methods of Classical Mechanics (1974; English 1978, 2nd edition 1989) — the classic mathematical treatment: variational principles, manifolds, symplectic geometry.
- Lev D. Landau and Evgeny M. Lifshitz, Mechanics (1960; 3rd edition 1976) — concise, starting from the principle of least action.
- Herbert Goldstein, Classical Mechanics (1950; 3rd edition with Poole and Safko, 2002).
- Daniel Kleppner and Robert Kolenkow, An Introduction to Mechanics (1973; 2nd edition 2014) — Newtonian mechanics in depth.
- Richard P. Feynman, Robert B. Leighton and Matthew Sands, The Feynman Lectures on Physics, Volume I (1963), and the chapter on the principle of least action in Volume II.
Next in the Lumenary: dynamical systems, smooth manifolds, symplectic geometry, relativity and quantum mechanics.