Triangle inequality (source code)

= Triangle inequality
{title2=$d(x,z)\leq d(x,y)+d(y,z)$}
{wiki}

A <metric> satisfies $d(x,z)\leq d(x,y)+d(y,z)$: visiting an intermediate point cannot beat the direct endpoint distance. A <norm> satisfies the corresponding inequality $\|u+v\|\leq\|u\|+\|v\|$.

Take $O=(0,0)$, $Q=(3,0)$, and $P=(3,4)$. For <Euclidean distance>, the <triangle inequality> reads $5\leq3+4=7$. The direct <line segment> has <metric path length> $5$, while the route through $Q$ has <metric path length> $7$. For <Manhattan distance>, the same comparison becomes $7=3+4$: both routes are shortest. The <line segment> and the bent route both become <metric geodesics> when progress is measured by <metric path length>. For <Chebyshev distance>, the direct <line segment> has <metric path length> $4$, while the same bent route still costs $7$.

\Image[/metric-route-lengths.png]
{title=The same endpoints and routes have different lengths in three metrics}

Repeated application of the <triangle inequality> bounds the endpoint distance by the sum along any finite chain of intermediate points. This explains why <metric path length> is always at least the distance between endpoints. Equality reveals a shortest route, but its shape and uniqueness depend on the chosen <metric>.