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}

and 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}

When to use this method

Use the distance 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. 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. 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 is the hypotenuse.

It is worth knowing why it works, because then it is not a separate rule to memorize. If

Δx=x2x1,Δy=y2y1\Delta x = x_2 - x_1, \qquad \Delta y = y_2 - y_1

then the Pythagorean theorem gives 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}. 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, which is the same idea extended into one more dimension.

The procedure, step by step

  1. Write the points. Label the coordinates carefully so each axis matches the correct axis in the other point.
  2. Subtract corresponding coordinates. Find the change in each direction, such as x2x1x_2 - x_1 and y2y1y_2 - y_1.
  3. Square the changes. Square each coordinate difference after subtracting, not before.
  4. Add and square root. Add the squared changes and take the positive square root to get the distance.
  5. Sense-check the result. Compare the answer with the horizontal, vertical, or spatial changes to see if the size is reasonable.

A full example from start to finish

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, and 41\sqrt{41} fits that.

The 3D version follows the same steps with one more term. 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}

You subtract matching coordinates, square the differences, add them, and take the positive square root.

Where students get stuck, and how to check each step

Most errors cluster around a few steps:

  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.

Before you trust the answer, ask two questions: did I subtract first and square second, and is the final distance a reasonable size compared with the coordinate changes? Those two checks catch most errors quickly.

Practice this procedure

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

Frequently Asked Questions

What is the distance formula in 2D?
For points $(x_1, y_1)$ and $(x_2, y_2)$, the 2D distance formula is $d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$.
What changes in 3D?
In 3D, you include the change along the $z$-axis as well, so $d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$.
Why is the answer never negative?
Distance is a length. After squaring the coordinate differences and adding them, you take the positive square root.

Need help with a problem?

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

Open GPAI Solver →