Skip to content

Distance Formula Calculator

Space
Distance between the points —
Horizontal change Δx
—
Vertical change Δy
—
Distance squared
—
Midpoint
—
Slope of the segment
—

The distance between two points is d = √((x₂ − x₁)² + (y₂ − y₁)²). For (1, 2) and (4, 6), the changes are 3 and 4, so d = √(9 + 16) = √25 = 5 units. In three dimensions, add (z₂ − z₁)² under the root before taking the square root.

About this tool

Students checking coordinate geometry homework, programmers measuring gaps between sprites, and surveyors sanity-checking grid coordinates all need the same number: the straight-line length between two points. Enter the coordinates of both points in a flat plane or in 3D space and the calculator returns the Euclidean distance to four decimals, the change along each axis, the squared distance, the midpoint and, in 2D, the slope of the segment joining them. Every working line is listed, so the arithmetic can be copied straight into a solution. One limit: this is flat (Euclidean) geometry. Two latitude and longitude pairs on the globe need a great-circle formula such as haversine, not this one.

How to use it

  1. Choose 2D or 3D

    Pick 2D for points on a plane or 3D to reveal the z coordinate for each point.

  2. Enter point 1

    Type the x and y (and z) coordinates of the first point. Negative values and decimals are accepted.

  3. Enter point 2

    Type the coordinates of the second point. The order of the points does not change the distance.

  4. Read the working

    The distance updates as you type, with Δx, Δy, the midpoint, the slope and each step of the calculation.

Examples

(-3, -1) to (2, 3)

Space
2D (x, y)
Point 1 x
-3
Point 1 y
-1
Point 2 x
2
Point 2 y
3

Result Distance between the points: 6.4031
Horizontal change Δx: 5
Vertical change Δy: 4
Distance squared: 41
Midpoint: (-0.5, 1)
Slope of the segment: 0.8

  1. Δx = 2 − -3 = 5
  2. Δy = 3 − -1 = 4
  3. Sum of squares = 25 + 16 = 41
  4. d = √41 = 6.4031

Δx = 5 and Δy = 4, so the distance is √(25 + 16) = √41, a little over 6.4 units.

(1, 2) to (4, 6)

Space
2D (x, y)
Point 1 x
1
Point 1 y
2
Point 2 x
4
Point 2 y
6

Result Distance between the points: 5
Horizontal change Δx: 3
Vertical change Δy: 4
Distance squared: 25
Midpoint: (2.5, 4)
Slope of the segment: 1.333333

  1. Δx = 4 − 1 = 3
  2. Δy = 6 − 2 = 4
  3. Sum of squares = 9 + 16 = 25
  4. d = √25 = 5

The legs are 3 and 4, the classic 3-4-5 triangle, so the points sit exactly 5 units apart.

3D: (1, 2, 3) to (4, 6, 15)

Space
3D (x, y, z)
Point 1 x
1
Point 1 y
2
Point 1 z
3
Point 2 x
4
Point 2 y
6
Point 2 z
15

Result Distance between the points: 13
Horizontal change Δx: 3
Vertical change Δy: 4
Distance squared: 169
Midpoint: (2.5, 4, 9)
Slope of the segment: n/a in 3D

  1. Δx = 4 − 1 = 3
  2. Δy = 6 − 2 = 4
  3. Δz = 15 − 3 = 12
  4. Sum of squares = 9 + 16 + 144 = 169
  5. d = √169 = 13

Adding the z-axis gives √(9 + 16 + 144) = √169 = 13 units.

How it is calculated

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

d
straight-line distance between the points
x₁, y₁, z₁
coordinates of the first point
x₂, y₂, z₂
coordinates of the second point (drop the z term in 2D)

The segment between two points is the hypotenuse of a right triangle whose legs are the changes along each axis, so the Pythagorean theorem gives its length. Squaring each difference removes the sign, which is why reversing the order of the points gives the same answer. In 3D the theorem is applied twice, adding the z difference under the same root. The midpoint averages each coordinate, and the 2D slope is Δy divided by Δx.

When not to use it

  • Points given as latitude and longitude on Earth need a great-circle formula, not a flat one.
  • Travel along a street grid is measured by Manhattan distance, the sum of the axis changes.
  • Distance from a point to a line or a plane needs a different formula.

Common mistakes

  • Subtracting x from y instead of pairing each coordinate with the same axis.
  • Forgetting that a negative difference squared is positive, so (−3)² is 9, not −9.
  • Adding the differences before squaring, which gives (Δx + Δy)² instead of Δx² + Δy².
  • Stopping at the sum of squares and reporting d² as the distance.

Frequently asked questions

Where does the distance formula come from?

It is the Pythagorean theorem written in coordinates. Draw a horizontal leg of length |x₂ − x₁| and a vertical leg of length |y₂ − y₁|; the segment between the points is the hypotenuse, so its length is the square root of the sum of the squared legs.

Does it matter which point I enter first?

No. Each difference is squared, so (4 − 1)² and (1 − 4)² are both 9. The distance and the midpoint are the same either way; only the signs of Δx and Δy flip.

How does the 3D version differ?

It adds a third squared term, (z₂ − z₁)², inside the square root. For (1, 2, 3) and (4, 6, 15) that is √(9 + 16 + 144) = √169 = 13 units.

Why is the answer often an irrational number?

The sum of squares is usually not a perfect square. For (−3, −1) and (2, 3) it is 41, so the exact distance is √41, which the calculator shows as 6.4031. The squared distance stat gives the exact value under the root.

What units is the distance in?

The same units as the coordinates. If x and y are in metres, the distance is in metres; on an unlabelled graph it is simply units. Both points must use the same scale on every axis.

Why does the slope say undefined?

When both points share the same x value the segment is vertical, and the slope Δy ÷ Δx would divide by zero. The distance is then just the absolute difference in y.

Can I use this for GPS coordinates?

Only over very short spans after converting to a flat projection in metres. Raw latitude and longitude degrees are not equal lengths, and the Earth curves, so use a haversine or great-circle calculation instead.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, October 26). Distance Formula Calculator. Tools Directory. Retrieved October 26, 2026, from https://tools.milunir.com/math/algebra-tools/distance-formula-calculator/

MLA

Tools Directory Editorial Team. “Distance Formula Calculator.” Tools Directory, 26 Oct. 2026, https://tools.milunir.com/math/algebra-tools/distance-formula-calculator/. Accessed 26 Oct. 2026.

Chicago

Tools Directory Editorial Team. “Distance Formula Calculator.” Tools Directory. Last modified October 26, 2026. Accessed October 26, 2026. https://tools.milunir.com/math/algebra-tools/distance-formula-calculator/.

Link<a href="https://tools.milunir.com/math/algebra-tools/distance-formula-calculator/">Distance Formula Calculator – Tools Directory</a>