Distance in Coordinate Geometry

From the Pythagorean theorem to distances anywhere in space

A Finding the hypotenuse
You already know: in a right-angled triangle with legs $a$ and $b$, the three sides satisfy $a^2 + b^2 = c^2$. Each exercise below gives you two legs. Your job is to find $c$. The method is always the same — square, add, root — but the answers will surprise you sometimes.
A1 Legs $a = 3$, $b = 4$ — find the hypotenuse. Starter

A right triangle has legs $a = 3$ and $b = 4$. What is the length of the hypotenuse $c$?

Hint: Write out $a^2 + b^2$, compute the sum, then take the square root.
Show solution
$c^2 = 3^2 + 4^2 = 9 + 16 = 25$
$c = \sqrt{25} = 5$

$c = 5$

A2 Legs $a = 5$, $b = 12$ — find the hypotenuse. Starter

A right triangle has legs $a = 5$ and $b = 12$. Find $c$.

Hint: $5^2 = 25$, $12^2 = 144$. Add and take the root.
Show solution
$c^2 = 25 + 144 = 169$
$c = \sqrt{169} = 13$

$c = 13$

A3 Legs $a = 6$, $b = 8$ — find the hypotenuse. Easy

A right triangle has legs $a = 6$ and $b = 8$. Find $c$.

Hint: Square, add, root. Does the answer remind you of A1?
Show solution
$c^2 = 36 + 64 = 100$
$c = 10$

$c = 10$

$(6,8,10)$ is just $(3,4,5)$ scaled by 2. Scaling all sides by the same factor preserves the right angle — and scales the hypotenuse by the same factor.

A4 Legs $a = 1$, $b = 1$ — find the hypotenuse. Easy

A right triangle has two equal legs $a = b = 1$ (this is the diagonal of a unit square). Find $c$.

Hint: $c^2 = 1 + 1$. The answer won't be a whole number — leave it as $\sqrt{\cdot}$.
Show solution
$c^2 = 1 + 1 = 2$
$c = \sqrt{2}$

$c = \sqrt{2} \approx 1.414$

$\sqrt{2}$ is irrational — it cannot be written as a fraction. But it is a perfectly exact answer. We will meet it again in Section B.

A5 Legs $a = 8$, $b = 15$ — find the hypotenuse. Medium

A right triangle has legs $a = 8$ and $b = 15$. Find $c$.

Hint: $8^2 = 64$, $15^2 = 225$. Does the sum happen to be a perfect square?
Show solution
$c^2 = 64 + 225 = 289$
$c = \sqrt{289} = 17$

$c = 17$

$(8,15,17)$ is another whole-number Pythagorean triple.

A6 Legs $a = 2$, $b = 3$ — find the hypotenuse. Medium

A right triangle has legs $a = 2$ and $b = 3$. Find $c$.

Hint: Compute $2^2 + 3^2$. The sum is not a perfect square, so leave the answer as $\sqrt{\cdot}$.
Show solution
$c^2 = 4 + 9 = 13$
$c = \sqrt{13} \approx 3.606$

$c = \sqrt{13}$

A7 Legs $a$ and $b$ (any values) — write a formula for $c$. Medium

A right triangle has legs of length $a$ and $b$. Write a single formula for the hypotenuse $c$ in terms of $a$ and $b$.

Hint: Look at what you did in every exercise above. Describe the pattern as one expression.
Show solution
$c^2 = a^2 + b^2$

$$c = \sqrt{a^2 + b^2}$$

This compact formula is the key to Section B and C. Keep it in mind — you will rediscover it from coordinates.

B Distance between two points in 2D
Given two points on a grid, how far apart are they? The trick: draw a right triangle using the two points, then apply the Pythagorean theorem to the triangle. You get to figure out exactly how to build that triangle.
1 2 3 4 5 1 2 3 4 A B Δx = x₂ − x₁ Δy d = ?
The key idea
Given $A = (x_1, y_1)$ and $B = (x_2, y_2)$, draw a horizontal line through $A$ and a vertical line through $B$. They meet at $C = (x_2, y_1)$. Triangle $ACB$ is a right triangle with legs $\Delta x = x_2 - x_1$ and $\Delta y = y_2 - y_1$. Apply the Pythagorean theorem to get the distance $AB$.
B1 Distance from $(0, 0)$ to $(3, 4)$ Starter

Find the distance between $A = (0, 0)$ and $B = (3, 4)$.

1 2 3 1 2 3 4 A B 3 4 d = ?
Hint: The horizontal leg goes from $(0,0)$ to $(3,0)$, length $= 3$. The vertical leg goes from $(3,0)$ to $(3,4)$, length $= 4$. Now use the Pythagorean theorem.
Show solution
Horizontal leg: $\Delta x = 3 - 0 = 3$
Vertical leg: $\Delta y = 4 - 0 = 4$
$d^2 = 3^2 + 4^2 = 9 + 16 = 25$

$d = 5$

Same as exercise A1 — the two legs are the legs of a right triangle.

B2 Distance from $(0, 0)$ to $(5, 0)$ Starter

Find the distance between $A = (0, 0)$ and $B = (5, 0)$. (The two points lie on the same horizontal line.)

Hint: What is $\Delta y$ when both points have the same $y$-coordinate? How does the Pythagorean theorem simplify?
Show solution
$\Delta x = 5$, $\Delta y = 0$
$d = \sqrt{5^2 + 0^2} = \sqrt{25} = 5$

$d = 5$

When the two points share a $y$-coordinate, the "distance" is just $|\Delta x|$. No triangle needed — the right triangle degenerates to a flat line.

B3 Distance from $(0, 0)$ to $(0, 4)$ Starter

Find the distance between $A = (0, 0)$ and $B = (0, 4)$. (The two points lie on the same vertical line.)

Hint: What is $\Delta x$ here? How does the formula simplify?
Show solution
$\Delta x = 0$, $\Delta y = 4$
$d = \sqrt{0^2 + 4^2} = 4$

$d = 4$

B4 Distance from $(1, 2)$ to $(4, 6)$ Easy

Find the distance between $A = (1, 2)$ and $B = (4, 6)$.

1 2 3 4 1 2 3 4 5 6 A B Δx = 3 Δy = 4 d = ?
Hint: First compute $\Delta x = 4 - 1$ and $\Delta y = 6 - 2$. These are the legs of the right triangle. Then apply Pythagoras.
Show solution
$\Delta x = 4 - 1 = 3$
$\Delta y = 6 - 2 = 4$
$d^2 = 3^2 + 4^2 = 9 + 16 = 25$

$d = 5$

Same right triangle as B1 and A1 — just shifted on the grid. Shifting doesn't change distances.

B5 Distance from $(0, 0)$ to $(1, 1)$ Easy

Find the distance between $A = (0, 0)$ and $B = (1, 1)$.

Hint: $\Delta x = 1$, $\Delta y = 1$. This is the diagonal of a unit square.
Show solution
$d = \sqrt{1^2 + 1^2} = \sqrt{2}$

$d = \sqrt{2} \approx 1.414$

Same answer as exercise A4. A unit-square diagonal has length $\sqrt{2}$.

B6 Distance from $(-3, 1)$ to $(1, 4)$ Easy

Find the distance between $A = (-3, 1)$ and $B = (1, 4)$.

Hint: $\Delta x = 1 - (-3)$. Careful with the double negative. Then $\Delta y = 4 - 1$.
Show solution
$\Delta x = 1 - (-3) = 4$
$\Delta y = 4 - 1 = 3$
$d = \sqrt{4^2 + 3^2} = \sqrt{16 + 9} = \sqrt{25} = 5$

$d = 5$

Negative coordinates are fine. The legs $\Delta x$ and $\Delta y$ can be positive or negative, but you square them — so the sign disappears.

B7 Distance from $(-2, -3)$ to $(4, 5)$ Medium

Find the distance between $A = (-2, -3)$ and $B = (4, 5)$.

Hint: Compute $\Delta x = 4 - (-2)$ and $\Delta y = 5 - (-3)$. Both involve subtracting a negative. Do you recognise the resulting triangle?
Show solution
$\Delta x = 4 - (-2) = 6$
$\Delta y = 5 - (-3) = 8$
$d = \sqrt{6^2 + 8^2} = \sqrt{36 + 64} = \sqrt{100} = 10$

$d = 10$

Triangle $(6, 8, 10)$ — the $3{-}4{-}5$ triple scaled by 2.

B8 Distance from $(4, 1)$ to $(-1, 5)$ Medium

Find the distance between $A = (4, 1)$ and $B = (-1, 5)$.

Hint: $\Delta x = -1 - 4 = -5$. A negative $\Delta x$ just means $B$ is to the left of $A$. Does it matter when you square it?
Show solution
$\Delta x = -1 - 4 = -5$
$\Delta y = 5 - 1 = 4$
$d = \sqrt{(-5)^2 + 4^2} = \sqrt{25 + 16} = \sqrt{41}$

$d = \sqrt{41} \approx 6.40$

$(-5)^2 = 25$, same as $5^2 = 25$. Squaring kills the sign. Distance is always non-negative, so this always works.

B9 Distance from $(2, 3)$ to $(7, 15)$ Medium

Find the distance between $A = (2, 3)$ and $B = (7, 15)$.

Hint: Compute $\Delta x$ and $\Delta y$, then check whether $(\Delta x)^2 + (\Delta y)^2$ is a perfect square.
Show solution
$\Delta x = 7 - 2 = 5$
$\Delta y = 15 - 3 = 12$
$d = \sqrt{5^2 + 12^2} = \sqrt{25 + 144} = \sqrt{169} = 13$

$d = 13$

The $(5, 12, 13)$ triple again — same as exercise A2.

B10 Write a general formula for the distance between any two 2D points. Medium

Let $A = (x_1, y_1)$ and $B = (x_2, y_2)$ be any two points in the plane. Derive a formula for the distance $d = AB$ using the approach from this section.

Hint: The right triangle has legs $\Delta x = x_2 - x_1$ and $\Delta y = y_2 - y_1$. Write $d$ in terms of these. Then substitute back.
Show derivation
Horizontal leg: $\Delta x = x_2 - x_1$
Vertical leg: $\Delta y = y_2 - y_1$
Pythagorean theorem: $d^2 = (\Delta x)^2 + (\Delta y)^2$

$$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$

This is the distance formula in 2D. You have just derived it from first principles using only the Pythagorean theorem.

C Distance between two points in 3D
In 3D each point has three coordinates: $(x, y, z)$. Can we still use the Pythagorean theorem? Yes — we just apply it twice. The exercises below will lead you to figure out how.
Δx Δy Δz d₁ d Δy A B M
The two-step trick for 3D
Given $A = (x_1, y_1, z_1)$ and $B = (x_2, y_2, z_2)$:
  1. Drop $B$ straight down onto the floor ($y = y_1$) to get point $M = (x_2, y_1, z_2)$. The floor distance is $d_1 = \sqrt{\Delta x^2 + \Delta z^2}$.
  2. Now $AM$ and $MB$ are perpendicular (floor vs. vertical), so apply Pythagoras again: $d = \sqrt{d_1^2 + \Delta y^2} = \sqrt{\Delta x^2 + \Delta y^2 + \Delta z^2}$.

You don't have to use the floor — any pair of axes works first. The result is always the same.

C1 Distance from $(0, 0, 0)$ to $(5, 0, 0)$ Starter

Find the distance between $A = (0, 0, 0)$ and $B = (5, 0, 0)$. $B$ lies on the $x$-axis.

Hint: $\Delta y = 0$ and $\Delta z = 0$. What does $\sqrt{\Delta x^2 + 0 + 0}$ simplify to?
Show solution
$\Delta x = 5$, $\Delta y = 0$, $\Delta z = 0$
$d = \sqrt{5^2 + 0 + 0} = 5$

$d = 5$

Along a single axis, 3D distance reduces to the ordinary 1D distance.

C2 Distance from $(0, 0, 0)$ to $(3, 4, 0)$ Starter

Find the distance between $A = (0, 0, 0)$ and $B = (3, 4, 0)$. Both points lie in the $z = 0$ plane.

Hint: $\Delta z = 0$. This is exactly the same as the 2D problem with $x$ and $y$. What does the formula give?
Show solution
$\Delta x = 3$, $\Delta y = 4$, $\Delta z = 0$
$d = \sqrt{3^2 + 4^2 + 0} = \sqrt{25} = 5$

$d = 5$

Setting one coordinate to zero recovers the 2D case. 3D distance is a genuine extension of 2D distance.

C3 Distance from $(0, 0, 0)$ to $(0, 3, 4)$ Easy

Find the distance between $A = (0, 0, 0)$ and $B = (0, 3, 4)$. Both points lie in the $x = 0$ plane.

Hint: $\Delta x = 0$. Only $y$ and $z$ change — it's still a 2D problem.
Show solution
$\Delta x = 0$, $\Delta y = 3$, $\Delta z = 4$
$d = \sqrt{0 + 3^2 + 4^2} = \sqrt{9 + 16} = 5$

$d = 5$

C4 Distance from $(0, 0, 0)$ to $(1, 1, 1)$ Easy

Find the distance between opposite corners of a unit cube: from $A = (0, 0, 0)$ to $B = (1, 1, 1)$.

Hint: Step 1 — find the floor diagonal from $(0,0,0)$ to $(1,0,1)$: $d_1 = \sqrt{1^2 + 1^2} = \sqrt{2}$. Step 2 — use $d_1$ as one leg and $\Delta y = 1$ as the other.
Show solution
Step 1 (floor diagonal): $d_1 = \sqrt{1^2 + 1^2} = \sqrt{2}$
Step 2 (space diagonal): $d = \sqrt{d_1^2 + 1^2} = \sqrt{2 + 1} = \sqrt{3}$

$d = \sqrt{3} \approx 1.732$

The main diagonal of a unit cube has length $\sqrt{3}$. You can also see this directly: $\sqrt{1^2+1^2+1^2} = \sqrt{3}$.

C5 Distance from $(1, 2, 3)$ to $(4, 6, 3)$ Easy

Find the distance between $A = (1, 2, 3)$ and $B = (4, 6, 3)$. Notice that both $z$-coordinates are equal.

Hint: $\Delta z = 3 - 3 = 0$. The problem collapses to a 2D distance — compute $\Delta x$ and $\Delta y$.
Show solution
$\Delta x = 3$, $\Delta y = 4$, $\Delta z = 0$
$d = \sqrt{9 + 16 + 0} = 5$

$d = 5$

C6 Distance from $(0, 0, 0)$ to $(2, 2, 1)$ Easy

Find the distance between $A = (0, 0, 0)$ and $B = (2, 2, 1)$.

Hint: Compute $2^2 + 2^2 + 1^2$. Does it equal a perfect square?
Show solution
$d^2 = 2^2 + 2^2 + 1^2 = 4 + 4 + 1 = 9$
$d = \sqrt{9} = 3$

$d = 3$

$(2,2,1,3)$ is a 3D Pythagorean quadruple: $2^2+2^2+1^2=3^2$.

C7 Distance from $(0, 0, 0)$ to $(3, 12, 4)$ — guided two steps Medium

Find the distance between $A = (0, 0, 0)$ and $B = (3, 12, 4)$. Try the two-step approach shown in the diagram at the top of this section.

Hint: Step 1: Ignore $y$ for now. Drop $B$ onto the floor ($y=0$) to get $M = (3, 0, 4)$. Compute $d_1 = AM$ using only $\Delta x = 3$ and $\Delta z = 4$ — does that look familiar?
Step 2: Now $M$ and $B$ are directly above each other ($\Delta y = 12$). Find $d = \sqrt{d_1^2 + 12^2}$.
Show solution
Step 1 — floor distance:
$M = (3, 0, 4)$
$d_1 = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5$
Step 2 — space diagonal:
$\Delta y = 12$
$d = \sqrt{5^2 + 12^2} = \sqrt{25 + 144} = \sqrt{169} = 13$

$d = 13$

The $3{-}4{-}5$ triple on the floor, then the $5{-}12{-}13$ triple going up. Two Pythagorean triples nested inside each other!

C8 Distance from $(0, 0, 0)$ to $(2, 6, 9)$ Medium

Find the distance between $A = (0, 0, 0)$ and $B = (2, 6, 9)$.

Hint: Compute $2^2 + 6^2 + 9^2$. Check whether the sum is a perfect square.
Show solution
$d^2 = 4 + 36 + 81 = 121$
$d = \sqrt{121} = 11$

$d = 11$

Another 3D quadruple: $2^2 + 6^2 + 9^2 = 11^2$.

C9 Distance from $(1, 2, 3)$ to $(4, 6, 7)$ Medium

Find the distance between $A = (1, 2, 3)$ and $B = (4, 6, 7)$. All three coordinates differ.

Hint: Compute $\Delta x$, $\Delta y$, $\Delta z$ first, then apply the formula you derived in C10.
Show solution
$\Delta x = 3$, $\Delta y = 4$, $\Delta z = 4$
$d^2 = 9 + 16 + 16 = 41$

$d = \sqrt{41} \approx 6.40$

C10 Write a general formula for 3D distance. Medium

Let $A = (x_1, y_1, z_1)$ and $B = (x_2, y_2, z_2)$ be any two points in 3D space. Using the two-step approach — floor diagonal then height — derive a formula for the distance $d = AB$.

Hint: Step 1: floor distance $d_1 = \sqrt{(\Delta x)^2 + (\Delta z)^2}$.
Step 2: $d = \sqrt{d_1^2 + (\Delta y)^2}$. Substitute $d_1$ and simplify.
Show derivation
$\Delta x = x_2 - x_1, \quad \Delta y = y_2 - y_1, \quad \Delta z = z_2 - z_1$
Step 1: Floor point $M = (x_2, y_1, z_2)$.
$d_1^2 = (\Delta x)^2 + (\Delta z)^2$
Step 2: $d^2 = d_1^2 + (\Delta y)^2 = (\Delta x)^2 + (\Delta z)^2 + (\Delta y)^2$

$$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$$

The 3D distance formula is a natural extension of the 2D one: add one more squared difference under the root. The same idea extends to 4D, 5D, or any number of dimensions — just keep adding terms.