Skip to content
Calculator Collection

Distance Formula Calculator

Calculate the straight-line distance between two points on a coordinate plane using √((x₂−x₁)² + (y₂−y₁)²). A direct application of the Pythagorean theorem.

Last updated: May 2026

Compare with similar

About this calculator

The distance formula finds the straight-line (Euclidean) distance between two points (x₁, y₁) and (x₂, y₂) on a coordinate plane. It is d = √((x₂ − x₁)² + (y₂ − y₁)²). The formula is a direct application of the Pythagorean theorem: the horizontal difference (x₂ − x₁) and the vertical difference (y₂ − y₁) form the two legs of a right triangle, and the distance between the points is the hypotenuse. You square each difference (which also makes the result positive regardless of direction), add them, and take the square root. The order of subtraction does not matter because each difference is squared, eliminating any negative sign. The distance is always non-negative, and it is zero only when the two points are identical. This formula is foundational in geometry, computer graphics, physics, navigation, and machine learning, where 'Euclidean distance' measures how far apart two points or data vectors are. Edge cases: if the points share an x-coordinate, the distance is simply the vertical difference; if they share a y-coordinate, it is the horizontal difference. The formula extends naturally to three dimensions as √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²) and to any number of dimensions. Note that it measures straight-line distance, not travel distance along a path or road, which is generally longer.

How to use

Example 1 — points (0, 0) and (3, 4). Enter x₁ = 0, y₁ = 0, x₂ = 3, y₂ = 4. Distance = √((3 − 0)² + (4 − 0)²) = √(9 + 16) = √25 = 5. Verify: this is the 3-4-5 right triangle again — the legs are 3 and 4 and the distance (hypotenuse) is 5. Example 2 — points (1, 1) and (4, 5). Enter x₁ = 1, y₁ = 1, x₂ = 4, y₂ = 5. Distance = √((4 − 1)² + (5 − 1)²) = √(9 + 16) = √25 = 5. Verify: the differences are 3 and 4 again, so this segment also has length 5, even though the points are different — the distance depends only on the differences, not the absolute positions.

Frequently asked questions

How is the distance formula related to the Pythagorean theorem?

The distance formula is essentially the Pythagorean theorem applied to coordinates. The horizontal distance between the points, (x₂ − x₁), and the vertical distance, (y₂ − y₁), are the two legs of a right triangle, and the straight-line distance between the points is the hypotenuse. So d² = (x₂ − x₁)² + (y₂ − y₁)² is exactly a² + b² = c², and taking the square root gives the distance. Understanding this connection makes the formula easy to remember and reconstruct. It also explains why the differences are squared — squaring computes the leg lengths' contributions and conveniently removes any negative signs.

Does it matter which point I call point 1?

No. Because each difference is squared, the sign produced by the subtraction order disappears: (x₂ − x₁)² equals (x₁ − x₂)². So you can label the points in either order and get the same distance. This is different from the slope formula, where order consistency matters for the sign. The only rule is to pair each point's x with its own y correctly. As long as you compute the horizontal and vertical differences between the same two points, the result is identical regardless of which you call first.

Can I use this for three-dimensional distances?

Yes, the concept extends naturally. In three dimensions, the distance between (x₁, y₁, z₁) and (x₂, y₂, z₂) is √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²) — you simply add a third squared difference under the root. The same pattern continues into any number of dimensions, which is how 'Euclidean distance' is defined for data points in machine learning. This two-dimensional calculator handles points on a plane, so for 3D you would need to include the z-coordinates. The underlying idea, summing squared differences and taking the root, stays the same.

What is the difference between straight-line distance and travel distance?

This formula gives the straight-line, or 'as the crow flies', distance — the shortest possible path between two points across open space. Travel distance, such as driving along roads or walking around obstacles, is almost always longer because real paths are not straight. For navigation you often need the travel distance, which depends on the route, not just the endpoints. The straight-line distance is still useful as a lower bound and for many geometric and scientific purposes. Just do not mistake it for the actual distance you would travel on a map, which routing tools calculate differently.

When should I NOT use this calculator?

Do not use it when you need travel distance along a route rather than straight-line distance, since real paths are longer and depend on the road network or obstacles. It also assumes a flat coordinate plane, so it is not accurate for large distances on the curved surface of the Earth, where you would use the great-circle (haversine) distance based on latitude and longitude instead. For three-dimensional points you must include the z-coordinate, which this two-dimensional version omits. Make sure your coordinates use the same units and the same coordinate system. And remember the result is the shortest possible distance, not necessarily a meaningful one for a physical journey.

Sources & references