Intuition Why a whole page of examples?
The distance formula is one line — but the situations it appears in are many. Negative coordinates, points sitting on an axis, points that collapse onto each other, a real-world "ant in a room" problem, and sneaky exam twists all use the same formula but trip you in different places . This page walks a full menu so you never meet a case you haven't already seen.
Everything here rests on the one rule from the parent note:
P Q = ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 + ( z 2 − z 1 ) 2
Read that as "same minus same, square, add, root." Nothing new is invented below — we only stress-test it.
Before solving anything, let's list every kind of situation this topic can throw at you. Each row is a "cell"; every worked example below is tagged with the cell it covers.
Cell
Situation
What makes it tricky
Covered by
A
All-positive coordinates, plain plug-in
nothing — the warm-up
Ex 1
B
Mixed signs (negatives)
subtracting a negative flips to a plus
Ex 2
C
A point on an axis / plane (some coords zero)
a whole term vanishes
Ex 3
D
Degenerate: the two points coincide
distance must be exactly 0
Ex 4
E
Solve for an unknown coordinate
one equation, possibly two answers
Ex 5
F
Geometry proof (type of triangle)
compare three distances
Ex 6
G
Real-world word problem (ant in a room)
translate words → coordinates
Ex 7
H
Exam twist: equidistant point / locus
set two distances equal, cancel squares
Ex 8
Once all eight cells are green, you have seen the full behaviour of the formula.
Worked example Example 1 — all positive
Find the distance between P ( 2 , 3 , 6 ) and Q ( 5 , 7 , 18 ) .
Forecast: Guess the number before reading on. The gaps look like 3 , 4 , 12 — do you recognise that trio?
Same minus same. x : 5 − 2 = 3 ; y : 7 − 3 = 4 ; z : 18 − 6 = 12 .
Why this step? These three differences are the edge lengths of the box whose diagonal is P Q .
Square, add. 3 2 + 4 2 + 1 2 2 = 9 + 16 + 144 = 169 .
Why this step? Pythagoras applied twice (floor then vertical) collapses into one sum of squares.
Root. 169 = 13 .
Why this step? The formula has an outer square root — the sum of squares is a squared length, not the length itself.
Answer: 13 units.
Verify: 3 2 + 4 2 = 25 = 5 2 (a floor diagonal of 5 ), then 5 2 + 1 2 2 = 169 = 1 3 2 ✓ — the classic 5 , 12 , 13 triangle sits on top of the 3 , 4 , 5 triangle.
Negatives are where most marks are lost, so go slowly.
Worked example Example 2 — mixed signs
Find the distance between A ( − 1 , 2 , − 3 ) and B ( 2 , − 2 , − 15 ) .
Forecast: With z going from − 3 to − 15 (a drop of 12 ), and the answer probably "nice", guess it lands near 13 again.
Same minus same — watch the double negatives.
x : 2 − ( − 1 ) = 2 + 1 = 3 ; y : − 2 − 2 = − 4 ; z : − 15 − ( − 3 ) = − 15 + 3 = − 12 .
Why this step? Subtracting a negative adds . The y and z gaps come out negative — that is fine, because the next step squares them away.
Square, add. 3 2 + ( − 4 ) 2 + ( − 12 ) 2 = 9 + 16 + 144 = 169 .
Why this step? ( − 4 ) 2 = + 16 and ( − 12 ) 2 = + 144 : squaring is order- and sign-blind , so distance never turns negative.
Root. 169 = 13 .
Answer: 13 units.
Verify: Reverse the subtraction order: x 1 − x 2 = − 1 − 2 = − 3 , and ( − 3 ) 2 = 9 — identical. Order does not change a squared term.
Worked example Example 3 — a coordinate is zero
Find the distance from A ( 0 , 0 , 4 ) to B ( 3 , 4 , 0 ) . A sits on the z -axis; B sits in the x y -plane.
Forecast: One point is "up the pole", the other "on the floor". Expect the diagonal to be a bit longer than either the height 4 or the floor-diagonal 5 .
Same minus same. x : 3 − 0 = 3 ; y : 4 − 0 = 4 ; z : 0 − 4 = − 4 .
Why this step? A zero coordinate is not special — it just means that term equals the other point's coordinate. Nothing vanishes here, but a term would vanish if both points shared a coordinate.
Square, add. 3 2 + 4 2 + ( − 4 ) 2 = 9 + 16 + 16 = 41 .
Root. 41 ≈ 6.40 .
Why this step? 41 is not a perfect square, so leave it as 41 — exact beats a rounded decimal in an exam.
Answer: 41 units ≈ 6.40 .
Verify: 6 2 = 36 and 7 2 = 49 , so 41 lies between 6 and 7 — matches the forecast that it's a touch above the floor-diagonal 5 .
See the two special points drawn in the room:
Worked example Example 4 — coincident points
Find the distance between P ( 7 , − 1 , 5 ) and Q ( 7 , − 1 , 5 ) .
Forecast: They are the same point. What must the distance be?
Same minus same. x : 7 − 7 = 0 ; y : − 1 − ( − 1 ) = 0 ; z : 5 − 5 = 0 .
Why this step? Identical coordinates give zero differences — the box has collapsed to a single point (all three edges length 0 ).
Square, add, root. 0 2 + 0 2 + 0 2 = 0 = 0 .
Why this step? Zero is the only input that makes distance zero — this is the limiting/degenerate case, and it confirms the formula behaves sensibly.
Answer: 0 units.
Verify: Distance is zero iff all three differences are zero iff the points coincide. Our result 0 agrees. (This is exactly why P Q = 0 can be used to prove two points are the same.)
Worked example Example 5 — find the missing
y (two answers)
Point P ( 3 , y , 4 ) is at distance 5 from Q ( 3 , 1 , 0 ) . Find y .
Forecast: x matches (3 = 3 ) so that term is dead. The z -gap is 4 . To reach a total of 5 , the y -part must supply a leg — do you sense 3 coming?
Write the equation, square both sides first.
5 2 = ( 3 − 3 ) 2 + ( y − 1 ) 2 + ( 4 − 0 ) 2
Why this step? Squaring removes the outer root, turning a scary radical equation into ordinary algebra.
Simplify the known terms. 25 = 0 + ( y − 1 ) 2 + 16 , so ( y − 1 ) 2 = 9 .
Why this step? Isolate the unknown before rooting.
Root — and keep both signs. y − 1 = ± 3 , so y = 4 or y = − 2 .
Why this step? 9 has two roots + 3 and − 3 ; a distance condition is symmetric, so two positions (one above, one below) are equally valid.
Answer: y = 4 or y = − 2 .
Verify: y = 4 : 0 + 9 + 16 = 25 = 5 ✓. y = − 2 : 0 + 9 + 16 = 5 ✓. Both check out — never discard a root without a reason.
Worked example Example 6 — right-angled triangle
Show that A ( 1 , 2 , 3 ) , B ( 3 , 4 , 3 ) , C ( 3 , 2 , 5 ) form a right-angled triangle.
Forecast: If it's right-angled, two short sides squared should add to the longest side squared — Pythagoras in reverse.
Compute all three side lengths (squared — root later).
A B 2 = ( 3 − 1 ) 2 + ( 4 − 2 ) 2 + ( 3 − 3 ) 2 = 4 + 4 + 0 = 8 .
B C 2 = ( 3 − 3 ) 2 + ( 2 − 4 ) 2 + ( 5 − 3 ) 2 = 0 + 4 + 4 = 8 .
A C 2 = ( 3 − 1 ) 2 + ( 2 − 2 ) 2 + ( 5 − 3 ) 2 = 4 + 0 + 4 = 8 .
Why this step? Comparing squared lengths avoids messy square roots and is exactly what Pythagoras needs.
Test Pythagoras. Is any pair's sum equal to the third? A B 2 + B C 2 = 8 + 8 = 16 , but A C 2 = 8 . Not right-angled that way. Every pair gives 8 + 8 = 16 = 8 .
Why this step? All three sides are equal (8 each), so no side is a hypotenuse.
Reinterpret. Since A B = B C = C A = 8 = 2 2 , the triangle is equilateral , not right-angled.
Why this step? Honest maths: the data told us "equilateral", so we report the truth. (An exam may deliberately mislabel to test you.)
Answer: The triangle is equilateral with side 2 2 , not right-angled.
Verify: All three squared distances equal 8 ✓, so all sides equal — the defining property of an equilateral triangle.
Worked example Example 7 — ant in a room
A room is a box 6 m long, 4 m wide, 3 m tall. An ant sits at a bottom corner; a crumb sits at the diagonally opposite top corner. What is the straight-line gap?
Forecast: The straight gap must beat the floor-diagonal alone (6 2 + 4 2 = 52 ≈ 7.2 ). Guess something a little over 7 .
Set coordinates. Put the ant at the origin ( 0 , 0 , 0 ) ; then the opposite top corner is ( 6 , 4 , 3 ) .
Why this step? Choosing the ant as origin makes every coordinate of the crumb equal to a room dimension — the word problem becomes a plug-in.
Apply the formula. gap = 6 2 + 4 2 + 3 2 = 36 + 16 + 9 = 61 .
Why this step? Length, width, height are exactly the box edges a , b , c ; the body diagonal is the straight-line distance.
Numeric value. 61 ≈ 7.81 m .
Answer: 61 ≈ 7.81 metres.
Verify: 7 2 = 49 < 61 < 64 = 8 2 , so the gap is between 7 and 8 m, and indeed a bit above the floor-diagonal 7.2 m ✓.
Worked example Example 8 — the locus twist
Find the point on the z -axis that is equidistant from A ( 1 , 2 , − 1 ) and B ( 3 , − 2 , 1 ) .
Forecast: A point on the z -axis looks like ( 0 , 0 , z ) . "Equidistant" means one equation — expect a single z .
Name the unknown point. Any point on the z -axis is P ( 0 , 0 , z ) (its x and y are zero by definition of the axis).
Why this step? Encoding "on the z -axis" as ( 0 , 0 , z ) turns a wordy condition into one variable.
Set P A 2 = P B 2 (square both, no roots).
( 0 − 1 ) 2 + ( 0 − 2 ) 2 + ( z + 1 ) 2 = ( 0 − 3 ) 2 + ( 0 + 2 ) 2 + ( z − 1 ) 2
Why this step? "Equidistant" means P A = P B ; squaring both sides removes both roots at once and keeps the equation linear-friendly.
Expand and cancel.
Left: 1 + 4 + z 2 + 2 z + 1 = z 2 + 2 z + 6 .
Right: 9 + 4 + z 2 − 2 z + 1 = z 2 − 2 z + 14 .
Set equal: z 2 + 2 z + 6 = z 2 − 2 z + 14 . The z 2 terms cancel, giving 4 z = 8 , so z = 2 .
Why this step? The squared-z terms always cancel in an "equidistant" set-up, leaving a simple linear equation — this is the signature trick.
Answer: P ( 0 , 0 , 2 ) .
Verify: P A 2 = 1 + 4 + ( 2 + 1 ) 2 = 1 + 4 + 9 = 14 . P B 2 = 9 + 4 + ( 2 − 1 ) 2 = 9 + 4 + 1 = 14 . Equal ✓ — P really is equidistant.
Recall Which cases are "green" now?
Positive plug-in ::: Ex 1
Negative / double-negative coords ::: Ex 2
Coordinate equal to zero ::: Ex 3
Coincident points (distance 0 ) ::: Ex 4
Unknown coordinate → two answers ::: Ex 5
Triangle-type proof via three distances ::: Ex 6
Word problem (box diagonal) ::: Ex 7
Equidistant point → linear equation after cancelling squares ::: Ex 8
Recall Quick numeric checks
Distance ( 2 , 3 , 6 ) → ( 5 , 7 , 18 ) ::: 13
Distance ( − 1 , 2 , − 3 ) → ( 2 , − 2 , − 15 ) ::: 13
Distance ( 0 , 0 , 4 ) → ( 3 , 4 , 0 ) ::: 41
If ( 3 , y , 4 ) is 5 from ( 3 , 1 , 0 ) ::: y = 4 or y = − 2
Ant-to-crumb in a 6 × 4 × 3 box ::: 61 ≈ 7.81
Point on z -axis equidistant from ( 1 , 2 , − 1 ) and ( 3 , − 2 , 1 ) ::: ( 0 , 0 , 2 )
Mnemonic For "equidistant" twists
"Square both, watch the squares cancel." In any P A = P B problem the x 2 , y 2 , z 2 terms vanish, leaving a plain linear (or plane) equation.
Distance formula in 3D — the parent rule every example uses.
Distance formula in 2D — Ex 3's floor-diagonal is exactly this special case.
Vectors and magnitude — each distance is ∣ P Q ∣ .
Section formula in 3D — shares the coordinate-difference machinery.
Coordinate axes and octants in 3D — Ex 3 and Ex 8 place points on axes.
Equation of a sphere — Ex 8's "equidistant" idea generalises to a plane/sphere locus.