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

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