# Distance Formula

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

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

From this proof we can derive tbe following corollary:

The distance of point \(P=(x,y)\) from the origin \(O=(0,0)\) is given by \[OP = \sqrt{{(x-0)}^2 + {(y-0)}^2} = \sqrt{x^2 + y^2}.\]

## What is the distance between the two points \((1,7)\) and \((3, 2)\) ?

The distance is \(\sqrt{(1-3)^2 + (7-2)^2}\) \(=\sqrt{4 + 25}\) \(=\sqrt{29}.\) \( _\square\)

## Find the sum of all \(a\) such that the distance between the points \((3,4)\) and \((6, a)\) is \(5\).

Using the above formula we get

\[5 = \sqrt{(3-6)^2 + (4-a)^2}.\]

Squaring both sides and on simplifying, we get

\[\begin{align} 25 &= 9 + (a-4)^2\\ (a-4)^2 &= 16\\ a-4 &= 4 ~\text{ or }~ a - 4 = -4\\ a &= 8 ~\text{ or }~ a = 0. \end{align}\]

Therefore the sum of possible values of \(a\) is \(8 + 0 = 8. \ _\square\)

## Find the distance between the points \(A=(2,3)\) and \(B=(5,7)\).

\[\begin {align} AB & = \sqrt{{(x_2 - x_1)}^2 + {(y_2 - y_1)}^2}\\ & = \sqrt{{(5-2)}^2 + {(7-3)}^2}\\ & = \sqrt{3^2 + 4^2}\\ & = \sqrt{9+16}\\ & = \sqrt{25}\\ & =5.\ _\square \end{align}\]

## Find the distance of the point \(P=(7,1)\) from the origin.

\[\begin{align} OP & = \sqrt{x^2 + y^2}\\ & = \sqrt{7^2 + 1^2}\\ & = \sqrt{49 + 1}\\ & = \sqrt{50}\\ & = 5\sqrt{2}.\ _\square \end{align}\]

## Identifying Figures by Joining Graph Points

Sometimes we are given four points and asked to comment on the nature of the quadrilateral which is formed by joining them. For this, we have to recall the following:

A quadrilateral is a

- rectangle, if its opposite sides are equal and diagnols are equal;
- square, if all its sides are equal and diagnols are equal;
- parallelogram, if its oppoaite sides are equal;
- rhombus, if its sides are equal.

## Show that the points \(A=(-3,0) , B=(1,-3) , C=(4,1)\) are the vertices of an isosceles right-angled triangle. Also find the area of the triangle.

We have

\[\begin{align} AB & = \sqrt{{(1-(-3))}^2 + {(-3-0)}^2}\\ & = \sqrt{4^2 + {(-3)}^2}\\ & = \sqrt{16 + 9}\\ & = \sqrt{25} = 5\\\\ BC & = \sqrt{{(4-1)}^2 + {(1-(-3)/)}^2}\\ & = \sqrt{3^2 + {4}^2}\\ & = \sqrt{9 + 16}\\ & = \sqrt{25}= 5\\\\ CA & = \sqrt{{(4-(-3))}^2 + {(1-0)}^2}\\ & = \sqrt{7^2 + {1}^2}\\ & = \sqrt{49 + 1}\\ & = \sqrt{50} = 5\sqrt{2}. \end{align}\]

Since \(AB=BC,\) the triangle is isosceles.

Moreover, since \({AB}^2 + {BC}^2 = 5^2 + 5^2= 50 = {CA}^2,\) it is right-angled.Now, the area of the triangle is \[\begin{align} \text{(Area of ABC)} & = \dfrac{1}{2} × AB × BC\\ & = \dfrac{1}{2} × 5 ×5\\ & = 12.5.\ _\square \end{align}\]

## Show that the points \(A=(2,-2) , B=(8,4) , C=(5,7) , D=(-1,1)\) are the vertices of a rectangle. Also find the area of the rectangle.

We have \[\begin{align} AB = \sqrt{{(8-2)}^2 + {(4+2)}^2}& = \sqrt{72} \\&= 6\sqrt{2}\\ BC = \sqrt{{(5-8)}^2 + {(7-4)}^2}& = \sqrt{18} \\&= 3\sqrt{2}\\ CD = \sqrt{{(-1-5)}^2 + {(1-7)}^2}& = \sqrt{72}\\& = 6\sqrt{2}\\ DA = \sqrt{{(2+1)}^2 + {(-2-1)}^2}& = \sqrt{18}\\& = 3\sqrt{2}, \end{align}\] which implies \(AB = CD\) and \(BC = DA,\) i.e. \(ABCD\) is a quadrilateral whose opposite sides are equal.

Now, since we have \[\begin{align} AC = \sqrt{{(5-2)}^2 + {(7+2)}^2} & = \sqrt{90}\\& = 3\sqrt{10}\\ BD = \sqrt{{(-1-8)}^2 + {(1-4)}^2} & = \sqrt{90}\\& = 3\sqrt{10}, \end{align}\] \(AC = BD,\) which implies \(ABCD\) is a quadrilateral whose diagonals are equal.

Hence, \(ABCD\) is a rectangle, and its area is

\[\begin{align} \text{(Area of ABCD)} & = AB × BC\\ & = 6\sqrt{2} × 3\sqrt{2}\\ & = 36.\ _\square \end{align}\]

## Show that four points in a plane \(A=(-3,2), B=(-5,-5), C=(2,-3), D=(4,4)\) form a rhombus \(ABCD\) which is not a square. Find the area of the rhombus.

We have \[\begin{align} AB = \sqrt{{(-5-(-3))}^2 + {(-5-2)}^2} & = \sqrt{53}\\ BC = \sqrt{{(2-(-5))}^2 + {(-3-(-5)}^2}& = \sqrt{53}\\ CD = \sqrt{{(4-2)}^2 + {(4-(-3))}^2}& = \sqrt{53}\\ DA = \sqrt{{(-3-4)}^2 + {(2-4)}^2}& = \sqrt{53}, \end{align}\] which implies that \(AB = BC = CD = DA,\) i.e. \(ABCD\) is either a rhombus or a square.

Now, since we have \[\begin{align} AC = \sqrt{{(2-(-3))}^2 + {(-3-2)}^2} & = \sqrt{25 + 25}\\& = 5\sqrt{2}\\ BD = \sqrt{{(4-(-5))}^2 + {(4-(-5))}^2}& = \sqrt{81 + 81}\\& = 9\sqrt{2}, \end{align}\] \(AC \neq BD,\) which implies that \(ABCD\) is a rhombus but not a square.

The area of rhombus \(ABCD\) is \[\begin{align} \text{(Area of rhombus ABCD)} & = \dfrac{1}{2} × AC × BD\\ & = \dfrac{1}{2} × 5\sqrt{2} × 9\sqrt{2}\\ & = 45.\ _\square \end{align}\]

## Other examples

## Show by the distance formula that \(A=(-1,-1) ,B=(2,3) , C=(8,11)\) are collinear.

We have \[\begin{align} AB = \sqrt{{(2-(-1))}^2 + {(3-(-1))}^2} = \sqrt{9+16}& =5 \\ BC = \sqrt{{(8-2)}^2 + {(11-3)}^2} = \sqrt{36+64}& = 10 \\ AC = \sqrt{{(8-(-1))}^2 + {(11-(-1))}^2} = \sqrt{81+144}& = 15, \end{align}\] so \(AB + BC = AC,\) which implies that the given points are collinear. \(_\square\)

## Find a point on the \(y\)-axis which is equidistant from the points \(A=(-3,4)\) and \(B=(7,6)\).

Since the point lies on the \(y\)-axis, the \(x\)-coordinate is \(0\). Let \(P=(0,y)\) be the required point on the \(y\)-axis which is equidistant from the given points. Then,

\[\begin{align} PA & = PB\\ {PA}^2 & = {PB}^2\\ {(-3-0)}^2 + {(4-y)}^2 & = {(7-0)}^2 + {(6-y)}^2\\ {(-3)}^2 + {(4-y)}^2 & = 7^2 + {(6-y)}^2\\ 9 + 16 + y^2 - 8y & = 49 + 36 + y^2 - 12y\\ 4y & = 60\\ y & = \dfrac{60}{4}\\ y & = 15. \end{align}\]

Hence, the required point is \((0,15).\) \(_\square\)

**Cite as:**Distance Formula.

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/distance-formula/