BedrockCalculator
Figures cited to primary sourcesWritten by Aapt Dubey, MBA (Marketing & Banking), ISB 2 primary sourcesLast updated

Distance Formula Calculator with Midpoint (2D and 3D)

The Distance Formula Calculator with Midpoint finds the distance between two points in 2D or 3D with the distance formula, in exact radical form when it applies, plus the midpoint and Manhattan distance.

Quick Answer: The distance between (1, 2) and (4, 6) is 5: the differences are 3 and 4, and √(3² + 4²) = √25 = 5. The midpoint is (2.5, 4).

Assumptions

Computed

Preset scenarios

Distance
5
Exact form
5 (exact)
Midpoint
(2.5, 4)
Distance squared
25
Differences
Δx = 3, Δy = 4
Manhattan (taxicab) distance
7

Distance from the origin to common points

Download CSV
Each row is this calculator run from (0, 0) to the point (x, y) shown. Distances are shown to 15 significant figures with the exact form beside them.
xyDistanceExact
111.4142135623731√2
122.23606797749979√5
222.828427124746192√2
3455 (exact)
5121313 (exact)
8151717 (exact)
133.16227766016838√10
233.60555127546399√13
334.242640687119293√2
681010 (exact)
7242525 (exact)
101014.14213562373110√2

This table and its CSV are free to reuse with a link to this page, CC BY 4.0.

Distance Formula Calculator with Midpoint (2D and 3D): Distance 5 (Dimensions: Two (x, y); x₁: 1; y₁: 2; x₂: 4; y₂: 6).

Save or share this result

A one-page summary of this calculator's default example, drawn from the same calculation as the result above.

The infographic is free to reuse with a link to this page, CC BY 4.0.

Illustration of a park seen from above, a straight path dividing the lawn and walkways curving around it
Quick Answer: The distance between (1, 2) and (4, 6) is 5: the differences are 3 and 4, and √(3² + 4²) = √25 = 5. The midpoint is (2.5, 4).

What does this calculator do?

This distance formula calculator finds the straight-line distance between two points in a plane or in space, gives it in exact radical form when it is not a whole number, and also returns the midpoint of the segment and the Manhattan (taxicab) distance.

The distance formula is the Pythagorean theorem in coordinates. The horizontal and vertical differences between two points are the two legs of a right triangle, and the straight line between the points is its hypotenuse. In three dimensions a third squared difference is added under the root. The midpoint is simply the average of the two points, coordinate by coordinate.

The squared distance is computed as an exact fraction before the square root is taken, so a distance like √72 can be reported exactly as 6√2 as well as in decimal form.

Using the Distance Formula Calculator

  1. Choose two or three dimensions.
  2. Enter the coordinates of both points. The z boxes only appear in three dimensions.
  3. Read the distance at the top. The cards give the exact form, the midpoint, the distance squared, the coordinate differences and the Manhattan distance.

How is this calculated?

  1. Differences. Each coordinate of the first point is subtracted from the matching coordinate of the second, exactly.
  1. Distance squared. The differences are squared and added. This is the number under the square root.
  1. Distance. The square root of that sum, to 34 significant digits, shown to 15.

d = √((x₂ − x₁)² + (y₂ − y₁)²); d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

  1. Exact form. When the distance squared is a whole number up to 10¹², it is factored into primes, and each pair of a prime comes out of the square root. √72 = √(36 × 2) = 6√2. A perfect square gives a whole number, marked exact.
  1. Midpoint. The average of each coordinate.

M = ((x₁ + x₂)/2, (y₁ + y₂)/2)

  1. Manhattan distance. The sum of the absolute differences, |x₂ - x₁| + |y₂ - y₁| (plus |z₂ - z₁| in 3D), which is the distance travelled along a grid of streets instead of in a straight line.

Worked Example

Using the defaults, (1, 2) and (4, 6):

  1. Differences: Δx = 3, Δy = 4.
  2. Distance squared: 3² + 4² = 9 + 16 = 25.
  3. Distance: √25 = 5, a whole number, so the exact form is 5 (exact).
  4. Midpoint: ((1 + 4)/2, (2 + 6)/2) = (2.5, 4).
  5. Manhattan distance: 3 + 4 = 7, longer than the straight line, as it always is unless the points share a coordinate.

A distance with a root left in it, from the (0, 0) to (6, 6) preset: 6² + 6² = 72, and √72 = 6√2, or 8.48528137423857.

What Is the Distance Formula?

d = √((x₂ - x₁)² + (y₂ - y₁)²). It measures the length of the straight segment joining two points, and it comes straight from the Pythagorean theorem: the segment is the hypotenuse of a right triangle whose legs are the horizontal and vertical gaps. Because the differences are squared, it does not matter which point you call the first.

The (-3, 5) to (2, -7) preset spans two quadrants: the gaps are 5 and -12, and the distance is 13.

How Do You Calculate the Midpoint?

Add the two x coordinates and halve, then do the same with the y coordinates (and z, in 3D). The midpoint of (-3, 5) and (2, -7) is (-0.5, -1). The midpoint is the same distance from both ends, half the full distance from each.

What Is Manhattan Distance?

The distance between two points if you can only move along the axes, like a taxi on a street grid. NIST's Dictionary of Algorithms and Data Structures defines it as the sum of the absolute differences of the coordinates. For the (1, 2, 3) to (4, 6, 15) preset, the straight-line distance is 13 but the Manhattan distance is 19.

It is used in grid path-finding, in comparing data points in machine learning, and in city planning.

When Should You Use Manhattan Distance Instead?

Use the straight-line distance when movement is free in every direction: a drone, a cable run across open ground, the length of a brace. Use the Manhattan distance when movement is confined to a grid: walking city blocks laid out north to south and east to west, a forklift moving along warehouse aisles, or a chess rook.

The Manhattan figure is always at least as large as the straight-line one, and the two are equal only when the points lie on the same horizontal or vertical line.

Distance from the Origin to Common Points

The reference table gives the distance from (0, 0) to familiar points. Several rows, (3, 4), (5, 12), (8, 15) and (7, 24), are Pythagorean triples, where the distance comes out as a whole number. The others show their exact radical form.

What does this calculator not account for?

  • Distance on the Earth. Latitude and longitude are angles on a sphere, not flat coordinates. The distance between two places needs a great-circle formula, not this one.
  • Units. Both points must use the same unit; the distance comes out in that unit.
  • Distance from a point to a line. Only point-to-point distances are computed.
  • More than three dimensions. The formula extends naturally, but the calculator stops at three.

What mistakes do people make with this?

  • Forgetting to square the differences. Adding the plain differences gives the Manhattan distance, not the straight-line one.
  • Sign errors in the differences. Squaring removes the sign, but subtract matching coordinates: x from x, y from y.
  • Taking the square root of each term. √(9 + 16) is 5, not 3 + 4.
  • Averaging the wrong way for the midpoint. The midpoint averages the coordinates; it is not half of the differences.
  • Rounding before the root. Keep the sum of squares exact, then take the root.

Frequently Asked Questions

What is the distance between (1, 2) and (4, 6)?

5. The differences are 3 and 4, and √(9 + 16) = 5.

How do I find the distance in 3D?

Add the squared z difference under the root. Between (1, 2, 3) and (4, 6, 15) the differences are 3, 4 and 12, and the distance is 13.

Can a distance be negative?

No. It is a square root of a sum of squares, so it is zero or positive, and zero only when the points are the same.

How is the distance formula related to the Pythagorean theorem?

It is the same equation: a² + b² = c², with a and b the coordinate differences and c the distance.

What if the coordinates are decimals?

They work the same way. The (1.5, 2.5) to (4, 1) preset gives a distance squared of 8.5 and a distance of 2.91547594742265.

Sources

Did this calculator answer your question?

How this calculator is tested

This calculator is checked by 6 automated test cases: specific inputs whose correct result is known in advance, and rules the output must always obey. They run on every change to the site. See the testing and corrections policy.

Show the test cases
  • Default: (1, 2) to (4, 6) is 5
  • a radical: (0, 0) to (6, 6) is 6√2
  • across quadrants: (-3, 5) to (2, -7) is 13
  • three dimensions: (1, 2, 3) to (4, 6, 15) is 13
  • decimals and the same point
  • builds the reference table from compute()

Add This Website as Preferred Source on Google

See Bedrock Calculator first in your Search results & AI Overviews