Key takeaways
- It is the Pythagorean theorem. The horizontal and vertical gaps are the legs; the distance is the hypotenuse.
- Distance is never negative. Squaring removes the signs, so a leftward or downward move counts the same as the reverse.
- Coordinates carry the unit. If x and y are in meters, the answer is in meters — not square meters.
- The midpoint is a separate average. It is ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2), not half the distance.
- Flat and round are different. Latitude and longitude are angles on a curved surface, so this formula drifts over long spans.
The formula is the Pythagorean theorem
Two points on a coordinate plane define a right triangle. The horizontal leg is dx = x₂ − x₁ and the vertical leg is dy = y₂ − y₁, so the straight-line distance is d = √(dx² + dy²). Squaring does two jobs at once: it removes the sign of a negative gap and it applies the theorem. That is why swapping the two points changes the signs of dx and dy but never the distance.
The formula assumes a flat plane with equal spacing on both axes. On graph paper that is exactly true, because one unit is one square in each direction. On a chart with different axis scales, or on a map, the number is only as good as that assumption.
Worked example: (1, 2) to (4, 6)
Here dx = 4 − 1 = 3 and dy = 6 − 2 = 4. Distance = √(3² + 4²) = √(9 + 16) = √25 = 5. This is the classic 3-4-5 triangle, and it is worth remembering because it appears constantly in layouts and checks. The midpoint is ((1 + 4) ÷ 2, (2 + 6) ÷ 2) = (2.5, 4), which sits exactly halfway along the segment.
Notice what the answer is not. It is not 3 + 4 = 7, which would be the distance travelled along a grid of streets. It is not 3 or 4 alone, which are the separate gaps. The straight line is always shorter than or equal to any route that follows the axes, and equality holds only when one gap is zero.
Negative coordinates: (−2, 5) to (3, −1)
Signs are where most errors appear, so work the gaps carefully. dx = 3 − (−2) = 5 and dy = −1 − 5 = −6. Then d = √(25 + 36) = √61 ≈ 7.81. The midpoint is ((−2 + 3) ÷ 2, (5 + (−1)) ÷ 2) = (0.5, 2). The negative dy says the second point lies below the first; it does not reduce the distance, because (−6)² = 36.
A common slip is to subtract in a mixed order, taking x₂ − x₁ for one gap and y₁ − y₂ for the other. The signs then disagree, but since both gaps are squared the final distance is still correct. The midpoint is not so forgiving, and neither is the slope, so keep a consistent direction: always second point minus first.
Horizontal and vertical segments
When the y values match, dy = 0 and the distance is |dx|. When the x values match, dx = 0 and the distance is |dy|. From (2, 7) to (2, 10) the distance is 3, a vertical segment. When one gap is zero the square root simplifies to the other gap, which is a quick check that the formula is being applied correctly.
Identical points give a distance of zero, the only case where that happens; a zero result usually means the coordinates were entered twice.
The midpoint
The midpoint is the average of each coordinate: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). For (−2, 5) and (3, −1) it is (0.5, 2), which lies 3.81 units from each endpoint — half of √61. The midpoint is useful for centering an object, splitting a run of material, or checking symmetry, and it is not the same as half the distance, which is a single number.
Because the midpoint averages, it is always exactly halfway regardless of the order of the points, and it stays inside the segment even when both coordinates are negative.
Units, scale, and map measurements
The result carries whatever unit the coordinates carry. Coordinates in feet give a distance in feet; coordinates in meters give meters. Both axes must use the same unit, because mixing them makes the squares incomparable. If x is in feet and y in inches, convert one first: 24 inches becomes 2 feet, and the distance is then in feet.
On a scaled map, measure in map units and multiply by the scale. At 1:24,000, two inches on the paper represents 2 × 24,000 = 48,000 inches, which is 4,000 feet, about 0.76 mile or 1,219 meters. To go the other way, a mile on the ground is 5,280 feet, or 1.609344 kilometers. Those conversions are exact by definition, so any mismatch comes from measurement, not from the factors.
Latitude, longitude, and the flat-plane limit
Latitude and longitude are angles, not distances, so treating them as x and y is an approximation that fails at scale. One degree of latitude is about 111 kilometers, or 69 miles, nearly everywhere. One degree of longitude is also about 111 kilometers at the equator but only about 56 kilometers at 60° latitude, because the lines of longitude converge toward the poles. A flat-plane calculation that works across a room can be off by hundreds of kilometers across a continent.
For anything beyond a local site plan, use a projected coordinate system or a great-circle formula. Earth’s mean radius is about 6,371 kilometers, and a great-circle distance uses spherical trigonometry rather than the Pythagorean theorem. The straight-line formula remains correct for short spans, which is why it is standard in surveying grids, floor plans, and computer graphics.
Rounding and exact forms
Keep the radicals until the last step. √61 ≈ 7.8102, and rounding it to 7.8 before using it in a further calculation introduces about 0.13% error. Square the full gaps first. Two gaps of 1.41421 give a distance of 2, but rounding each to 1.4 gives √(1.96 + 1.96) ≈ 1.98 — a 1% miss from a rounding at the first decimal.
Two decimal places are sensible for most measurements, one for rough estimates, and three or more only when the coordinates themselves are that precise. If the input coordinates are whole numbers, an exact radical such as √61 is often more informative than 7.81, because it shows the work and avoids a false sense of precision.
Common mistakes
- Adding dx and dy instead of squaring and taking the root, which gives a Manhattan route rather than a straight line.
- Using latitude and longitude as flat coordinates over long distances.
- Mixing units on the two axes, so feet and inches are squared together.
- Reporting the answer in square units, which describes area rather than length.
- Rounding each gap before squaring, which compounds error.
- Treating dx or dy alone as the distance when the other gap is not zero.
- Subtracting coordinates in inconsistent orders and then reading direction from the result.
When to use a different distance
Three relatives of this formula cover cases it cannot. A three-dimensional distance adds a third gap: from (1, 2, 3) to (4, 6, 15), dx = 3, dy = 4, and dz = 12, so d = √(9 + 16 + 144) = √169 = 13. A Manhattan or taxicab distance sums the absolute gaps, which is the right model for travel on a street grid; it gives 7 for the first example instead of 5. A great-circle distance replaces the plane with a sphere and is the correct choice for navigation and mapping.
Pick the model before you pick the formula. A floor plan, a screen layout, and a survey grid are flat enough for the Pythagorean version. A shipping route or a flight path is not, and needs a geodesic calculation or a route measured along the actual path.
Frequently asked questions
Can the distance between two points be negative?
No. Both gaps are squared, so the value under the root is zero or positive, and the principal square root is never negative.
Does the order of the points matter?
Not for distance. Swapping the points flips both signs, and the squares are unchanged. The midpoint is also unchanged, but dx, dy, and slope reverse.
How do I find the distance from a point to the origin?
Use (0, 0) as one point. For (3, 4) the distance is √(9 + 16) = 5; for (−3, 4) it is also 5.
Why is my GPS distance different from this calculation?
GPS coordinates are angles on a curved Earth. Over short spans the difference is small; over a region it grows, especially at high latitudes.
What is the difference between distance and displacement?
Distance is the length of the path; displacement is the straight-line gap between start and end. A round trip has displacement zero but a large distance.
How precise should the answer be?
Match the precision of the coordinates. Whole-number inputs rarely justify more than two decimal places, and an exact radical is often better.
Further reading