Skip to content

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?

ItemDefinition
StatesHorizontal distance xx, depth yy, speed vv
ControlTunnel angle θ\theta from downward vertical
ObjectiveMinimize tft_f
PhasesOne phase, 30 nodes, free final time
New conceptsPhysical units and variable scaling with set_unit_*

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.

Depth is positive downward; θ=90∘\theta=90^\circ is horizontal, and larger angles climb:

x˙=vsin⁡θ,y˙=vcos⁡θ,v˙=gcos⁡θ.\dot{x}=v\sin\theta,\qquad\dot{y}=v\cos\theta,\qquad\dot{v}=g\cos\theta.

Gravity’s component along the tunnel changes speed. Energy gives v=2gyv=\sqrt{2gy}.

x(0)=y(0)=v(0)=0,x(tf)=l,y(tf)=0.x(0)=y(0)=v(0)=0,\qquad x(t_f)=l,\quad y(t_f)=0.

The vehicle starts at rest at the surface in Tokyo and reaches the surface in Osaka, l=600l=600 km away.

0≤x≤l,y≥0,0≤θ≤π,J=tf.0\le x\le l,\qquad y\ge0,\qquad0\le\theta\le\pi,\qquad J=t_f.

The trajectory stays between the cities, below ground, and does not reverse horizontally. These bounds restrict the search to the intended region.

SymbolParameterValue
ggPARAMETERS["g"]9.8 m/s²
llPARAMETERS["l"]600 000 m
hhPARAMETERS["h"], guessed maximum depth300 000 m
VariableUnitApproximate internal range
xx300 000 m0–2
yy100 000 m0–1.9
vv3000 m/s0–0.65
θ\theta1 rad0–3.1
tt100 s0–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.

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 π\pi; speed starts at zero at all nodes.

Tunnel shape. The green line is the surface; endpoint markers identify Tokyo and Osaka. The blue curve through 30 nodes nearly overlaps the analytic cycloid (black dashed).
Tunnel shape. The green line is the surface; endpoint markers identify Tokyo and Osaka. The blue curve through 30 nodes nearly overlaps the analytic cycloid (black dashed).
Depth in km, speed in km/s, and direction in degrees. Black dashed curves show the analytic solution.
Depth in km, speed in km/s, and direction in degrees. Black dashed curves show the analytic solution.
Travel through the tunnel, with depth and speed histories and a cursor at the current time.
  • 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°).

The cycloid is

x=a(ϕ−sin⁡ϕ),y=a(1−cos⁡ϕ).x=a(\phi-\sin\phi),\qquad y=a(1-\cos\phi).

Unlike Example 03, the endpoint returns to the original height. The trajectory spans ϕ=0\phi=0 to 2π2\pi, so a=l/(2π)≈95.5a=l/(2\pi)\approx95.5 km. Therefore

ymax⁡=lπ≈191 km,tf=2πlg,vmax⁡=2gymax⁡.y_{\max}=\frac{l}{\pi}\approx191\ \text{km},\qquad t_f=\sqrt{\frac{2\pi l}{g}},\qquad v_{\max}=\sqrt{2gy_{\max}}.

Duration is proportional to l\sqrt l: quadrupling distance only doubles time because the longer tunnel is deeper and allows higher speeds.

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.

  • Set l to 400000 (roughly Tokyo to Nagoya). Expect duration about 506 s and maximum depth about 127 km.
  • Set unit_x, unit_y, and unit_t to 1 in make_problem. The mathematical answer is unchanged, but the solver may fail with Inequality constraints incompatible.
  • Change guessed maximum depth h to 150000 or 500000. Compare convergence to durations near 620.2 s, differing by only about 0.03 s.
Terminal window
uv run python examples/05_brachistochrone_tokyo_osaka.py

View the Python source on GitHub.