The distance formula gives the straight-line distance between two points on a coordinate plane or in 3D space. For points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) in 2D,

d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

For points (x1,y1,z1)(x_1, y_1, z_1) and (x2,y2,z2)(x_2, y_2, z_2) in 3D,

d=(x2x1)2+(y2y1)2+(z2z1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}

Use this formula when you want the actual length between two points, not just the horizontal or vertical change. It applies in standard Cartesian coordinates when each axis uses the same unit scale.

Distance Formula in 2D: What It Measures

The formula combines two perpendicular changes: how far you move in xx and how far you move in yy. Those changes form the legs of a right triangle, and the distance between the points is the hypotenuse.

Why the Distance Formula Works

In the plane, the distance formula comes straight from the Pythagorean theorem. If

Δx=x2x1\Delta x = x_2 - x_1

and

Δy=y2y1\Delta y = y_2 - y_1

then

d2=(Δx)2+(Δy)2d^2 = (\Delta x)^2 + (\Delta y)^2

so

d=(Δx)2+(Δy)2d = \sqrt{(\Delta x)^2 + (\Delta y)^2}

So the formula is not a separate rule to memorize. It is the Pythagorean theorem written in coordinate form.

In 3D, you add one more perpendicular change:

d2=(Δx)2+(Δy)2+(Δz)2d^2 = (\Delta x)^2 + (\Delta y)^2 + (\Delta z)^2

That is the same idea extended into one more dimension.

Worked Example: Distance Between Two Points

Find the distance between (1,2)(1, 2) and (5,7)(5, 7).

Start with the 2D distance formula:

d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

Substitute the coordinates:

d=(51)2+(72)2d = \sqrt{(5 - 1)^2 + (7 - 2)^2}

Simplify the differences:

d=42+52d = \sqrt{4^2 + 5^2}

Square and add:

d=16+25=41d = \sqrt{16 + 25} = \sqrt{41}

So the exact distance is 41\sqrt{41}. As a decimal, d6.4d \approx 6.4.

A quick check helps. The points are 44 units apart horizontally and 55 units apart vertically, so the straight-line distance should be more than 55 but less than 99. 41\sqrt{41} fits that.

Distance Formula in 3D

The setup is the same, but now you include the change in zz.

For example, between (1,2,3)(1, 2, 3) and (5,7,6)(5, 7, 6), the coordinate changes are 44, 55, and 33, so

d=42+52+32=16+25+9=50d = \sqrt{4^2 + 5^2 + 3^2} = \sqrt{16 + 25 + 9} = \sqrt{50}

The method does not change. You subtract matching coordinates, square the differences, add them, and take the positive square root.

Common Mistakes with the Distance Formula

  1. Squaring before subtracting. The formula uses (x2x1)2(x_2 - x_1)^2, not x22x12x_2^2 - x_1^2.
  2. Forgetting the square root. If you stop after adding the squares, you found d2d^2, not dd.
  3. Mixing axes. An xx-coordinate must be matched with the other xx-coordinate, and the same goes for yy and zz.
  4. Losing a negative sign when substituting. For example, 13=4-1 - 3 = -4, not 44.
  5. Using the formula when the graph is not using standard Cartesian distance. If the axes use different scales, the geometric distance changes.

When You Use the Distance Formula

You use the distance formula in coordinate geometry whenever two points are given and the problem asks for the length of the segment between them.

Common cases include finding side lengths on a graph, checking whether a point lies on a circle, comparing distances from a center, and measuring straight-line separation in 3D geometry.

Quick Check Before You Trust the Answer

Ask two questions:

  1. Did I subtract first and square second?
  2. Is the final distance a reasonable size compared with the coordinate changes?

Those two checks catch most errors quickly.

Try a Similar Problem

Find the distance between (2,3)(-2, 3) and (4,1)(4, -1) in 2D. Then compare your setup with the Midpoint Formula to see the difference between finding a length and finding a point halfway along the segment.

Need help with a problem?

Upload your question and get a verified, step-by-step solution in seconds.

Open GPAI Solver →