Relevant For...

The distance formula is a formula that is used to find the distance between two points. These points can be in any dimension. For example, you might want to find the distance between two points on a line (1d), two points in a plane (2d), or two points in space (3d).

Contents

Distance in One Dimension

Suppose \(A=x_1\) and \(B=x_2\) are two points lying on the real number line. Then the distance between \(A\) and \(B\) is

\[ d(A,B) = \lvert x_1 - x_2 \rvert. \]

In the plane, we can consider the \(x\)-axis as a one-dimensional number line, so we can compute the distance between any two points lying on the \(x\)-axis as the absolute value of the difference of their \(x\)-coordinates. Similarly, the distance between any two points lying on the \(y\)-axis is the absolute value of the difference of their \(y\)-coordinates.

Now, consider the \(xy\)-plane, and suppose \(P_1 = (x_1, y_1)\) and \(P_2 = (x_2, y_2)\) are two points in it . Then the distance between \(P_1\) and \(P_2\) is

\[ d(P_1, P_2) = \sqrt{(x_1-x_2)^2+(y_1-y_2)^2}.\]

Since \(\lvert x_1 - x_2 \rvert\) is the distance between the \(x\)-coordinates of the two points and \(\lvert y_1 - y_2\rvert\) is the distance between the \(y\)-coordinates of the two points, the distance formula in the \(xy\)-plane can be thought of as the length of the hypotenuse of the right triangle with vertices \(P_1=(x_1,y_1)\), \(P_2 = (x_2,y_2),\) and \(P = (x_2,y_1) \). Then the distance formula is simply a statement of the Pythagorean theorem.

In both 1D and 2D, the distance function satisfies the following properties:

\(d(P,Q) \geq 0\) for all points \( P,Q\) with equality if and only if \(P = Q\)

\(d(P, Q) = d(Q, P) \) for all points \(P,Q\)

\( d(P,Q) \leq d(P, R) + d(R, Q) \) for all points \( P, Q, R\).

What is the distance between the points \((0,5)\) and \((0,13)\)?

Note that both of these points lie on the \(y\)-axis and therefore the distance between the points is the absolute value of the difference of the \(y\)-coordinates, which is \[ \lvert 5 - 13 \rvert = \lvert -8 \rvert =8 .\ _\square\]

To generalize the above problem, if two points \(P_1 = (x_1, y_1) \) and \(P_2 = (x_2, y_2) \) have the same \(x\)-coordinate, i.e. \(x_1=x_2\), then the distance between the two points is \( d(P_1, P_2) = |y_1-y_2|\) and the line segment \(\overline{P_1P_2} \) is a vertical line segment.

Similarly, if \(P_1\) and \(P_2\) have the same \(y\)-coordinate (\(y_1=y_2\)), then \(d(P_1, P_2) = |x_1-x_2|\) and the line segment \(\overline{P_1P_2} \) is a horizontal line segment.

Find the area of the rectangle in the \(xy\)-plane with vertices

\[ A = (6, -3), B=(6, 7), C=(2, 7), \text{ and } D=(2, -3).\]

Points \(A\) and \(B\) have the same \(x\)-coordinate, implying \(d(A,B) = \lvert 7 - (-3) \rvert = 10\). Points \(B\) and \(C\) have the same \(y\)-coordinate, implying \(d(B,C) = \lvert 6 - 2 \rvert = 4\). We check that points \(C\) and \(D\) have the same \(x\)-coordinate and \(D\) and \(A\) have the same \(y\)-coordinate, implying the points are indeed vertices of a rectangle.

The area of the rectangle is then
\[ [ABCD]=AB \cdot BC = 4 \cdot 10 = 40.\ _\square \]

Distance in Two Dimensions

The distance between two points \(P= (x_1, y_1)\) and \(Q= (x_2, y_2)\) can be found using the following formula:

\[PQ = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}.\ _\square\]

Construct a triangle \(\triangle PQR,\) where \(R\) has the coordinates \((x_2, y_1)\).

Then \(\triangle PQR\) is a right angled triangle, and we can apply the Pythagorean theorem to obtain

\[PQ^2 = PR^2 + QR^2.\]

Since \(PQ\) is to be found, and \(PR = |x_1 – x_2|\) and \(QR = |y_1 – y_2|,\) we have