Coordinate geometry tool
Distance Formula Calculator
Find the exact distance between any two points on a coordinate plane, with step-by-step working, a live visual plot, and support for 3D coordinates.
- 2D and 3D
- Visual coordinate plot
- Step-by-step working
- 100% free
Core calculator
Distance Between Two Points Calculator
Formula
The Distance Formula
d = √((x₂ − x₁)² + (y₂ − y₁)²)
The distance formula gives the straight-line distance between two points on a coordinate plane.
Given Point 1 at (x₁, y₁) and Point 2 at (x₂, y₂), the formula computes
the length of the direct path between them, the hypotenuse of the right triangle formed by the
horizontal and vertical differences.
The formula works for any two points, including those with negative coordinates, decimal coordinates, or coordinates in different quadrants. The squaring step ensures that negative differences become positive before they are added.
3D Distance Formula
d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
The 3D version adds a third term for the z-axis difference. It applies the Pythagorean theorem twice: first to find the diagonal of the base plane, then again to include the vertical component.
Why it works
Why the Distance Formula Is the Pythagorean Theorem
The distance formula is not a separate rule. It is the Pythagorean theorem applied to a
coordinate grid. When you draw a horizontal line from P1 to the x-coordinate of P2, and a
vertical line from P2 down to meet it, you form a right triangle. The horizontal leg has
length |x₂ − x₁|, the vertical leg has length |y₂ − y₁|, and the
hypotenuse is the direct distance d.
(x₂ − x₁)² + (y₂ − y₁)² = d²
Taking the square root of both sides gives the distance formula directly. The two formulas are mathematically identical, the distance formula is just the Pythagorean theorem written in coordinate notation.
This connection means that any problem involving the distance formula can also be solved by
identifying the right triangle, labeling its legs as Δx and Δy, and
applying c = √(a² + b²). The calculator above draws this triangle in the
coordinate plot so you can see the relationship visually.
To learn more about the Pythagorean theorem itself, see The Pythagorean Theorem.
How to use it
How to Use the Distance Formula
-
Step 1 — Identify the two points
Write down the coordinates of both points:
(x₁, y₁)and(x₂, y₂). Whichever point you call P1, keep its x and y values paired together throughout. -
Step 2 — Find the differences
Subtract the x-coordinates to get
Δx = x₂ − x₁. Subtract the y-coordinates to getΔy = y₂ − y₁. These are the horizontal and vertical legs of the right triangle. -
Step 3 — Square, add, and take the square root
Calculate
Δx², calculateΔy², add them together, then take the square root:d = √(Δx² + Δy²). -
Step 4 — Check your answer
The distance must be positive and must be greater than or equal to either
|Δx|or|Δy|alone. If your result is smaller than one of the differences, recheck the arithmetic.
Examples
Worked Examples
Example 1: Distance between (0, 0) and (3, 4)
| Δx | 3 − 0 = 3 |
|---|---|
| Δy | 4 − 0 = 4 |
| Square and add | 3² + 4² = 9 + 16 = 25 |
| Square root | d = √25 = 5 |
The legs 3 and 4 form a 3-4-5 Pythagorean triple.
Example 2: Distance between (−2, 3) and (4, −1)
| Δx | 4 − (−2) = 6 |
|---|---|
| Δy | −1 − 3 = −4 |
| Square and add | 6² + (−4)² = 36 + 16 = 52 |
| Square root | d = √52 = 2√13 ≈ 7.211 |
Negative differences are fine, squaring makes them positive.
Example 3: Distance between (1, 2, 3) and (4, 6, 3)
| Δx | 4 − 1 = 3 |
|---|---|
| Δy | 6 − 2 = 4 |
| Δz | 3 − 3 = 0 |
| Square and add | 3² + 4² + 0² = 9 + 16 + 0 = 25 |
| Square root | d = √25 = 5 |
When Δz = 0, the 3D formula reduces to the 2D formula because the points lie in the
same plane.
FAQ
Frequently Asked Questions
The distance formula is d = √((x₂−x₁)² + (y₂−y₁)²). It calculates the
straight-line distance between two points on a coordinate plane and comes directly from the
Pythagorean theorem.
No. Because both differences are squared, swapping P1 and P2 gives the same result. The order of subtraction changes the sign, but not the final distance.
Yes. Negative coordinates work the same way as positive ones. A difference may be negative, but squaring it makes the contribution positive before the terms are added.
The 3D version is d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). It extends the same
square-sum idea by adding a third squared difference for the z-axis.
The distance formula finds how far apart two points are. The midpoint formula finds the point
halfway between them: ((x₁+x₂)/2, (y₁+y₂)/2). Distance gives length, midpoint
gives location.
Any time your points are defined by coordinates rather than physical measurements. Geometry problems, maps, games, and data visualizations all use coordinate positions where the exact straight-line distance must be computed mathematically.
Related