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

VariableDescriptionDefault
x1x₁1
y1y₁2
x2x₂4
y2y₂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
  1. 01Δx = 4 - 1 = 3
  2. 02Δy = 6 - 2 = 4
  3. 03d = √(3² + 4²) = √(9 + 16) = √25 = 5

Ready to run the numbers?

Open Distance Calculator