Distance Formula Calculator
The distance between (0, 0) and (3, 4) is 5 units. This distance formula calculator measures the straight-line distance between two points on a two-dimensional Cartesian plane. Enter the x and y coordinates for each point to get the distance plus the signed horizontal and vertical changes. The calculation treats the coordinate differences as the legs of a right triangle. It works with positive, negative, zero, and decimal coordinates. The distance is rounded to no more than 4 decimal places, while the reported changes in x and y keep the direct subtraction results. Use it to check coordinate geometry, graphing, design layouts, or any problem that asks for Euclidean distance in a flat coordinate system.
Quick answer
The distance formula finds the length of the straight line between two points.
What this tells you
- •The distance formula finds the length of the straight line between two points.
- •It uses the horizontal change (x2 - x1) and the vertical change (y2 - y1).
- •The result is the square root of the sum of those two changes squared.
- •Distance is rounded to no more than 4 decimal places, so whole-number results appear without trailing zeros.
- •The signed changes are x2 - x1 and y2 - y1, so either change can be negative even though distance cannot be negative.
- •Identical points have a horizontal change of 0, a vertical change of 0, and a distance of 0.
- •Reversing the order of the points changes the signs of both reported changes but leaves the distance unchanged.
How to Use
- 1Enter the x and y coordinates of the first point (x1, y1).
- 2Enter the x and y coordinates of the second point (x2, y2).
- 3Click Calculate to get the distance between the two points.
- 4Check Change in X and Change in Y to see the signed coordinate differences used by the formula.
- 5Interpret the answer in the same unit used for both coordinate axes. If coordinates are in meters, the distance is in meters.
- 6Keep more than the displayed 4 decimal places elsewhere if a later calculation requires higher numerical precision.
How It Works
Formula
d = sqrt((x2 - x1)^2 + (y2 - y1)^2)The distance formula comes from the Pythagorean theorem. The horizontal change (x2 - x1) and the vertical change (y2 - y1) form the two legs of a right triangle, and the distance between the points is the hypotenuse. Squaring each change, adding them, and taking the square root gives the straight-line distance.
Calculation note: values are processed in the order shown above, using the current input units.
Worked Examples
Distance from (1, 2) to (4, 6)
The change in x is 4 - 1 = 3 and the change in y is 6 - 2 = 4. Square each value to get 9 and 16, add them to get 25, then take the square root to get 5.
Distance from (0, 0) to (5, 12)
The change in x is 5 and the change in y is 12. Square each value to get 25 and 144, add them to get 169, then take the square root to get 13.
Distance across a unit square diagonal
Both coordinate changes equal 1. Squaring and adding gives 1 + 1 = 2, so the exact distance is sqrt(2). The calculator rounds that irrational value to 1.4142.
Distance between identical points
Both differences are zero because the coordinates match. The square root of 0 squared plus 0 squared is 0, so there is no separation between the points.
Second point is lower and left
The reported changes are -3 and -4. Their squares are 9 and 16, so the signs disappear inside the distance calculation and sqrt(25) equals 5.
Example Distances
Common point pairs and the straight-line distance between them.
| Point 1 | Point 2 | Distance |
|---|---|---|
| (0, 0) | (3, 4) | 5 |
| (1, 2) | (4, 6) | 5 |
| (-2, -3) | (1, 1) | 5 |
| (0, 0) | (5, 12) | 13 |
What the coordinate distance represents
The formula measures Euclidean distance, which means the shortest straight segment joining two points on a flat plane. The horizontal difference and vertical difference create perpendicular legs of a right triangle. The segment connecting the points is its hypotenuse, so the Pythagorean theorem gives the length.
Coordinate order affects direction but not length. From (5, 5) to (2, 1), the changes are -3 and -4. From (2, 1) to (5, 5), they are 3 and 4. Squaring produces 9 and 16 in either order, so both directions have distance 5. This is why distance stays non-negative even when one or both coordinate changes are negative.
The answer has the same unit as the coordinate scale when both axes use the same unit. Coordinates measured in feet produce a distance in feet. If one axis uses meters and the other uses feet, convert them to a shared unit before applying the formula. Otherwise, the result has no consistent physical meaning.
A straight-line answer is not always a travel distance. A road, hallway, trail, or grid route may require turns and obstacles. The formula also assumes a flat Cartesian plane. For latitude and longitude across Earth, a spherical or ellipsoidal geodesic method is more appropriate, especially over long distances.
Common mistakes
- Forgetting to square the differences. You must square both the change in x and the change in y before adding them, otherwise the result is wrong.
- Sign errors with negative coordinates. When a coordinate is negative, subtracting it adds a positive value, so 1 - (-2) = 3, not -1.
- Swapping x and y values. Keep the x coordinates together and the y coordinates together, and do not mix a point's x value with the other point's y value.
- Adding coordinates instead of subtracting matching coordinates. The legs are x2 - x1 and y2 - y1, not x1 + x2 and y1 + y2.
- Taking the square root before adding both squared changes. Add the squares first, then take one square root of the total.
- Assuming negative delta values mean a negative distance. The deltas describe direction from point 1 to point 2, while distance describes magnitude.
- Using mixed units on the axes. Convert both coordinate scales to the same unit before interpreting the answer as a physical length.
Embed this calculator on your site
Drop this single line where you want the calculator to appear. It is responsive, mobile-friendly, resizes automatically, and is free to use with attribution.
<script src="https://calctide.com/embed.js" data-tool="distance-formula-calculator" async></script>Preview the embed at /embed/distance-formula-calculator/.