The distance between two points · Mathematics Class 11–12 | StemPy Lab
Course 22.2·Lesson 1 of 3
The distance between two points
The distance between P(x1,y1,z1)
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
find the distance between any two points in space;
find a point on an axis that is at a given distance from a point, or equidistant from two points;
decide whether a triangle is isosceles, equilateral or right-angled.
A cable between two masts
A cable runs from the top of one radio mast to the top of another. We know where each top is, with three coordinates. How long is the cable?
In the chapter on Straight Lines you found the distance between two points of a plane as (x2−x1)2+(y2−y1)2. In space the same idea needs one more term. The last lesson found the distance from the origin as x2+y2+z2. This lesson moves the origin to any point.
The formula
Let P(x1,y1,z1) and Q(x2,y2,z2) be two points. Draw a box with P and Q at opposite corners and with the faces parallel to the coordinate planes. The edges of the box have lengths ∣x2−x1∣, ∣y2−y1∣ and ∣z2−z1∣.
The diagonal of the bottom face has length (x2−x1)2+(y2−y1)2 by Pythagoras. Then PQ is the hypotenuse of a right triangle with that diagonal and the vertical edge as its sides. So
PQ2=(x2−x1)2+(y2−y1)2+(z2−z1)2.
The distance PQ is the square root of this sum.
The order of the points does not matter, because each difference is squared. The distance is zero only when the two points are the same.
Two points P and Q in space with a dashed box that has P and Q at opposite corners. The three edges of the box are marked with the differences x2 - x1, y2 - y1 and z2 - z1. The diagonal of the bottom face of the box is drawn in green and the segment PQ is drawn in red. A small square marks the right angle between the green diagonal and the vertical edge.
A worked example
Find the distance between A(3,−1,2) and B(5,3,6).
Differences.5−3=2, 3−(−1)=4 and 6−2=4.
Squares and sum.4+16+16=36.
Root.AB=6.
A point on an axis
A point on the y-axis is (0,t,0). To find the one that is equidistant from C(3,1,2) and D(5,5,4), set the two squared distances equal. That avoids square roots.
PC2=9+(t−1)2+4 and PD2=25+(t−5)2+16.
Set them equal: t2−2t+14=t2−10t+66.
The t2 cancels, so 8t=52 and t=213.
Check. Both squared distances are 43.25 at t=6.5. The point is (0,213,0).
Because the t2 terms cancel, the equation is linear and has one answer.
What the three sides of a triangle tell us
Compute the three squared sides a2, b2, c2 of a triangle and compare.
Equilateral: all three are equal. The points (1,0,0), (0,1,0) and (0,0,1) are an example, with every side 2.
Isosceles: two are equal.
Right-angled: the largest equals the sum of the other two (the converse of Pythagoras). Take A(1,0,2), B(3,1,4) and C(3,−2,1). Then AB2=9, AC2=9 and BC2=18=9+9. The triangle has a right angle at A and two equal sides.
Compare the squared sides. That keeps the arithmetic exact.
Practise with new numbers
Try it in Python
The function distance applies the formula. The program also checks the point (0,6.5,0) against the two points of the example.
Common mistakes
Forgetting the square root. The sum of squares is PQ2, not PQ.
Subtracting the wrong way round. It does not matter, because each difference is squared. A sign slip inside the bracket does matter: 3−(−1)=4, not 2.
Using only two differences. In space every one of the three coordinates counts.
Comparing sides instead of squares. Test a right angle with a2+b2=c2 on the squared sides.
Remember these
PQ2=(x2−x1)2+(y2−y1)2+(z2−z1)2, and PQ is the square root.
For a point (t,0,0), (0,t,0) or (0,0,t) at a given distance, square both sides and solve.
Triangle types come from the squared sides: equal means isosceles or equilateral, and a2+b2=c2 means a right angle.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Find the distance between (0,1,−2) and (4,5,5).
Show that A(1,0,0), B(0,1,0) and C(0,0,1) are the corners of an equilateral triangle, and find its side.
Find the point on the z-axis that is equidistant from A(1,2,3) and B(3,2,5).
Show that A(0,1,1), B(1,3,3) and C(2,3,−2) form a right-angled triangle. At which vertex is the right angle?
The point P(x,2,3) is 7 units from Q(2,−1,1). Find x.
References
NCERT, Mathematics Textbook for Class XI, the chapter Introduction to Three Dimensional Geometry, section on the distance between two points.
OpenStax, Calculus Volume 3, Chapter 2, section 2.2 on vectors in three dimensions.
Enroll free in Distance and Section Formulae in Space
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.