The distance between (x1,y1) and (x2,y2) in the plane is (x2−x1)2+(y2−y1)2 , just the Pythagorean theorem. In space, the same principle applies, with one extra coordinate.
The formula
For two points P(x1,y1,z1) and Q(x2,y2,z2):
∣PQ∣=(x2−x1)2+(y2−y1)2+(z2−z1)2.
Derivation
Project P and Q down to the xy-plane: their projections are P′(x1,y1,0) and Q′(x2,y2,0). The distance ∣P′Q′∣ in the plane is (x2−x1)2+(y2−y1)2.
Now consider the right triangle with one leg along ∣P′Q′∣ in the xy-plane and the other leg vertical of length ∣z2−z1∣. The hypotenuse ∣PQ∣ satisfies
∣PQ∣2=∣P′Q′∣2+∣z2−z1∣2=(x2−x1)2+(y2−y1)2+(z2−z1)2.\qed
Distance from origin
∣OP∣=x12+y12+z12.
Worked examples
Example 1. Distance between (1,2,3) and (4,6,8).
9+16+25=50=52.
Example 2. Distance from origin to (1,−2,2).
1+4+4=3.
Example 3. Show that (0,0,0),(3,4,0),(0,4,3) form an isosceles triangle.
Sides:
AB=9+16+0=5.
AC=0+16+9=5.
BC=9+0+9=18.
AB=AC, so isosceles.
Example 4. Find the point on the x-axis equidistant from (2,3,−1) and (4,−1,5).
Example 5. Show that (1,2,3),(−1,0,4),(4,1,2) form a right triangle.
AB2=4+4+1=9.
AC2=9+1+1=11.
BC2=25+1+4=30.
Check: AB2+AC2=9+11=20=30. Try other combinations: AB2+BC2=39=11. AC2+BC2=41=9. None equal. So not a right triangle. (I'd correct the example with proper integers.)
Let's use a cleaner case: (0,0,0),(1,0,0),(0,1,0). AB=1,AC=1,BC=2. 1+1=2=BC2. Right triangle at A.
Try it yourself
Distance between (1,0,1) and (0,1,0).
Distance between (−3,4,5) and (2,−1,0).
Distance from (0,0,0) to (2,−2,1).
Find a such that the distance between (a,1,2) and (3,1,5) is 5.
Show (1,2,3),(−2,3,5),(7,0,−1) are collinear.
Find a point on the y-axis equidistant from (1,2,3) and (2,1,1).
Find a point on the z-axis at distance 7 from (2,3,−1).
Are (0,7,−10),(1,6,−6),(4,9,−6) vertices of a right triangle?
The vertices of a triangle are (2,1,0),(−1,−1,2),(0,1,3). Find its perimeter.
Find the equidistant locus of (0,0,0) and (2,0,0).
Find the locus of a point that is at distance 3 from (1,2,−1).
The point P(x,y,z) is equidistant from (0,0,0) and (1,1,1). Find the equation describing this.
Pitfalls / Tricks
Don't forget the third term in the square root.
Distance is always non-negative; take the principal square root.
For "equidistant" problems, equate squared distances , avoids square roots until you must.
Insight. The distance formula is the same Pythagorean theorem we used in 2D, applied twice , once in the xy-plane, once between that and the vertical lift.