Skip to content

Distance Between Two Points Calculator (2D and 3D)

Distance between two points in 2D or 3D, exact radical form, Manhattan distance and midpoint.

Your details

Space

Results update as you type

Distance d

5

Distance squared d²
25
Manhattan (taxicab) distance
7
Midpoint
(2.5, 4)

Step-by-step solution
  1. Δx = x₂ − x₁ = 4 − 1 = 3
  2. Δy = y₂ − y₁ = 6 − 2 = 4
  3. Sum of the squares: d² = 3² + 4² = 25
  4. Straight-line (Euclidean) distance: d = √25 = 5
  5. Manhattan (taxicab) distance: |3| + |4| = 7
  6. Midpoint: ((1 + 4) / 2, (2 + 6) / 2) = (2.5, 4)

How far apart are two points? On a graph, a map grid or a 3D model, the answer is given by the distance formula, which is nothing more than the Pythagorean theorem applied to coordinates. Enter two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) — or (x1,y1,z1)(x_1, y_1, z_1) and (x2,y2,z2)(x_2, y_2, z_2) in space — and this calculator returns the straight-line Euclidean distance, both as a decimal and, when the coordinates are whole numbers, in exact simplified radical form such as 626\sqrt{2}.

It also gives the squared distance, the Manhattan (taxicab) distance used for grid movement, and the midpoint of the segment, with every subtraction, square and simplification written out in the steps. That makes it handy for checking homework, writing an answer key, or verifying coordinates in a design or game.

The coordinates can be any unit — centimetres, metres, kilometres on a map grid, pixels — as long as both points use the same one. The distance comes out in that unit.

How to use this calculator

  1. Choose 2D for points in a plane or 3D for points in space.
  2. Enter the coordinates of the first point, then those of the second. Negative values and decimals are fine, and the order of the two points does not change the result.
  3. Read the distance. If all coordinates are integers and the distance is not a whole number, the exact value appears as kmk\sqrt{m}.
  4. Use the Manhattan distance when movement is restricted to horizontal and vertical steps, and the midpoint when you need the centre of the segment.
  5. Open the steps to see the working in the order a teacher expects it.

The formula

In the plane, the horizontal and vertical differences Δx=x2−x1\Delta x = x_2 - x_1 and Δy=y2−y1\Delta y = y_2 - y_1 are the legs of a right triangle whose hypotenuse is the segment. By Pythagoras:

d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

In space, the same reasoning is applied twice and a third term appears:

d=(x2−x1)2+(y2−y1)2+(z2−z1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}

The Manhattan distance adds the absolute differences instead: d1=∣Δx∣+∣Δy∣ (+ ∣Δz∣)d_1 = |\Delta x| + |\Delta y|\,(+\,|\Delta z|). The midpoint averages each coordinate: M=(x1+x22,y1+y22)M = \left(\frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2}\right).

To simplify the radical, write d2d^2 as k2×mk^2 \times m with mm free of square factors; then d2=km\sqrt{d^2} = k\sqrt{m}.

Worked example

Find the distance between A(−1,2)A(-1, 2) and B(5,−4)B(5, -4).

  • Differences: Δx=5−(−1)=6\Delta x = 5 - (-1) = 6 and Δy=−4−2=−6\Delta y = -4 - 2 = -6.
  • Sum of squares: 62+(−6)2=36+36=726^2 + (-6)^2 = 36 + 36 = 72.
  • Simplify: 72=36×2=62\sqrt{72} = \sqrt{36 \times 2} = 6\sqrt{2}, so d=62≈8.485d = 6\sqrt{2} \approx 8.485.
  • Manhattan distance: 6+6=126 + 6 = 12; midpoint: (2, −1).

In space, the points (3,−1,5)(3, -1, 5) and (2,1,−1)(2, 1, -1) give 1+4+36=411 + 4 + 36 = 41, so d=41≈6.403d = \sqrt{41} \approx 6.403 and a Manhattan distance of 9.

Distance: which one do you need?

The word distance covers several measurements, and choosing the right one matters:

Situation Distance to use
Straight line on a graph, plan or 3D model Euclidean (this formula)
Moving along a street grid or a chessboard rook Manhattan, ∣Δx∣+∣Δy∣|\Delta x| + |\Delta y|
Two places given by latitude and longitude Great-circle (haversine), not this formula
A trip at a known speed Distance = speed × time, see the pace calculator

For GPS coordinates, the Earth's curvature and the fact that a degree of longitude shrinks towards the poles make the flat distance formula wrong over long distances. On a small local grid in metres (a site plan, a game map), it works perfectly.

Distance, slope and midpoint together

The distance formula is one of three tools that work on the same pair of points. The midpoint gives the centre of the segment, and the slope ΔyΔx\frac{\Delta y}{\Delta x} gives its direction — the slope calculator finds it along with the equation of the line. Together they let you prove that a quadrilateral is a parallelogram, find the centre and radius of a circle from a diameter, or check whether a triangle is isosceles or right-angled.

Frequently asked questions

What is the formula for the distance between two points?

d = √((x₂ − x₁)² + (y₂ − y₁)²). Subtract the coordinates, square each difference, add them and take the square root. For (−3, −1) and (2, 3): 5² + 4² = 41, so d = √41 ≈ 6.403.

Does the order of the points matter?

No. Swapping the points changes the sign of each difference, but squaring removes the sign, so the distance is the same either way.

How do I give the answer in simplest radical form?

Factor the largest perfect square out of d². For d² = 72 = 36 × 2, √72 = 6√2. The calculator does this automatically whenever every coordinate is a whole number.

What is the Manhattan distance?

It is the length of a path that only moves parallel to the axes, like a taxi driving on a grid of streets: |Δx| + |Δy|. It is always at least as large as the straight-line distance, and equal to it only when the two points differ along a single axis.

Can I use this for latitude and longitude?

Only for very short distances after converting degrees to metres. For real geographic distances, use a great-circle (haversine) formula, which accounts for the curvature of the Earth.

Sources

Last updated:

More Math calculators

People also use