Discord

INAIO Guide Stage 1 10Coordinate Geometry and Vectors

10.2 Euclidean and Manhattan distance

Compare straight-line Euclidean distance with grid-route Manhattan distance, and choose the metric that fits the question.

“Nearest” depends on how movement is allowed. A drone can travel almost straight to a point, while a robot confined to horizontal and vertical grid paths cannot. Euclidean and Manhattan distances model those two situations.

This is foundational to intermediate coordinate geometry. Learn the distance formula in OpenStax, then compare it with the simple grid-route sum below.

A basic idea: two ways to measure

From A=(x1,y1)A=(x_1,y_1) to B=(x2,y2)B=(x_2,y_2), write Δx=x2−x1\Delta x=x_2-x_1 and Δy=y2−y1\Delta y=y_2-y_1. Straight-line Euclidean distance uses the Pythagorean theorem. Manhattan distance counts horizontal plus vertical movement.

Points A and B are joined by a straight diagonal and by a horizontal-then-vertical grid path; the diagonal's length is the Euclidean distance; the grid path's length is the Manhattan distance and is longer.Points A and B are joined by a straight diagonal and by a horizontal-then-vertical grid path; the diagonal's length is the Euclidean distance; the grid path's length is the Manhattan distance and is longer.
The metric encodes which paths or differences count.

A quick tour of formulas

d2(A,B)=(Δx)2+(Δy)2,d1(A,B)=∣Δx∣+∣Δy∣.d_2(A,B)=\sqrt{(\Delta x)^2+(\Delta y)^2}, \qquad d_1(A,B)=|\Delta x|+|\Delta y|.

Both distances are nonnegative, symmetric, and zero only for identical points. For any two points, d2≤d1d_2\le d_1, with equality only when Δx=0\Delta x=0 or Δy=0\Delta y=0. If you only need to compare Euclidean distances, compare their squares and skip square roots; squaring preserves their order because distances are nonnegative.

Application 1: a grid route

Move from (1,1)(1,1) to (4,5)(4,5). The horizontal and vertical changes are 33 and 44.

  1. A shortest grid route uses 3+4=73+4=7 unit moves, so d1=7d_1=7.
  2. A direct path has length d2=32+42=5d_2=\sqrt{3^2+4^2}=5.
  3. Use 77 for a robot limited to axis-aligned moves and 55 for a straight-line route.

Application 2: which candidate is closer?

From the origin, compare P=(3,0)P=(3,0) and Q=(2,2)Q=(2,2). Euclidean distances are d2(O,P)=3d_2(O,P)=3 and d2(O,Q)=8≈2.83d_2(O,Q)=\sqrt8\approx2.83, so QQ is nearer by straight line. Manhattan distances are d1(O,P)=3d_1(O,P)=3 and d1(O,Q)=4d_1(O,Q)=4, so PP is nearer on an axis-aligned grid. State the metric before selecting a nearest point.

Resources

SourceTitleWhy read it
OpenStaxThe rectangular coordinate systems and graphsDerive the straight-line distance formula.

Finished this module? Mark it done.

Comments

Stuck on something, spotted a mistake, or found a resource that helped you? Tell us below.

Loading comments