Distance Formula Calculator

Find the distance between two points in 2D or 3D with the distance formula, showing Δx, Δy, Δz, every substitution step, the exact answer and a graph.

Point A

A = (3, 4)

Point B

B = (6, 8)

e.g. m, km, ft. Used only as a label; no conversion.

Try an example

Distance from A to B (2D)

d = 5 units
Δx = 3Δy = 4

Step-by-Step Calculation

  1. Step 1 — Find the coordinate differences

    Subtract the coordinates of Point A from those of Point B.

    Δx = x₂ − x₁ = 6 − 3 = 3

    Δy = y₂ − y₁ = 8 − 4 = 4

  2. Step 2 — Substitute into the distance formula

    Δx and Δy are the legs of a right triangle, and d is its hypotenuse (Pythagorean theorem).

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

    = √[(6 − 3)² + (8 − 4)²]

    = √[3² + 4²]

    = √[9 + 16]

    = √25

    = 5

Coordinate plane

Points A and B and the distance between themPoint A (3, 4) and point B (6, 8) joined by a straight segment of length 5 units. The dashed legs show Δx = 3 and Δy = 4, forming a right triangle with the segment as hypotenuse.−224682468xyΔx = 3Δy = 4d = 5A (3, 4)B (6, 8)
d = 5 unitsA = (3, 4)B = (6, 8)The green segment is the straight-line distance d. The dashed purple legs Δx and Δy form a right triangle with it, so d² = Δx² + Δy².
Midpoint M
((3 + 6)/2, (4 + 8)/2) = (4.5, 6)
Slope of AB
4/3 ≈ 1.333333m = Δy / Δx = 4 / 3
Order of points
d(A, B) = d(B, A) = 5 units. Distance is never negative.

For more on these, use the Midpoint Calculator and the Slope Calculator.

Distance formula

2D distance

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

A = (x₁, y₁), B = (x₂, y₂)

3D distance

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

z₁ and z₂ are the third coordinates

x₁, y₁ (and z₁) are the coordinates of Point A; x₂, y₂ (and z₂) those of Point B. Squaring each difference makes it non-negative, so d ≥ 0, and swapping A and B gives the same distance.

The distance between two points is the length of the vector from A to B, which the Vector Calculator finds as a magnitude. For side lengths, angles and area once you know three points, use the Triangle Calculator; for square roots and powers, the Scientific Calculator.

This distance formula calculator finds the straight-line distance between two points. Choose 2D for points (x, y) or 3D for points (x, y, z), enter the coordinates of Point A and Point B, and the calculator shows the distance with the coordinate differences Δx, Δy (and Δz) and every step of the substitution: for A = (3, 4) and B = (6, 8), d = √[(6 − 3)² + (8 − 4)²] = √[3² + 4²] = √25 = 5.

When the distance is irrational, you get both the simplified exact form and a decimal, such as √50 = 5√2 ≈ 7.0711. A graph shows the two points, the segment between them and the right triangle behind the formula, and the midpoint and slope of the segment are shown as related information.

Worked Calculation Examples

ScenarioResultCalculation Step
2D: A = (2, 3), B = (6, 6)d = 5Step 1: Δx = 6 − 2 = 4, Δy = 6 − 3 = 3. Step 2: d = √(4² + 3²). Step 3: d = √(16 + 9). Step 4: d = √25. Step 5: d = 5.
3D: A = (1, 2, 3), B = (4, 6, 8)d = 5√2 ≈ 7.0711Step 1: Δx = 3, Δy = 4, Δz = 5. Step 2: d = √(3² + 4² + 5²). Step 3: d = √50. Step 4: d = 5√2. Step 5: d ≈ 7.0711.
Negative coordinates: A = (−3, −4), B = (2, 1)d = 5√2 ≈ 7.0711Δx = 2 − (−3) = 5, Δy = 1 − (−4) = 5. d = √(25 + 25) = √50 = 5√2 ≈ 7.0711.
Same point: A = (3, 4), B = (3, 4)d = 0Δx = 0 and Δy = 0, so d = √0 = 0.

Why the Distance Formula Works

Plot A = (x₁, y₁) and B = (x₂, y₂) and draw a horizontal line from A and a vertical line from B. They meet at the corner (x₂, y₁) of a right triangle. The horizontal leg has length |Δx| = |x₂ − x₁|, the vertical leg has length |Δy| = |y₂ − y₁|, and the segment AB is the hypotenuse.

By the Pythagorean theorem, d² = (Δx)² + (Δy)², so d = √[(Δx)² + (Δy)²]. Squaring removes any minus signs, which is why it does not matter which point you call A: the distance from A to B equals the distance from B to A, and it is never negative.

The Distance Formula in 3D

For points in space, A = (x₁, y₁, z₁) and B = (x₂, y₂, z₂), add a third squared difference: d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. It comes from using the Pythagorean theorem twice: first across the floor (Δx and Δy), then up the height (Δz).

For A = (1, 2, 3) and B = (4, 6, 8), the differences are 3, 4 and 5, so d = √(9 + 16 + 25) = √50 = 5√2 ≈ 7.0711.

Distance vs Displacement

Distance is the non-negative length between two points: a single number, the same whichever point you start from. Displacement is the directed change in position from A to B, written as a vector (Δx, Δy) or (Δx, Δy, Δz). The distance formula gives the length (magnitude) of that displacement vector.

Where the Distance Formula Is Used

In coordinate geometry and maths homework, it finds side lengths of shapes, checks whether a triangle is isosceles or right-angled, and gives the radius of a circle from its centre and a point on it. Physics uses it for the straight-line separation of two positions.

Computer graphics, game development and robotics use it constantly, for collision checks, finding the nearest object and path planning. In GIS and mapping it applies to projected (flat) coordinates over short distances; navigation over long distances on the Earth uses great-circle formulas instead. Engineering drawings and CAD use it to measure between points in 2D and 3D.

How to Use the Distance Formula Calculator

  1. Choose 2D distance for points (x, y) or 3D distance for points (x, y, z).
  2. Enter the coordinates of Point A: x₁, y₁ and, for 3D, z₁. Negative and decimal coordinates are fine.
  3. Enter the coordinates of Point B: x₂, y₂ and, for 3D, z₂. The distance updates as you type. Optionally type a unit such as m or km; otherwise the answer is given in units.
  4. Read the distance d, shown exactly (such as 5 or 5√2) with a decimal approximation when it is irrational.
  5. Check the coordinate differences Δx, Δy (and Δz), then follow the step-by-step substitution into the distance formula.
  6. Use the diagram to see the segment from A to B as the hypotenuse of a right triangle with legs Δx and Δy, and see the midpoint and slope under Related coordinate geometry.

Frequently Asked Questions

What is the distance formula?

d = √[(x₂ − x₁)² + (y₂ − y₁)²]. It gives the straight-line distance between points (x₁, y₁) and (x₂, y₂) on a coordinate plane.

How do you find the distance between two points?

Subtract the coordinates to get Δx and Δy, square each, add them and take the square root. For (2, 3) and (6, 6): Δx = 4, Δy = 3, d = √(16 + 9) = √25 = 5.

What is the distance formula in 2D?

d = √[(x₂ − x₁)² + (y₂ − y₁)²], using the x- and y-coordinates of the two points.

What is the distance formula in 3D?

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. The extra term accounts for the difference in height. For (1, 2, 3) and (4, 6, 8), d = √50 ≈ 7.0711.

Can the distance between two points be negative?

No. The differences are squared before they are added, and the square root of a non-negative number is non-negative. The smallest possible distance is 0, when the two points are the same.

How does the distance formula relate to the Pythagorean theorem?

Δx and Δy are the legs of a right triangle whose hypotenuse joins the two points, so a² + b² = c² becomes Δx² + Δy² = d². The distance formula is that equation solved for d.

How do you find the distance between points with negative coordinates?

Use the same formula and keep the signs when subtracting. For (−3, −4) and (0, 0): Δx = 0 − (−3) = 3 and Δy = 0 − (−4) = 4, so d = √(9 + 16) = 5.

What happens when two points are the same?

Every coordinate difference is 0, so d = √0 = 0. The points coincide, and they do not define a line or a slope.

What is the difference between distance and displacement?

Distance is a non-negative number, the length between two points. Displacement is a directed change in position, a vector such as (3, 4) from A to B. The distance is the length of the displacement.

Can the distance formula be used in 3D?

Yes. Add the squared difference of the z-coordinates under the square root. The same pattern extends to any number of dimensions.

How do you find the midpoint between two points?

Average the coordinates: M = ((x₁ + x₂)/2, (y₁ + y₂)/2), and in 3D also (z₁ + z₂)/2. The midpoint of (3, 4) and (6, 8) is (4.5, 6), and it lies half the distance from each point.

Last updated: September 27, 2026.