What's the Distance Formula?

••• forrest9/iStock/GettyImages

Distance is an important concept both in mathematics and the real world. Of course, measuring real-world distances is typically easier than distances in math; all that you have to do is use a tool like a ruler or odometer to get the actual distance measurement. Given that scales can vary, however, the same technique won't work when measuring distances mathematically. The formula used to calculate distance depends on whether you're measuring distance over time or a distance between two points on a plane.

TL;DR (Too Long; Didn't Read)

The formula for distance over time is Distance = Rate × Time. The formula for distance between two points is Distance = √((x2 - x1)2 + (y2 - y1)2).

Distance Over Time

If you need to calculate the distance between two locations while traveling, this means you're calculating distance over time. The calculation assumes that you're moving at a constant rate and that your movement will occur over a set period of time. If you know these two elements, the distance traveled over that period of time is simply a matter of multiplying the two.

Distance Over Time Formula

The formula to calculate distance over a period of time is Distance = Rate × Time. To give an example of this, if you're traveling 60 miles per hour (mph) and drive for two and a half hours (2.5 h), you can calculate the distance traveled as Distance = 60 × 2.5. This gives a total distance of 150 miles (since miles per hour is essentially a fraction of m/h and hours can be shown as a fraction of h/1, the two time factors cancel out and leave only miles). You can also use this formula to calculate rate or time as needed, transforming it to Rate = Distance ÷ Time or Time = Distance ÷ Rate for whichever calculation you need.

Distance Between Points

If you're working on a two-dimensional graph, the distance formula is a bit different. Since neither time nor rate are involved in static graphs, you'll instead need to calculate the distance between two points based on their x and y coordinates. The formula here is actually based on the Pythagorean Theorem, as you're essentially calculating one side of a triangle based on its two corner points. You'll take the differences between the x coordinates and between the y coordinates, then square those results and add them. The square root of your final result is the distance between those points.

Distance Between Points Formula

The formula for this calculation is Distance = √((x2 - x1)2 + (y2 - y1)2), where the first point is represented by (x1,y1), and the second point is represented by (x2,y2). To give an example, say you're trying to find the distance between the points (1,3) and (4,4). Putting those numbers in the formula, you have Distance = √(4 - 1)2 + (4 - 3)2. From here your start the math within the parentheses, giving you Distance = √(3)2 + (1)2 and then Distance = √(9 + 1). The distance ends up being √10, which works out to around 3.16.


About the Author

Holding a BS in computer science and several years of experience building, repairing and maintaining computers and electronics, Jack Gerard has had a love of science and mathematics for years. When not working on writing projects as part of his 15+ year career, he also works as a programmer writing gaming and accessibility software.