From Coordinates to Distance
In three-dimensional Cartesian coordinates, a point is specified by three numbers. Those numbers tell us where the point lies along three mutually perpendicular coordinate axes. To find the straight-line distance between two points, we must combine their differences in all three coordinate directions.
The Pythagorean theorem provides the key. In a right triangle, the square of the hypotenuse equals the sum of the squares of the two leg lengths. In space, we can apply this theorem first in a coordinate plane and then in a second right triangle involving the remaining coordinate direction.
This gives a distance formula that works for any pair of points in three-dimensional space. It also gives a direct way to test whether a point lies on a sphere: measure its distance from the sphere’s center and compare that distance with the radius.
The Three-Dimensional Distance Formula
The order of subtraction in each coordinate difference does not affect the result, because each difference is squared. For example, \((x_2-x_1)^2=(x_1-x_2)^2\). The formula therefore gives a nonnegative distance and gives distance zero when the two points have identical coordinates.
Each coordinate difference records how far apart the points are in one direction. The \(x\)-coordinate difference is \(x_2-x_1\), the \(y\)-coordinate difference is \(y_2-y_1\), and the \(z\)-coordinate difference is \(z_2-z_1\). Squaring and adding these three differences combines the contributions from all three perpendicular directions.
Why the Formula Works
Consider the points \(P=(x_1,y_1,z_1)\) and \(Q=(x_2,y_2,z_2)\). First, move from \(P\) to a point \(R=(x_2,y_2,z_1)\). This movement changes the \(x\)- and \(y\)-coordinates but leaves the \(z\)-coordinate fixed, so \(P\), \(R\), and \(Q\) form a right-triangle arrangement: the segment from \(P\) to \(R\) lies in a horizontal coordinate plane, while the segment from \(R\) to \(Q\) is parallel to the \(z\)-axis. These directions are perpendicular.
Within the horizontal plane, the two coordinate changes from \(P\) to \(R\) are perpendicular. By the two-dimensional Pythagorean theorem, the square of the length \(PR\) is the sum of the squares of those changes. A second application of the theorem combines \(PR\) with the vertical change \(z_2-z_1\) to give the distance \(PQ\).
The coordinate changes from \(P\) to \(R\) are \(x_2-x_1\) and \(y_2-y_1\). Thus \(PR^2=(x_2-x_1)^2+(y_2-y_1)^2\).
The segment \(RQ\) has length \(|z_2-z_1|\), and it is perpendicular to \(PR\). Therefore \(PQ^2=PR^2+(z_2-z_1)^2\).
Substituting the expression for \(PR^2\) gives \(PQ^2=(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2\). Since distance is nonnegative, \(PQ\) is the nonnegative square root of this sum.
Combining the two applications of the Pythagorean theorem proves the formula:
The argument depends on the coordinate directions being mutually perpendicular, as they are in the standard Cartesian coordinate system. The square root is necessary because the equation from the Pythagorean theorem first determines the square of the distance.
Worked Distance Calculations
Worked Example: Distance Between Points with Negative Coordinates
Find the distance between \(P=(1,-2,3)\) and \(Q=(4,2,-1)\).
Subtract the coordinates in corresponding positions:
Substitute the differences into the formula and evaluate each square:
Thus the distance is exactly \(\sqrt{41}\) units. To check, the squared coordinate differences add to \(9+16+16=41\), so squaring the stated distance gives \((\sqrt{41})^2=41\), as required by the formula.
Worked Example: A Distance Along a Coordinate Plane
Find the distance between \(A=(1,2,3)\) and \(B=(4,6,3)\).
The coordinate differences are \(4-1=3\), \(6-2=4\), and \(3-3=0\). The points share the same \(z\)-coordinate, so their separation lies in a plane parallel to the \(xy\)-plane.
The distance is \(5\) units. Checking the result by squaring gives \(5^2=25\), and the sum of the three squared coordinate differences is also \(25\).
Using Distance to Test Sphere Membership
A sphere with center \(C\) and radius \(r\) consists of exactly those points whose distance from \(C\) is \(r\). Here \(r\) is nonnegative. Consequently, to test whether a given point \(P\) lies on a sphere, calculate \(d(C,P)\) and compare it with \(r\). If the values are equal, \(P\) lies on the sphere; if they differ, it does not.
The squared-distance version often avoids evaluating a square root. To use it, calculate the sum of the squared coordinate differences from the center to the point, and compare that sum with the square of the radius. Equality means the point is on the sphere. A sum less than \(r^2\) means the point is closer to the center than the radius; a sum greater than \(r^2\) means it is farther away.
Worked Example: Testing Two Points Against a Sphere
A sphere has center \(C=(1,-2,2)\) and radius \(5\). Determine whether \(A=(4,2,2)\) and \(B=(1,2,2)\) lie on the sphere.
For \(A\), the coordinate differences from the center are \(4-1=3\), \(2-(-2)=4\), and \(2-2=0\). Therefore,
The radius is \(5\), so \(d(C,A)=5\) and \(A\) lies on the sphere. Substitution into the squared test confirms this: \(3^2+4^2+0^2=25=5^2\).
For \(B\), the coordinate differences are \(1-1=0\), \(2-(-2)=4\), and \(2-2=0\). Thus,
Since \(4\ne5\), the point \(B\) does not lie on the sphere. The squared test gives the same conclusion: \(0^2+4^2+0^2=16\ne25=5^2\).
A Common Calculation Mistake
A frequent error is to forget that every coordinate difference must be squared. For example, consider the origin \(O=(0,0,0)\) and the point \(P=(3,4,12)\). An incorrect calculation might leave the last difference unsquared and write:
This does not follow from the distance formula: the \(z\)-coordinate difference is \(12-0=12\), and its contribution must be \(12^2\), not \(12\). The correct calculation is:
Checking by squaring confirms the answer: \(13^2=169\), which equals \(9+16+144\). Writing the coordinate differences in parentheses before squaring helps prevent this mistake, especially when coordinates are negative.
Why the Formula Is Useful
The distance formula turns a geometric question about separation into a calculation with coordinates. Its usefulness depends on including all three coordinate directions, even when one or more differences are zero. A zero difference simply contributes zero to the sum; it does not require a different formula.
For sphere membership, the formula converts a spatial condition into a numerical equality. The point must be exactly one radius away from the center—not merely close to it. Using squared distances makes the test efficient, while comparing actual distances makes its geometric meaning clear.
When calculating, keep the coordinates paired correctly: subtract \(x\)-coordinates from \(x\)-coordinates, \(y\)-coordinates from \(y\)-coordinates, and \(z\)-coordinates from \(z\)-coordinates. Then square each difference, add the results, and take the nonnegative square root if the distance itself is required. If only a sphere-membership decision is needed, compare the sum directly with the squared radius.
Check Your Understanding
Use the distance formula and the sphere test to answer the following questions.
- Find the distance between \((0,1,-2)\) and \((2,4,4)\).
- Explain why the coordinate differences are squared in the three-dimensional distance formula.
- A point is \(3\) units from a sphere’s center, and the sphere’s radius is \(4\). Does the point lie on the sphere? Explain using the defining test.
- For a sphere of radius \(6\), what squared-distance value from the center must a point have to lie on the sphere?
- Identify the error in using \(\sqrt{2^2+(-5)^2+7}\) as the distance from the origin to \((2,-5,7)\), and give the correct expression.