If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

### Course: Basic geometry and measurement>Unit 13

Lesson 4: Pythagorean theorem and distance between points

# Distance formula

Walk through deriving a general formula for the distance between two points.
The $\text{distance}$ between the points $\left({x}_{1},{y}_{1}\right)$ and $\left({x}_{2},{y}_{2}\right)$ is given by the following formula:
$\sqrt{\left({x}_{2}-{x}_{1}{\right)}^{2}+\left({y}_{2}-{y}_{1}{\right)}^{2}}$

## Deriving the distance formula

Let's start by plotting the points $\left({x}_{1},{y}_{1}\right)$ and $\left({x}_{2},{y}_{2}\right)$.
The length of the segment between the two points is the $\text{distance}$ between them:
We want to find the $\text{distance}$. If we draw a right triangle, we'll be able to use the Pythagorean theorem!
An expression for the length of the base is ${x}_{2}-{x}_{1}$:
Similarly, an expression for the length of the height is ${y}_{2}-{y}_{1}$:
Now we can use the Pythagorean theorem to write an equation:
${?}^{2}\phantom{\rule{0.167em}{0ex}}=\left({x}_{2}-{x}_{1}{\right)}^{2}+\left({y}_{2}-{y}_{1}{\right)}^{2}$
We can solve for $?$ by taking the square root of each side:
$?=\sqrt{\left({x}_{2}-{x}_{1}{\right)}^{2}+\left({y}_{2}-{y}_{1}{\right)}^{2}}$
That's it! We derived the distance formula!
Interestingly, a lot of people don't actually memorize this formula. Instead, they set up a right triangle, and use the Pythagorean theorem whenever they want to find the distance between two points.

## Want to join the conversation?

• who came up with this formula?
• The distance formula is a consequence of the Pythagorean Theorem.
• I still don't understand any of this... :I
• I haven't read any of the article on this so I really hope I don't say the exact same thing he says.... here goes:

Here is the graph I am referring to in my explanation: https://www.desmos.com/calculator/juthaysfbl
-- only look at the graph, ignore everything on the sides and bottom --

(intuitive solution, and how I learned this)

Think of the Pythagorean theorem. The formula is a^2 + b^2 = c^2 . Now, imagine two points, let's say they are (0,0) and (3,4) to keep it simple. Look at the blue line going from (0,0) to (3,0). This is the base, with a distance of 3 units. How did we find this? We took one of the x values (3) and subtracted it by the other (0). 3 - 0 = 0. Next, we must find the height. The red line represents it, and it is a length of 4 units. We found this, again, by subtracting the y values (4 - 0 = 0). We can now find the hypotenuse, if we replace a and b with the base height length, so we get 3^2 + 4^2 = c^2 (where c is the orange line, or hypotenuse). The hypotenuse is the distance of the two points.

Of course, we can square root both sides so we get c = sqrt( 3^2 + 4^2). We can expand this even further if we replace the 3 and 4 with how we got there, so c = sqrt( (3 - 0)^2 + (4 - 0)^2). But what do 3 and 0 and 4 and 0 mean? The two x values and y values, respectively. Therefore, we replace the numbers so we get c (hypotenuse) = ( ( x1 - x2) ^2 + (y1 - y2) ^2) .

I really hope this helped you, I spent a long time explaining this lmao...
• The worst feeling in the world is when you lose a point because you "Didn't show your work" like. Ow
• bro why do we have to do this
• I cannot say why you have to, but I can say why this might be useful in the future.
Lets say for whatever reason you needed to make a video game, and let’s also say you needed to calculate the distance between a player and an object in order to make an action occur. I imagine this would be useful for those purposes
• okay I understand all you have to do is take your y axis and divide it by your x axis
• If you were to get two perfect squares under the giant square root after subtracting the two points within each parentheses, would you be able to separate them in order to pull them out of the square root and make them rational?
For example, if I got "the square root of (6)^squared + (6)^squared" would I first square them and get "the square root of 36+36?" or could I separate them into "the square root of 36 + the square root of 36"
• how is the formula the same as the Pythagorean theorem
• The x and the y axis are perpendicular, so if you imagine a right triangle when you find a distance, and the hypotenuse is the distance
• Sooooo, if I have two points, (1, 2) and (-1, 4), it does not matter in which order I subtract as long as I do the x with the x, and so on? Because it doesn't look that way.