FREE COORDINATE GEOMETRY TOOL

Distance Between Two Points Calculator

Calculate the straight-line distance between two points on a coordinate plane. Enter the x- and y-coordinates to get the distance formula, step-by-step working, midpoint, slope, direction angle, and an interactive coordinate diagram.

Calculate the Distance

Enter the coordinates of Point A and Point B. Negative and decimal coordinates are supported.

Horizontal coordinate of Point A.
Vertical coordinate of Point A.
Horizontal coordinate of Point B.
Vertical coordinate of Point B.
This labels the result; it does not convert coordinates.
Controls the displayed numerical precision.
Straight-line distance AB
5 units
d = √((3 − 0)² + (4 − 0)²) = 5
Horizontal difference |Δx| 3 units
Vertical difference |Δy| 4 units
Midpoint (1.5, 2)
Slope 1.333
Direction angle 53.130°
Squared distance d² 25

Coordinate Plane

The dashed horizontal and vertical legs show the coordinate differences. The direct segment between A and B is the distance being calculated. The graph adjusts to fit the selected coordinates.

Step-by-Step Calculation

  1. Calculate the horizontal difference: Δx = 3 − 0 = 3.
  2. Calculate the vertical difference: Δy = 4 − 0 = 4.
  3. Substitute into the distance formula.
  4. d = √(3² + 4²) = √25 = 5 units.

Distance Formula

d = √((x₂ − x₁)² + (y₂ − y₁)²)

Subtract the coordinates, square both differences, add them, and take the positive square root.

M = ((x₁ + x₂)/2, (y₁ + y₂)/2)

The midpoint is halfway between the two points.

m = (y₂ − y₁)/(x₂ − x₁)

Slope is defined when the two points have different x-coordinates.

The Distance Formula Explained

The distance formula calculates the length of the straight line joining two points in a two-dimensional Cartesian coordinate plane. It follows directly from the Pythagorean theorem.

d = √((x₂ − x₁)² + (y₂ − y₁)²)

Here, (x₁, y₁) represents Point A, (x₂, y₂) represents Point B, and d is the straight-line distance between them.

Why does the formula work?

The horizontal difference between the points is x₂ − x₁, and the vertical difference is y₂ − y₁. These differences form the two perpendicular sides of a right triangle. The line joining the points is its hypotenuse.

a² + b² = c²

Applying the Pythagorean theorem gives d² = (x₂ − x₁)² + (y₂ − y₁)². Taking the positive square root gives the distance formula.

Related coordinate formulas

QuantityFormulaMeaning
Distance d = √(Δx² + Δy²) Length of the segment AB
Horizontal difference Δx = x₂ − x₁ Signed change in x
Vertical difference Δy = y₂ − y₁ Signed change in y
Midpoint M = ((x₁+x₂)/2, (y₁+y₂)/2) Point halfway along AB
Slope m = Δy/Δx Rise divided by run, when Δx ≠ 0
Direction angle θ = atan2(Δy, Δx) Angle of AB from the positive x-axis
Remember: Distance is never negative. The formula squares the coordinate differences, so points with negative coordinates can be used without any special modification. Enter the coordinates with their correct signs.

Worked Examples

Example 1: A 3–4–5 triangle

A = (0, 0)

B = (3, 4)

d = √(3² + 4²)

Distance = 5 units

Example 2: Negative coordinates

A = (−2, 1)

B = (2, −2)

d = √(4² + (−3)²)

Distance = 5 units

Example 3: Horizontal segment

A = (2, 3)

B = (8, 3)

d = √(6² + 0²)

Distance = 6 units

How to Find the Distance Between Two Points

  1. Identify the coordinates. Write the first point as A(x₁, y₁) and the second as B(x₂, y₂).
  2. Find the x-coordinate difference. Subtract x₁ from x₂.
  3. Find the y-coordinate difference. Subtract y₁ from y₂.
  4. Square each difference. Multiply each difference by itself.
  5. Add the squares. This gives the squared distance.
  6. Take the positive square root. The result is the straight-line distance between the points.

Example using the formula

Find the distance between A(1, 2) and B(4, 6).

d = √((4 − 1)² + (6 − 2)²)

d = √(3² + 4²)

d = √(9 + 16)

d = √25 = 5 units

Where Is the Distance Formula Used?

This calculator measures Euclidean distance in a flat two-dimensional coordinate plane. For geographic latitude and longitude on Earth, use a great-circle or geodesic distance calculation instead.

Special Cases

Points on a horizontal line

If y₁ = y₂, the vertical difference is zero. The distance simplifies to d = |x₂ − x₁|.

Points on a vertical line

If x₁ = x₂, the horizontal difference is zero. The distance simplifies to d = |y₂ − y₁|.

Distance from the origin

For a point P(x, y) and the origin O(0, 0), the formula becomes d = √(x² + y²).

Identical points

If both coordinates match, then Δx = 0 and Δy = 0. The distance is exactly zero.

Frequently Asked Questions

1. What is the formula for distance between two points?

The formula is d = √((x₂ − x₁)² + (y₂ − y₁)²). Subtract the corresponding coordinates, square both differences, add the results, and take the positive square root.

2. Why is the distance formula based on the Pythagorean theorem?

The horizontal and vertical differences form perpendicular sides of a right triangle. The distance between the points is its hypotenuse, so the Pythagorean theorem gives the distance formula.

3. Can I use negative coordinates?

Yes. Negative coordinates are valid. Substitute them carefully, keeping parentheses around negative values when evaluating the differences.

4. What if both points have the same x-coordinate?

The segment is vertical, and the distance is the absolute difference between the y-coordinates: d = |y₂ − y₁|.

5. What if both points have the same y-coordinate?

The segment is horizontal, and the distance is the absolute difference between the x-coordinates: d = |x₂ − x₁|.

6. Can the distance between two points be zero?

Yes. The distance is zero if and only if the two points have exactly the same x- and y-coordinates.

7. How do I calculate the midpoint?

Average the x-coordinates and average the y-coordinates: M = ((x₁ + x₂)/2, (y₁ + y₂)/2).

8. What is the difference between distance and displacement?

Distance is the nonnegative length of the segment between two points. Displacement describes the change in position and includes direction. The coordinate differences Δx and Δy describe the components of that displacement.

9. Is the distance formula suitable for latitude and longitude?

Not directly for accurate real-world distances over Earth's surface. Latitude and longitude are spherical geographic coordinates; use a geodesic or great-circle distance formula for those calculations.

Further Reading

Learn more about coordinate distance and its geometric derivation: