Skip to content
Glacius
Linear algebraConcept reference

Euclidean distance

Euclidean distance between two vectors is the Euclidean length of their difference.

On this page 7 sections
  1. Overview
  2. Euclidean distance measures straight-line separation
  3. Reversing the endpoints negates every difference, but squaring removes those signs
  4. Check your understanding
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01Euclidean distance measures straight-line separation#

Euclidean distance measures straight-line separation. View the vectors as points, and connect the first point to the second.

Point A is(1,1) and point B is(4,5). The arrow from A to B changes x by3 and y by4. Its Euclidean length is5. Both axes have the same unit scale.Point A is(1,1) and point B is(4,5). The arrow from A to B changes x by3 and y by4. Its Euclidean length is5. Both axes have the same unit scale.
Figure 1A and B differ by 3 horizontally and 4 vertically.
Link to this figure ↗Download SVGDownload PNG

For A=(1,1)A=(1,1) and B=(4,5)B=(4,5), subtract the start from the end in each coordinate. The connecting displacement is (41,51)=(3,4)(4-1,5-1)=(3,4).

The displacement’s length is the distance.

32+42=5\sqrt{3^2+4^2}=5

For any same-dimension vectors, subtract corresponding coordinates first. Then compute the Euclidean length of the difference.

Distance is the length of the connecting displacement.

d(a,b)=ba2d(a,b)=\|b-a\|_2
Check your reasoning

Find the Euclidean distance from A=(2,1)A=(-2,1) to B=(1,5)B=(1,5).

Show answer and explanation
5

The difference is (3,4)(3,4). Its length is 55.

02Reversing the endpoints negates every difference, but squaring removes those signs#

Reversing the endpoints negates every difference, but squaring removes those signs. Distance is therefore the same in both directions. Identical endpoints have distance zero.

From (4,5) back to (1,1).

(3,4)2=5\|(-3,-4)\|_2=5
Check your reasoning

A map places P at (2,3) and Q at (8,11). What is their straight-line separation?

Show answer and explanation
10

The displacement is (6,8)(6,8), whose length is 1010.

03Check your understanding#

Check your reasoning

For A=(3,0)A=(3,0) and B=(6,0)B=(6,0), a learner reports distance 66. What fixes it?

  1. ASubtract first.
  2. BAdd lengths.
  3. CNegate the result.
Show answer and explanation
Subtract first.

The difference is (3,0)(3,0); the distance is 33.

Key takeaway

Subtract the coordinates, then measure the difference. Reversing the endpoints preserves distance.

  • Compute the Euclidean distance between two vectors

Sources & further reading

  1. [1]
  2. [2]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Euclidean distance.” Math behind ML. /learn/la-distance