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.

Main content

Distance formula

Learn how to find the distance between two points by using the distance formula, which is an application of the Pythagorean theorem. We can rewrite the Pythagorean theorem as d=√((x_2-x_1)²+(y_2-y_1)²) to find the distance between any two points. Created by Sal Khan and CK-12 Foundation.

Want to join the conversation?

Video transcript

In this video, we're going to learn how to take the distance between any two points in our x, y coordinate plane, and we're going to see, it's really just an application of the Pythagorean theorem. So let's start with an example. Let's say I have the point, I'll do it in a darker color so we can see it on the graph paper. Let's say I have the point 3 comma negative 4. So if I were to graph it, I'd go 1, 2, 3, and then I'd go down 4. 1, 2, 3, 4, right there, is 3 comma negative 4. And let's say I also have the point 6 comma 0. So 1, 2, 3, 4, 5, 6, and then there's no movement in the y-direction. We're just sitting on the x-axis. The y-coordinate is 0, so that's 6 comma 0. And what I want to figure out is the distance between these two points. How far is this blue point away from this orange point? And at first, you're like, gee, Sal, I don't think I've ever seen anything about how to solve for a distance like this. And what are you even talking about the Pythagorean theorem? I don't see a triangle there! And if you don't see a triangle, let me draw it for you. Let me draw this triangle right there, just like that. Let me actually do several colors here, just to really hit the point home. So there is our triangle. And you might immediately recognize this is a right triangle. This is a right angle right there. The base goes straight left to right, the right side goes straight up and down, so we're dealing with a right triangle. So if we could just figure out what the base length is and what this height is, we could use the Pythagorean theorem to figure out this long side, the side that is opposite the right angle, the hypotenuse. This right here, the distance is the hypotenuse of this right triangle. Let me write that down. The distance is equal to the hypotenuse of this right triangle. So let me draw it a little bit bigger. So this is the hypotenuse right there. And then we have the side on the right, the side that goes straight up and down. And then we have our base. Now, how do we figure out-- let's call this d for distance. That's the length of our hypotenuse. How do we figure out the lengths of this up and down side and the base side right here? So let's look at the base first. What is this distance? You could even count it on this graph paper, but here, where x is equal to-- let me do it in the green. Here, we're at x is equal to 3 and here we're at x is equal to 6, right? We're just moving straight right. This is the same distance as that distance right there. So to figure out that distance, it's literally the end x point. And you could actually go either way, because you're going to square everything, so it doesn't matter if you get negative numbers, so the distance here is going to be 6 minus 3, right? 6 minus 3. That's this distance right here, which is equal to 3. So we figured out the base. And to just remind ourselves, that is equal to the change in x. That was equal to your finishing x minus your starting x. 6 minus 3. This is our delta x. Now, by the same exact line of reasoning, this height right here is going to be your change in y. Up here, you're at y is equal to 0. That's kind of where you finish. That's your higher y point. And over here, you're at y is equal to negative 4. So change in y is equal to 0 minus negative 4. I'm just taking the larger y-value minus the smaller y-value, the larger x-value minus the smaller x-value. But you're going to see we're going to square it in a second, so even if you did it the other way around, you'd get a negative number, but you'd still get the same answer, so this is equal to 4. So this side is equal to 4. You can even count it on the graph paper if you like. And this side is equal to 3. And now we can do the Pythagorean theorem. This distance is the distance squared. Be careful. The distance squared is going to be equal to this delta x squared, the change in x squared plus the change in y squared. This is nothing fancy. Sometimes people will call this the distance formula. It's just the Pythagorean theorem. This side squared plus that side squared is equal to hypotenuse squared, because this is a right triangle. So let's apply it with these numbers, the numbers that we have at hand. So the distance squared is going to be equal to delta x squared is 3 squared plus delta y squared plus 4 squared, which is equal to 9 plus 16, which is equal to 25. So the distance is equal to-- let me write that-- d squared is equal to 25. d, our distance, is equal to-- you don't want to take the negative square root, because you can't have a negative distance, So it's only the principal root, the positive square root of 25, which is equal to 5. So this distance right here is 5. Or if we look at this distance right here, that was the original problem. How far is this point from that point? It is 5 units away. So what you'll see here, they call it the distance formula, but it's just the Pythagorean theorem. And just so you're exposed to all of the ways that you'll see the distance formula, sometimes people will say, oh, if I have two points, if I have one point, let's call it x1 and y1, so that's just a particular point. And let's say I have another point that is x2 comma y2. Sometimes, you'll see this formula, that the distance-- you'll see it in different ways. But you'll see that the distance is equal to-- and it looks as though there's this really complicated formula, but I want you to see that this is really just the Pythagorean theorem. You see that the distance is equal to x2 minus x1 minus x1 squared plus y2 minus y1 squared. You'll see this written in a lot of textbooks as the distance formula. And it's a complete waste of your time to memorize it because it's really just the Pythagorean theorem. This is your change in x. And it really doesn't matter which x you pick to be first or second, because even if you get the negative of this value, when you square it, the negative disappears. This right here is your change in y. So it's just saying that the distance squared-- remember, if you square both sides of this equation, the radical will disappear and this will be the distance squared is equal to this expression squared, delta x squared, change in x-- delta means change in-- delta x squared plus delta y squared. I don't want to confuse you. Delta y just means change in y. I should have probably said that earlier in the video. But let's apply it to a couple more, and I'll just pick some points at random. Let's say I have the point, let's see, 1, 2, 3, 4, 5, 6. Negative 6 comma negative 4. And let's say I want to find the distance between that and 1 comma 1, 2, 3, 4, 5, 6, 7, and the point 1 comma 7, so I want to find this distance right here. So it's the exact same idea. We just use the Pythagorean theorem. You figure out this distance, which is our change in x, this distance, which is our change in y. This distance squared plus this distance squared is going to equal that distance squared. So let's do it. So our change in x, you just take-- you know, it doesn't matter. In general, you want to take the larger x-value minus the smaller x-value, but you could do it either way. So we could write the distance squared is equal to-- what's our change in x? So let's take the larger x minus the smaller x, 1 minus negative 6. 1 minus negative 6 squared plus the change in y. The larger y is here. It's 7. 7 minus negative 4. 7 minus negative 4 squared. And I just picked these numbers at random, so they're probably not going to come out too cleanly. So we get that the distance squared is equal to 1 minus negative 6. That is 7, 7 squared, and you'll even see it over here, if you count it. You go, 1, 2, 3, 4, 5, 6, 7. That's that number right here. That's what your change in x is. Plus 7 minus negative 4. That's 11. That's this distance right here, and you can count it on the blocks. We're going up 11. We're just taking 7 minus negative 4 to get a distance of 11. So plus 11 squared is equal to d squared. So let me just take the calculator out. So the distance if we take 7 squared plus 11 squared is equal to 170, that distance is going to be the square root of that, right? d squared is equal to 170. So let's take the square root of 170 and we get 13.0, roughly 13.04. So this distance right here that we tried to figure out is 13.04. Hopefully, you found that helpful.