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).
x1 = 1y1 = 2x2 = 4y2 = 6
- 01Δx = 4 - 1 = 3
- 02Δy = 6 - 2 = 4
- 03d = √(3² + 4²) = √(9 + 16) = √25 = 5
Ready to run the numbers?
Open Distance Calculator