Distance Formula Calculator

Distance

Given two points on graph paper or in 3D space, the straight-line distance between them is the hypotenuse of a right triangle built from their coordinate differences. This calculator handles the 2D formula sqrt((x2-x1)^2 + (y2-y1)^2), the 3D extension with a z-term.

How to compute the distance between two points

  1. 1

    Choose dimensions

    Pick 2D (x, y) or 3D (x, y, z).

  2. 2

    Enter the coordinates

    Fill in both points. Decimals and negatives are fine.

  3. 3

    Read the distance

    See the numeric result for your points.

The formulas

2D distance between (x1, y1) and (x2, y2):

d = sqrt((x2 - x1)^2 + (y2 - y1)^2)

3D distance between (x1, y1, z1) and (x2, y2, z2):

d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)

Both are direct consequences of the Pythagorean theorem: the squared distance equals the sum of squared differences along each axis.

Worked example

From (3, 4) to (7, 1):

  • dx = 7 - 3 = 4
  • dy = 1 - 4 = -3
  • d = sqrt(16 + 9) = sqrt(25) = 5

In 3D from (1, 2, 3) to (4, 6, 3):

  • dx = 3, dy = 4, dz = 0
  • d = sqrt(9 + 16 + 0) = sqrt(25) = 5

When to use which

  • 2D covers screen coordinates, map distances at small scale (where Earth curvature is negligible), and most homework problems.
  • 3D is for simulations, game engines, molecular distances and CAD measurements.
  • Great-circle distance on the surface of Earth requires the haversine formula, not the 3D Pythagorean one, because the path follows a curve. Use a dedicated geographic distance tool.

Common mistakes

  • Forgetting the square root. Squaring once is not enough; you need to take the root at the end.
  • Order of subtraction. (x2 - x1) vs (x1 - x2) does not matter because the result is squared, but keep it consistent with the textbook you are checking against.
  • Mixing units. All coordinates must be in the same unit; mixing feet and meters silently gives a meaningless number.
  • Negative coordinates. Double-negatives become positives inside the square, so watch the signs on points in quadrants II, III or IV.

Frequently Asked Questions

Because the Pythagorean theorem gives the squared hypotenuse, not the length. The square root undoes the squaring so the result is a plain length in the same unit as the coordinates.

Not with this formula. Earth surface distances need the haversine or Vincenty formulas, which account for curvature. The Pythagorean formula assumes a flat Euclidean space and breaks down at planetary scales.

The Manhattan or taxicab distance is |x2 - x1| + |y2 - y1|, the sum of absolute differences. It represents travel along a grid (like city blocks) rather than a diagonal line and is always greater than or equal to the Pythagorean distance.

No. The coordinates are sent to our server so the distance can be computed, and in the step-by-step mode they are carried in the page link. They are not stored.

Related Tools

Tool available in other languages