What is the distance formula?
The distance formula gives the length of the straight line between two points on a graph. It comes directly from the Pythagorean theorem: the horizontal and vertical gaps between the points are the two legs of a right triangle, and the distance is its hypotenuse.
The distance formula
| Case | Formula |
|---|---|
| Distance in 2D | d = √((x₂ − x₁)² + (y₂ − y₁)²) |
| Distance in 3D | d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²) |
How to use the distance formula step by step
- Subtract the x-coordinates to get Δx, and the y-coordinates to get Δy.
- Square each difference. The squares are never negative.
- Add the squares.
- Take the square root of the sum.
- Simplify the radical if you need an exact answer.
Worked examples
A 3-4-5 triangle: (1, 2) and (4, 6)
Δx = 3 and Δy = 4, so d = √(9 + 16) = √25 = 5.
Negative coordinates: (−3, 4) and (5, −2)
Δx = 8 and Δy = −6, so d = √(64 + 36) = √100 = 10. The sign of a difference does not matter, because it is squared.
An exact radical: (0, 0) and (1, 1)
d = √(1 + 1) = √2, about 1.4142. For (0, 0) and (5, 5), d = √50 = 5√2, about 7.0711.
In 3D: (1, 2, 3) and (4, 6, 15)
The differences are 3, 4 and 12, so d = √(9 + 16 + 144) = √169 = 13.
A vertical line: (2, 5) and (2, −1)
The x-values match, so Δx = 0 and d = √(0 + 36) = 6. When points share an x-value or a y-value, the distance is just the difference of the other coordinate.
Exact form and decimal form
Most distances are irrational, so a calculator shows a rounded decimal. In coursework you are often asked for the exact value, written as a simplified radical. Here, √50 simplifies to 5√2, because 50 = 25 × 2 and √25 = 5. The exponent and root calculator simplifies any square root.
Where the distance formula is used
It measures side lengths of shapes defined by coordinates, such as the perimeter of a triangle. It also finds the radius of a circle from its center and a point on it, the distance between two locations on a flat grid, and the distance between objects in games and graphics. For the right-triangle idea behind it, see the Pythagorean theorem calculator, and for the halfway point, the midpoint calculator.
Common distance formula mistakes
The classic mistake is forgetting to square the differences or to take the final square root. Another is squaring only part of an expression: (−3)² is 9, not −9. Adding the differences before squaring, instead of squaring each first, gives the wrong result. Lastly, keep all coordinates in the same units. The slope, distance and midpoint calculator shows all three measures for the same two points.
Frequently asked questions
What is the distance formula?
The distance between (x₁, y₁) and (x₂, y₂) is d = √((x₂ − x₁)² + (y₂ − y₁)²). It finds the length of the straight line joining two points on a coordinate plane, and it is the Pythagorean theorem applied to the horizontal and vertical gaps.
Is the distance formula the same as the Pythagorean theorem?
Yes, it is the same idea. The gaps Δx and Δy are the legs of a right triangle, and the distance is the hypotenuse. That is why you square both gaps, add them and take the square root, exactly as in a² + b² = c².
How do you find the distance between two points in 3D?
Add a third squared difference: d = √(Δx² + Δy² + Δz²). For (1, 2, 3) and (4, 6, 15), the differences are 3, 4 and 12, so d = √169 = 13. Leave the z-boxes empty for a 2D problem.
Can distance be negative?
No. The differences are squared, so every term is zero or positive, and a square root gives a non-negative result. Distance is zero only when the two points are identical. The order you subtract the coordinates in does not change the answer.
How do you leave the answer in exact form?
Keep the square root instead of rounding, and simplify it by pulling out perfect squares. For √50, write 50 = 25 × 2, so √50 = 5√2. The calculator shows this exact form whenever the sum of squares is a whole number.
More Geometry calculators
- Area Calculator
- Volume Calculator
- Circle Calculator
- Pythagorean Theorem Calculator
- Slope, Distance and Midpoint Calculator
- Midpoint Calculator
- Equation of a Line Calculator
Browse every geometry calculator.
Other calculators
- Percentage Calculator
- Quadratic Formula Calculator
- Fraction Calculator
- GCF and LCM Calculator
- Mean, Median, Mode Calculator
- Standard Deviation Calculator
- Linear Equation Calculator
- Exponent and Root Calculator
- System of Equations Calculator
- Order of Operations Calculator
- Scientific Calculator with Steps
- Z-Score Calculator
- Permutation and Combination Calculator
- Percentage Change Calculator
- Percent Error Calculator
- Variance Calculator
Related topics on this page: distance between two points, 3D distance, Pythagorean theorem, coordinate geometry, exact radical form, length of a segment