03. Fastest descent
Release a ball from rest on a frictionless track. What shape reaches a point 1 m horizontally away fastest? A straight line is shortest, but it is not fastest. Johann Bernoulli posed this classical problem in 1696.
| Item | Definition |
|---|---|
| States | Horizontal position , depth , speed |
| Control | Track angle , measured from downward vertical |
| Objective | Minimize arrival time |
| Phases | One phase, 20 nodes, free final time |
| New concepts | Nonlinear dynamics, inequality constraints, a free terminal depth, analytic comparison |
Situation
Section titled “Situation”Rather than searching directly for a track, choose the ball’s direction at each instant. A steep descent builds speed but makes little horizontal progress; a shallow track advances horizontally but accelerates slowly. The fastest path balances these effects by descending steeply first, then turning horizontally.
Only terminal horizontal position is fixed. Depth is free, so the target is a vertical line. Gravity and horizontal distance are both set to 1.
Formulation
Section titled “Formulation”Dynamics
Section titled “Dynamics”Depth is positive downward. Angle points down, and is horizontal.
The first two equations resolve velocity into components. Only the component of gravity along the track accelerates the ball. Since , energy is conserved:
Boundary conditions
Section titled “Boundary conditions”Terminal depth and speed are left to optimization.
Constraints
Section titled “Constraints”The depth inequality excludes the initial node, already fixed by an equality. The angle condition restricts the intended forward-moving solution, and the time bound prevents a degenerate duration. Inequalities are written as nonnegative residuals.
Objective and parameters
Section titled “Objective and parameters”| Symbol | Parameter | Value |
|---|---|---|
PARAMETERS["g"] | 1 m/s² | |
PARAMETERS["l"] | 1 m |
Initial guess
Section titled “Initial guess”Use time 0 to 2, horizontal position linear from 0 to 1, depth linear from 0 to , and constant direction . Speed starts from zero at all nodes. The guess is not dynamically consistent; optimization corrects it.
Results
Section titled “Results”

- Arrival time: 1.772454 s, agreeing to about seven digits with 1.772454 s.
- The straight track takes 2.101 s. The longer cycloid is about 16% faster.
- Final depth: 0.6365 m, versus 0.6366 m; final speed: 1.128 m/s.
- Direction changes nearly linearly from downward to horizontal: 90.0° at the end.
Explanation
Section titled “Explanation”The cycloid
Section titled “The cycloid”The fastest descent curve is a cycloid, traced by a point on a circle rolling beneath a horizontal ceiling:
It points down at and becomes horizontal at its deepest point, . An optical analogy explains the shape: Snell’s law for a minimum-time path requires to remain constant. Since , the required curve has constant, which gives the cycloid.
Why finish horizontally?
Section titled “Why finish horizontally?”Terminal depth is free, so a downward velocity component at arrival contributes nothing to reaching the target line sooner. The best endpoint directs all speed horizontally. Thus and
For , . Along the cycloid, and grows linearly with time, so the angle history is a straight line.
Numerical accuracy
Section titled “Numerical accuracy”The dynamics are nonlinear because of trigonometric terms and products of states and controls. The smooth solution nevertheless gives about seven-digit agreement with 20 nodes (convergence plot).
Try it
Section titled “Try it”- Set
lto 2: duration becomes s and final depth m. - Set
gto 4: the track is unchanged, but duration halves to about 0.886 s. - Reduce 20 nodes to 8 or 7 and compare errors (roughly and ). With 5 or 6 nodes, success can be reported despite errors exceeding 0.2 s. Solver success and accuracy are different checks.
uv run python examples/03_brachistochrone.py