Distance Formula Calculator

Find the distance between two points in 2D or 3D space. Enter coordinates and get the exact distance plus the midpoint, with every step shown.

Enter the coordinates of two points to find the distance between them and their midpoint.





Distance: —
Midpoint: —

Distance formula diagram showing two points and the straight line between them
Distance formula diagram showing two points and the straight line between them

How to Use the Distance Formula Calculator

The distance formula tells you the straight-line length between two points on a coordinate plane or in three-dimensional space. It is one of the most useful tools in geometry, and this calculator handles both the arithmetic and the midpoint for you.

  1. Choose 2D or 3D. Most school problems use 2D (x and y coordinates). Switch to 3D when your points also have a z coordinate, such as positions in a 3D game or physical space.
  2. Enter point A. Type the x, y (and z for 3D) coordinates of your first point. Decimals and negative numbers are fine.
  3. Enter point B. Type the coordinates of your second point in the same order.
  4. Read the results. The calculator shows the distance, the midpoint (the point exactly halfway between A and B), and a step-by-step breakdown so you can follow the math.

Distance Formula Explained

The distance formula is a direct application of the Pythagorean theorem. In two dimensions, the horizontal gap (dx) and vertical gap (dy) between the points form the legs of a right triangle, and the distance is the hypotenuse:

2D: distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)

In three dimensions you simply add the squared z-difference as well:

3D: distance = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)

The midpoint formula averages each pair of coordinates: midpoint = ((x1+x2)/2, (y1+y2)/2) in 2D, adding (z1+z2)/2 for 3D. The midpoint is useful whenever you need the center of a line segment, for example when bisecting a shape or finding the middle of a journey between two map coordinates.

Worked Example

Find the distance between A(1, 2) and B(4, 6). First compute the differences: dx = 4 - 1 = 3 and dy = 6 - 2 = 4. Square them: 3^2 = 9 and 4^2 = 16. Add: 9 + 16 = 25. Take the square root: sqrt(25) = 5. The distance is 5 units, a classic 3-4-5 right triangle. The midpoint is ((1+4)/2, (2+6)/2) = (2.5, 4). Try these same numbers in the calculator above and confirm you get the same answer.

Distance in 3D: A Worked Example

The 2D formula extends naturally to three dimensions by adding the z-difference under the square root. Suppose you need the distance between points P(1, 2, 3) and Q(4, 6, 8). First find the differences: Δx = 4 − 1 = 3, Δy = 6 − 2 = 4, Δz = 8 − 3 = 5. Then d = √(3² + 4² + 5²) = √(9 + 16 + 25) = √50 ≈ 7.07. Select the 3D mode in the calculator above and enter both points to see the same result with every step shown.

Manhattan Distance: Another Way to Measure

In a grid-like city, you cannot walk diagonally through buildings — you travel along streets. The Manhattan (taxicab) distance reflects that: d = |Δx| + |Δy|. From A(1, 2) to B(4, 6), the straight-line distance is 5, but the Manhattan distance is |3| + |4| = 7. It is the right metric for block-by-block movement, circuit-board routing, and grid-based games. Notice it is always at least as large as the straight-line distance.

Coordinate Distance vs Real-World Distance

A common mistake is feeding latitude and longitude into the distance formula as if they were flat x and y values. They are not: degrees of longitude shrink toward the poles, and the Earth is curved. The distance formula works perfectly on flat coordinate planes (graphs, maps with projected coordinates, game worlds), but for geographic coordinates use the Haversine formula, which accounts for the Earth's curvature. This calculator gives exact results for planar coordinates in any unit — pixels, meters, miles — because the formula is unit-agnostic: use the same unit for both points and the answer carries that unit.

Frequently Asked Questions

What is the distance formula used for?

It measures the straight-line distance between two points. Common uses include geometry homework, map distances, game development, physics displacement, and finding lengths in coordinate-based designs.

What is the difference between distance and displacement?

Distance is the total length of the path traveled, while displacement is the straight-line change from start to finish. The distance formula computes displacement-style straight-line length between two points.

How do I find the distance in 3D?

Add the squared z-difference under the square root: sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2). Select the 3D option above and the calculator handles it.

What is the midpoint formula?

Average each coordinate pair: ((x1+x2)/2, (y1+y2)/2) in 2D. It gives the exact center point of the segment joining A and B.

Can distance be negative?

No. Distance is always zero or positive because it comes from a square root of a sum of squares. A result of zero means the two points are identical.

What is Manhattan (taxicab) distance?

It is the distance measured along a grid, d = |Δx| + |Δy|, as if you could only walk along city blocks. From (1, 2) to (4, 6) it is 7, larger than the straight-line distance of 5. Use it for grid movement, circuit boards, and games.

Can I use this calculator with latitude and longitude?

No — latitude and longitude are not flat x and y coordinates, and degrees of longitude shrink toward the poles. For geographic distance use the Haversine formula, which accounts for Earth's curvature.

What does Δ (delta) mean in the distance formula?

Delta means 'change in.' Δx is the horizontal change (x2 − x1) and Δy is the vertical change (y2 − y1). The distance formula is the Pythagorean theorem applied to those two changes.

Related Calculators

Working with right triangles? Try the Pythagorean Theorem Calculator to find missing sides. For more geometry tools, explore the Scientific Calculator.

Worked distance formula example with a 3-4-5 right triangle
Worked distance formula example with a 3-4-5 right triangle

Scroll to Top