Article

Distance Between Two Points: Distance Formula and Worked Examples

The distance between the points A = (x₁, y₁) and B = (x₂, y₂) in the plane is d = √((x₂ − x₁)² + (y₂ − y₁)²). The formula follows from the Pythagorean theorem for a right triangle whose legs are the differences of the coordinates. This article gives the formula, how it is derived, the distance in space, the midpoint of a segment and four worked examples. You can check your own points in the distance between two points calculator. For A = (-2, 3) and B = (4, -1) the distance is 7.211103.

Last updated:

Find the distance between two points in the distance between two points calculator. Find the third side of a right triangle in the Pythagorean theorem calculator.

The distance formula for two points

The distance between two points in the plane is the length of the segment that joins them. You find it in three steps.

1. Find the differences: Δx = x₂ − x₁ and Δy = y₂ − y₁.
2. Square them and add: Δx² + Δy².
3. Take the square root: d = √(Δx² + Δy²).
example: Δx = 6, Δy = −4, d = √(36 + 16) = √52 ≈ 7.2111

Point APoint BΔx, ΔySum of squaresDistance d
(0, 0)(3, 4)3, 4255
(0, 0)(6, 8)6, 810010
(0, 0)(1, 1)1, 121.4142
(2, 1)(5, 5)3, 4255
(-2, 3)(4, -1)6, −4527.2111

The order of the points does not matter, because the differences are squared. The distance from A to B is the same as from B to A.

The segment AB on a coordinate plane with a right triangleA coordinate plane with the points A = (-2, 3) and B = (4, -1). The legs of the right triangle have lengths 6 and 4, and the hypotenuse AB has a length of about 7.21.xyA (-2, 3)B (4, -1)Δx = 6Δy = −4d = √(Δx² + Δy²)= √52 ≈ 7.21
The distance AB is the hypotenuse of a triangle with legs 6 and 4. By the Pythagorean theorem 36 + 16 = 52, so d ≈ 7.2111.

Try it with an example

Example: A = (-2, 3) and B = (4, -1). All four coordinates are already stored in the link to the calculator.

x₁
-2
y₁
3
x₂
4
y₂
-1
Result
Δx = 6, Δy = −4, d = 7.211103

Open the calculator with these numbers

The calculator reads the values from the page address and shows the result right away. You can change them freely.

How the calculator works

The calculator finds the differences of the coordinates, their squares, the sum of squares and the Euclidean distance in the plane. It rounds the result to six decimal places and also shows the result of a second method of finding the length as a check. An empty coordinate field counts as zero, so it is worth checking that all four fields are filled in before you calculate. The drawing shows both points and the segment. The calculator finds the distance in a Cartesian plane and does not handle three-dimensional space or geographic coordinates.

How the distance formula is derived

Draw a horizontal segment from point A and a vertical segment from point B. They meet at the point with coordinates (x₂, y₁) and form a right triangle whose legs have the lengths |Δx| and |Δy|. The segment AB is its hypotenuse, so by the Pythagorean theorem d² = Δx² + Δy².

For A = (-2, 3) and B = (4, -1) the legs have lengths 6 and 4, so d² = 36 + 16 = 52. The third side of a right triangle can be checked in the Pythagorean theorem calculator, and a square root in the square root calculator. The formula is described in The Pythagorean Theorem.

Distance in space and the midpoint

In three-dimensional space there is a third coordinate, and the formula becomes d = √(Δx² + Δy² + Δz²). For the points (1, 2, 3) and (4, 6, 15) the differences are 3, 4 and 12, and the distance is √(9 + 16 + 144) = √169 = 13. The calculator on the page handles only the plane, so this formula has to be worked out by hand.

The midpoint of the segment AB has the coordinates ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). For A = (-2, 3) and B = (4, -1) it is (1, 1). The distance from the midpoint to each end is half the length of the segment, which is 3.6056.

Special cases and uses

When the points have the same y-coordinate, the segment is horizontal and the distance is |x₂ − x₁|. For (−2, 8) and (7, 8) it is 9. When they have the same x-coordinate, the segment is vertical. The distance from the point (x, y) to the origin is √(x² + y²), so for (3, 4) it is 5.

The formula is used to find the side lengths of shapes given by coordinates. A triangle with the vertices (0, 0), (6, 0) and (3, 4) has sides 6, 5, 5, so its perimeter is 16. The area of this triangle is 12, which the Heron's formula calculator confirms, and the method is described in Heron's Formula. A rectangle with sides equal to these distances is in the rectangle area calculator. The formula does not suit geographic coordinates, because the Earth is a sphere.

Four worked examples

You can repeat the first three examples in the distance between two points calculator.

1. The distance between A = (-2, 3) and B = (4, -1)

Negative coordinates.

  1. Find the differences: 4 − (-2) = 6 and -1 − 3 = −4.
  2. Square them: 36 and 16.
  3. Add them: 52.
  4. The distance is 7.211103.

2. The distance between (0, 0) and (3, 4)

A Pythagorean triple.

  1. Find the differences: 3 and 4.
  2. Square them: 9 and 16.
  3. Add them: 25.
  4. The distance is 5.

3. The distance between (−2, 8) and (7, 8)

The same y-coordinate.

  1. Find the differences: 7 − (−2) = 9 and 8 − 8 = 0.
  2. Square them: 81 and 0.
  3. Add them: 81.
  4. The distance is 9.

4. The distance between (1, 2, 3) and (4, 6, 15) in space

Three coordinates.

  1. Find the differences: 3, 4 and 12.
  2. Square them: 9, 16 and 144.
  3. Add them: 169.
  4. The distance is 13.

Common mistakes when finding the distance between points

  • Forgetting the square root — the sum of the squared differences is d², and the distance is its square root.
  • Subtracting coordinates from different axes — subtract x from x and y from y.
  • Squaring the sum instead of summing the squares — the formula needs (x₂ − x₁)² + (y₂ − y₁)², not (Δx + Δy)².
  • Getting a sign wrong with negative coordinates — subtracting a negative number means adding, for example 4 − (−2) = 6.
  • Leaving a field empty in the calculator — the calculator counts an empty coordinate field as zero.
  • Using the plane formula for points in space — in space you have to add the squared difference of z.
  • Using the formula for geographic coordinates — latitude and longitude need a formula for distance on a sphere.

Frequently asked questions

How do you find the distance between two points?

Find the differences of the coordinates, square them, add them and take the square root. For (-2, 3) and (4, -1) the result is 7.2111.

What is the distance formula?

For the points (x₁, y₁) and (x₂, y₂) in the plane the formula is d = √((x₂ − x₁)² + (y₂ − y₁)²).

Why does the distance formula work?

It follows from the Pythagorean theorem. The differences of the coordinates are the legs of a right triangle, and the segment between the points is its hypotenuse.

What is the distance between the points (−2, 8) and (7, 8)?

The points have the same y-coordinate, so the distance is |7 − (−2)| = 9.

How do you find the distance between two points in 3D?

Add the squared difference of the third coordinate: d = √(Δx² + Δy² + Δz²). For (1, 2, 3) and (4, 6, 15) the result is 13.

How do you find the midpoint of a segment?

Use the mean coordinates: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). For (-2, 3) and (4, -1) the midpoint is (1, 1).

Does the order of the points matter?

No. The differences are squared, so the distance from A to B is the same as from B to A.

Does the distance between two points calculator work in 3D?

No. The calculator handles points in the plane, which means four coordinates x₁, y₁, x₂ and y₂. It counts an empty field as zero.

Find the distance between your own points

Enter the four coordinates in the distance between two points calculator and read the differences, the sum of squares and the distance.

Find the third side of a right triangle in the Pythagorean theorem calculator, and the area of a triangle from three sides in the Heron's formula calculator.