Distance Calculator Formula
Understand the math behind the distance calculator. Each variable explained with a worked example.
Formulas Used
Distance
distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)Horizontal Dist
horizontal_dist = abs(x2 - x1)Vertical Dist
vertical_dist = abs(y2 - y1)Variables
| Variable | Description | Default |
|---|---|---|
x1 | x₁ | 1 |
y1 | y₁ | 2 |
x2 | x₂ | 4 |
y2 | y₂ | 6 |
How It Works
How to Calculate Distance Between Two Points
Formula
d = √((x₂ - x₁)² + (y₂ - y₁)²)
This is derived from the Pythagorean theorem. The horizontal and vertical distances form the legs of a right triangle, and the distance between the points is the hypotenuse.
Worked Example
Find the distance between points (1, 2) and (4, 6).
- 01Δx = 4 - 1 = 3
- 02Δy = 6 - 2 = 4
- 03d = √(3² + 4²) = √(9 + 16) = √25 = 5
Frequently Asked Questions
What is the distance formula?
The distance formula d = √((x₂-x₁)² + (y₂-y₁)²) calculates the straight-line distance between two points on a coordinate plane. It is based on the Pythagorean theorem.
Can this formula work in 3D?
For 3D, add a z component: d = √((x₂-x₁)² + (y₂-y₁)² + (z₂-z₁)²). This calculator handles 2D distances.
Learn More
Guide
Pythagorean Theorem - Complete Guide
Master the Pythagorean theorem with this comprehensive guide. Learn the formula a² + b² = c², proofs, Pythagorean triples, and real-world applications.
Ready to run the numbers?
Open Distance Calculator