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

Walk through deriving a general formula for the distance between two points.
The distance between the points (x1,y1) and (x2,y2) is given by the following formula:
(x2x1)2+(y2y1)2
In this article, we're going to derive this formula!

Deriving the distance formula

Let's start by plotting the points (x1,y1) and (x2,y2).
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two.
The length of the segment between the two points is the distance between them:
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points.
We want to find the distance. If we draw a right triangle, we'll be able to use the Pythagorean theorem!
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points. A third unlabeled point is at x two, y one with a line connecting from it to the point at x two, y two and another line connecting from it to the point at x one, y one forming a right triangle.
An expression for the length of the base is x2x1:
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points. A third unlabeled point is at x two, y one with a line connecting from it to the point at x two, y two and another line connecting from it to the point at x one, y one forming a right triangle. The hypotenuse of the right triangle is unknown and the side made from the point at x one, y one and x two, y one is labeled x two minus x one.
Similarly, an expression for the length of the height is y2y1:
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points. A third unlabeled point is at x two, y one with a line connecting from it to the point at x two, y two and another line connecting from it to the point at x one, y one forming a right triangle. The hypotenuse of the right triangle is unknown and the side made from the point at x one, y one and x two, y one is labeled x two minus x one. The third side is labeled y two minus y one.
Now we can use the Pythagorean theorem to write an equation:
?2=(x2x1)2+(y2y1)2
We can solve for ? by taking the square root of each side:
?=(x2x1)2+(y2y1)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?