Finding the Fastest Path Under Gravity
The brachistochrone problem is one of the most famous problems in the calculus of variations. It asks: what is the shape of the curve down which a bead sliding from rest and accelerated by gravity will slip (without friction) from one point to another in the least time?
Surprisingly, the answer is not a straight line, but a cycloid - the curve traced by a point on the rim of a circle as it rolls along a straight line.
Mathematical Formulation
Given two points $A(0, 0)$ and $B(x_1, y_1)$ where $y_1 < 0$ (B is below A), we want to find the curve $y(x)$ that minimizes the travel time.
The time functional is:
$$T = \int_0^{x_1} \frac{\sqrt{1 + (y’)^2}}{\sqrt{2gy}} dx$$
Using the Euler-Lagrange equation, the solution is a cycloid parametrized as:
$$x(\theta) = r(\theta - \sin\theta)$$
$$y(\theta) = -r(1 - \cos\theta)$$
where $r$ is determined by the boundary condition at point B.
Specific Example Problem
Let’s solve a concrete example: A bead slides from point A(0, 0) to point B(2, -1) under gravity ($g = 9.8 , \text{m/s}^2$). We’ll compare three paths:
- Brachistochrone (Cycloid) - the optimal curve
- Straight line - the shortest distance
- Parabolic path - a smooth alternative
Python Implementation
1 | import numpy as np |
Code Explanation
1. Cycloid Parameter Calculation
The function find_cycloid_parameter() uses numerical root-finding to determine the radius $r$ and endpoint angle $\theta_{max}$ of the cycloid that passes through point B. The cycloid equations are:
- $x = r(\theta - \sin\theta)$
- $y = -r(1 - \cos\theta)$
2. Path Generation
Three paths are generated:
- Cycloid: Parametrically using the calculated $r$ and $\theta$
- Straight line: Linear interpolation between A and B
- Parabola: A simple quadratic curve for comparison
3. Travel Time Calculation
The calculate_travel_time() function uses the principle of energy conservation. At any height $y$, the velocity is:
$$v = \sqrt{2g|y|}$$
The time for each segment is $\Delta t = \Delta s / v_{avg}$, where $\Delta s$ is the arc length.
4. Visualization Components
- Plot 1: Compares the three path shapes
- Plot 2: Shows velocity profiles (the cycloid accelerates faster initially)
- Plot 3: Bar chart of travel times
- Plot 4: Demonstrates cycloid generation by a rolling circle
- Plot 5: Compares path lengths (shortest ≠ fastest!)
- Plot 6: 3D visualization showing position evolving with time
5. Performance Metrics
The code calculates and compares:
- Travel time for each path
- Path length
- Velocity profiles
- Percentage differences
Results

====================================================================== BRACHISTOCHRONE PROBLEM SOLUTION ====================================================================== Boundary Conditions: Start point A: (0.0, 0.0) End point B: (2.0, -1.0) Gravity: g = 9.8 m/s² Cycloid Parameters: Radius r = 0.517200 m Maximum angle θ_max = 3.508369 rad = 201.01° Path Type Time (s) Length (m) Time Diff (%) ---------------------------------------------------------------------- Brachistochrone 0.805323 2.446069 0.00% (optimal) Straight Line 0.996476 2.236068 +23.74% Parabola 3.509062 2.295587 +335.73% ====================================================================== Key Insight: The brachistochrone is 23.74% faster than the straight line, even though it's 9.39% longer! ======================================================================
Physical Interpretation
The brachistochrone demonstrates a counterintuitive principle: the fastest path is not the shortest path. The cycloid dips down more steeply at the beginning, allowing the bead to gain velocity quickly. Even though this makes the path longer, the increased velocity more than compensates for the extra distance.
This problem has applications in:
- Physics (particle trajectories)
- Engineering (optimal ramp design)
- Economics (optimal control theory)
- Computer graphics (motion planning)
The cycloid curve appears naturally in many other contexts, including the tautochrone problem (where all particles reach the bottom in the same time, regardless of starting position) and in the design of gear teeth.