Skip to main content
K12 LibreTexts

4.39: The Distance Formula and Algebra

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Using the Pythagorean Theorem to determine distances

    Suppose you and your friend were on a scavenger hunt. Starting out from the same place, you walked 5 blocks east and 3 blocks north. Your friend walked 7 blocks west and 2 blocks south. If each block were a tenth of a mile long, could you calculate how far apart you and your friend were? How would you do it?

    The Distance Formula

    To understand the distance formula, we will first look at the following problem:

    Find the length of the segment connecting \((1, 5)\) and \((5, 2)\).

    Figure \(\PageIndex{1}\)

    The question asks you to identify the length of the segment. Because the segment is not parallel to either axis, it is difficult to measure given the coordinate grid.

    However, it is possible to think of this segment as the hypotenuse of a right triangle. Draw a vertical line and a horizontal line. Find the point of intersection. This point represents the third vertex in the right triangle.

    Figure \(\PageIndex{2}\)

    You can easily count the lengths of the legs of this triangle on the grid. The vertical leg extends from \((1, 2)\) to \((1, 5)\), so it is \(\mid5−2\mid=\mid3\mid=3\: units\) long. The horizontal leg extends from \((1, 2)\) to \((5, 2)\), so it is \(\mid5−1\mid=\mid4\mid=4\: units\) long. Use the Pythagorean Theorem with these values for the lengths of each leg to find the length of the hypotenuse.

    \(\begin{aligned} a^2+b^2 & =c^2 \\ 3^2+4^2 & =c^2 \\ 9+16 & =c^2 \\ 25 & =c^2 \\ \sqrt{25} & =\sqrt{c^2} \\ 5 & = c\end{aligned}\)

    The segment connecting \((1, 5)\) and \((5, 2)\) is 5 units long.

    Mathematicians have simplified this process and created a formula that uses these steps to find the distance between any two points in the coordinate plane. If you use the distance formula, you don’t have to draw the extra lines.

    The distance formula states: Given points \((x_1,y_1)\) and \((x_2,y_2)\), the length of the segment connecting those two points is \(d=\sqrt{\left(y_{2}-y_{1}\right)^{2}+\left(x_{2}-x_{1}\right)^{2}}\).

    Let's use the distance formula to complete the following problems:

    1. Find the distance between \((–3, 5)\) and \((4, –2)\).

    Use the distance formula. Let \((x_1,y_1)=(−3,5)\) and \((x_2,y_2)=(4,−2)\).

    d=\sqrt{(-2-5)^{2}+(4-(-3))^{2}} \rightarrow \sqrt{(-7)^{2}+7^{2}} \\
    d=\sqrt{98}=7 \sqrt{2} \text { units }

    1. At 8 a.m. one day, Amir decides to walk in a straight line on the beach. After two hours of making no turns and traveling at a steady rate, Amir was two miles east and four miles north of his starting point. How far did Amir walk and what was his walking speed?
    Figure \(\PageIndex{3}\)

    Plot Amir’s route on a coordinate graph. We can place his starting point at the origin, \(A=(0,0)\). Then, his ending point will be at the point \(B=(2,4)\). The distance can be found with the distance formula.

    \(\begin{aligned} d&=\sqrt{(4−0)^2+(2−0)^2}=\sqrt{(4)^2+(2)^2}=\sqrt{16+4}=\sqrt{20} \\ d &=4.47\text { miles } \end{aligned} \).

    Since Amir walked 4.47 miles in 2 hours, his speed is:

    \(Speed=\dfrac{4.47 \text{ miles }}{2 \text{ hours }}=2.24 \: mi/h\)

    Example \(\PageIndex{1}\)

    Earlier, you were told that on a scavenger hunt, starting out from the same place, you walked 5 blocks east and 3 blocks north and your friend walked 7 blocks west and 2 blocks south. Each block is a tenth of a mile long. How far apart were you and your friend?


    It may be helpful to draw a graph to visualize the situation. Assuming that the starting point was at (0,0) and the distance between each point is equal to one block, if you walked 5 blocks east and 3 blocks north, your coordinates would be \((-5, 3)\). Your friend walked 7 blocks west and 2 blocks south, so their coordinates would be \((7,-2)\)

    Figure \(\PageIndex{4}\)

    Now, you can calculate the distance between these two points using the distance formula. All you need to do is plug the points into the formula and solve.

    \(\begin{aligned} d&=\sqrt{\left(y_{2}-y_{1}\right)^{2}+\left(x_{2}-x_{1}\right)^{2}} \\

    d&=\sqrt{(−2−3)^2+(7−(−5))^2}\rightarrow \sqrt{(−5)^2+12^2} \\


    You and your friend are 13 units away from each other. Since each block is a tenth of a mile long, you can multiply 13 by one tenth to get the actual distance.

    \(13 \times \dfrac{1}{10}=\dfrac{13}{10}=1.3\)

    You and your friend are 1.3 miles away from each other.

    Example \(\PageIndex{2}\)

    Point \(A=(6,−4)\) and point \(B=(2,k)\). What is the value of \(k\) such that the distance between the two points is 5?


    Use the distance formula.

    \(d=\sqrt{(y_1−y_2)^2+(x_1−x_2)^2}\Rightarrow 5=\sqrt{(4−k)^2+(6−2)^2}\)

    \(\begin{aligned} Square\: both \:sides \:of \:the \:equation. &\qquad& 5^2&=[\sqrt{(4−k)^2+(6−2)^2}]^2 \\

    Simplify.&\qquad& 25&=(−4−k)^2+16 \\ Eliminate\: the \:parentheses. &\qquad& 0&=k^2+8k+16−9 \\

    Simplify.&\qquad& 0&=k^2+8k+7 \\

    Find \:k \:using \:the \:quadratic \:formula. & \qquad& k&=\dfrac{−8\pm\sqrt{64−28}}{2}=\dfrac{−8\pm\sqrt{36}}{2}=\dfrac{−8\pm6}{2}\end{aligned}\)

    \(k=−7\) or \(k=−1\). There are two possibilities for the value of k. Let’s graph the points to get a visual representation of our results.

    Figure \(\PageIndex{5}\)


    In 1–10, find the distance between the two points.

    1. \((x_1,y_1)\) and \((x_2,y_2)\)
    2. \((7, 7)\) and \((–7, 7)\)
    3. \((–3, 6)\) and \((3, –6)\)
    4. \((–3, –1)\) and \((–5, –8)\)
    5. \((3, –4)\) and \((6, 0)\)
    6. \((–1, 0)\) and \((4, 2)\)
    7. \((–3, 2)\) and \((6, 2)\)
    8. \((0.5, –2.5)\) and \((4, –4)\)
    9. \((12, –10)\) and \((0, –6)\)
    10. \((2.3, 4.5)\) and \((–3.4, –5.2)\)
    1. Find all points having an x-coordinate of –4 and whose distance from point \((4, 2)\) is 10.
    2. Find all points having a y-coordinate of 3 and whose distance from point \((–2, 5)\) is 8.
    3. Michelle decides to ride her bike one day. First she rides her bike due south for 12 miles, and then the direction of the bike trail changes and she rides in the new direction for a while longer. When she stops, Michelle is 2 miles south and 10 miles west of her starting point. Find the total distance that Michelle covered from her starting point.

    Mixed Review

    1. Solve \((x−4)^2=121\).
    2. What is the \(GCF\) of \(21ab^4\) and \(15a^7b^2\)?
    3. Evaluate \(_10C_7\) and explain its meaning.
    4. Factor \(6x^2+17x+5\).
    5. Find the area of a rectangle with a length of \((16+2m)\) and a width of \((12+2m)\).
    6. Factor \(x^2−81\).

    Review (Answers)

    To see the Review answers, open this PDF file and look for section 11.7.


    Term Definition
    Distance Formula The distance between two points \)(x_1,y_1)\) and \)(x_2,y_2)\) can be defined as \)d=\sqrt{(x_2−x_1)^2+(y_2−y_1)^2}\).
    Midpoint Formula The midpoint formula says that for endpoints \((x_1,y_1)\) and \((x_2,y_2)\), the midpoint is \((\dfrac{x_1+x_2}{2}, \dfrac{y_1+y_2}{2})\).

    Additional Resources

    Interactive Element

    Video: Distance Formula

    Activities: Distance Formula Discussion Questions

    Practice: The Distance Formula and Algebra

    Real World: SF Map - PythThm

    This page titled 4.39: The Distance Formula and Algebra is shared under a CK-12 license and was authored, remixed, and/or curated by CK-12 Foundation via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    CK-12 Foundation
    CK-12 Foundation is licensed under CK-12 Curriculum Materials License
    • Was this article helpful?