05. Fastest descent from Tokyo to Osaka
Dig a tunnel from Tokyo to Osaka and let a frictionless vehicle travel under gravity alone. It accelerates downhill and slows uphill, arriving at rest. What tunnel shape gives the shortest journey?
| Item | Definition |
|---|---|
| States | Horizontal distance , depth , speed |
| Control | Tunnel angle from downward vertical |
| Objective | Minimize |
| Phases | One phase, 30 nodes, free final time |
| New concepts | Physical units and variable scaling with set_unit_* |
Situation
Section titled “Situation”This thought experiment extends Example 03 to a horizontal distance of 600 km. The endpoints are at the same height, so conservation of energy gives zero arrival speed. We simplify the Earth to a flat surface with constant gravity 9.8 m/s², neglecting curvature, changing gravity at depth, friction, and drag.
Distances are hundreds of thousands of meters, time hundreds of seconds, and angles around one radian. These different magnitudes make scaling essential.
Formulation
Section titled “Formulation”Dynamics
Section titled “Dynamics”Depth is positive downward; is horizontal, and larger angles climb:
Gravity’s component along the tunnel changes speed. Energy gives .
Boundary conditions
Section titled “Boundary conditions”The vehicle starts at rest at the surface in Tokyo and reaches the surface in Osaka, km away.
Constraints and objective
Section titled “Constraints and objective”The trajectory stays between the cities, below ground, and does not reverse horizontally. These bounds restrict the search to the intended region.
Parameters
Section titled “Parameters”| Symbol | Parameter | Value |
|---|---|---|
PARAMETERS["g"] | 9.8 m/s² | |
PARAMETERS["l"] | 600 000 m | |
PARAMETERS["h"], guessed maximum depth | 300 000 m |
Scaling
Section titled “Scaling”| Variable | Unit | Approximate internal range |
|---|---|---|
| 300 000 m | 0–2 | |
| 100 000 m | 0–1.9 | |
| 3000 m/s | 0–0.65 | |
| 1 rad | 0–3.1 | |
| 100 s | 0–6.2 |
The optimizer uses values divided by these units. Equations, conditions, and results remain in physical units. Scaling changes numerical behavior without changing the mathematical answer (scaling). The velocity unit equals distance unit divided by time unit to balance the dynamics.
Initial guess
Section titled “Initial guess”Use time 0 to 600 s. Horizontal position increases linearly from 0 to 600 km. Depth is V-shaped: the first 15 nodes descend to 300 km and the last 15 rise back to zero. Angle increases linearly from 0 to ; speed starts at zero at all nodes.
Results
Section titled “Results”

- Duration: 632.7 s, about 10 minutes 20 seconds; analytic value: 620.2 s.
- Maximum depth at the midpoint: 186.9 km, versus 191.0 km analytically.
- Peak speed: 1.91 km/s, versus 1.93 km/s analytically.
- Angle changes almost linearly from straight down (0°) to straight up (180°).
Explanation
Section titled “Explanation”A complete cycloid arch
Section titled “A complete cycloid arch”The cycloid is
Unlike Example 03, the endpoint returns to the original height. The trajectory spans to , so km. Therefore
Duration is proportional to : quadrupling distance only doubles time because the longer tunnel is deeper and allows higher speeds.
Accuracy and scaling
Section titled “Accuracy and scaling”With 30 nodes, duration differs from the analytic result by about 0.04 s (less than 0.01%), and maximum depth by about 1 km. Without scaling, the optimizer must handle distances up to 600 000 alongside angles near 3, making its search poorly balanced. With representative units, all variables have comparable magnitudes.
Try it
Section titled “Try it”- Set
lto 400000 (roughly Tokyo to Nagoya). Expect duration about 506 s and maximum depth about 127 km. - Set
unit_x,unit_y, andunit_tto 1 inmake_problem. The mathematical answer is unchanged, but the solver may fail withInequality constraints incompatible. - Change guessed maximum depth
hto 150000 or 500000. Compare convergence to durations near 620.2 s, differing by only about 0.03 s.
uv run python examples/05_brachistochrone_tokyo_osaka.py