Maths

Distance Calculator

Find the distance and midpoint between two points in 2D or 3D, with the exact square-root form.

By Nitin Raturi · Last reviewed

Your points

How to use the Distance Calculator

Find the straight-line distance and the midpoint between two points.

  1. Choose 2D or 3D.
  2. Enter the coordinates of the first point.
  3. Enter the coordinates of the second point.
  4. Read the distance, its exact form and the midpoint.

Good to know

  • The order of the points does not change the distance.
  • For map coordinates in latitude and longitude, this flat formula is only approximate.

Use the same unit on every axis.

Dimensions

Dimensions

Whether the points lie on a flat plane (x, y) or in space (x, y, z).

How to fill it in

  • Choose 2D for graphs and maps; 3D adds a z-coordinate.

Example

In 3D, (1, 2, 3) to (4, 6, 15) is 13 apart.

x₁

The x-coordinate of the first point.

How to fill it in

  • Enter a number from −10,00,000 to 10,00,000. Decimals and negatives are fine.

Example

(−3, −1) to (2, 3) is √41 ≈ 6.403124 apart.

y₁

The y-coordinate of the first point.

How to fill it in

  • Enter a number from −10,00,000 to 10,00,000. Decimals and negatives are fine.

x₂

The x-coordinate of the second point.

How to fill it in

  • Enter a number from −10,00,000 to 10,00,000. Decimals and negatives are fine.

Example

The midpoint of (7, −2) and (9, 5) is (8, 1.5).

y₂

The y-coordinate of the second point.

How to fill it in

  • Enter a number from −10,00,000 to 10,00,000. Decimals and negatives are fine.

Example

A diameter from (−1, −4) to (5, −4) has its centre at (2, −4).

Distance from (−3, −1) to (2, 3)

6.403124

d = √(5² + 4²) = √41. Midpoint: (−0.5, 1).

Exact form
√41
Midpoint
(−0.5, 1)
Change (Δx, Δy)
(5, 4)

Straight-line (Euclidean) distance on flat axes. Rounded to six decimals for display.

How this calculator works

  1. Step 1DifferencesΔx, ΔyHow far apart the points are along each axis.
  2. Step 2Square and addΔx² + Δy²The legs of a right triangle, squared.
  3. Step 3Square rootd = √(…)The hypotenuse is the straight-line distance.

The distance formula is Pythagoras’ theorem applied to the gaps between coordinates. In 3D, the z-gap joins the sum.

When the squared distance is a whole number, the calculator also gives the exact answer as a simplified square root.

Worked example: (−3, −1) to (2, 3)

Distance between two points
Distance
d = √((x₂ − x₁)² + (y₂ − y₁)²)
  • (x₁, y₁)First point (−3, −1)
  • (x₂, y₂)Second point (2, 3)
  1. Δx2 − (−3)5
  2. Δy3 − (−1)4
  3. Squares5² + 4² = 25 + 1641
  4. Distance√41√41 ≈ 6.403124

This is Example 6 in OpenStax College Algebra 2e, section 2.1, which gives the same √41.

Midpoints

  • (7, −2) and (9, 5)(8, 1.5)OpenStax Example 7: (8, 3/2).
  • Circle centre(2, −4)Example 8: the midpoint of a diameter.
  • In 3D13(1, 2, 3) to (4, 6, 15): √169.

Read the result

The distance is always zero or more and the same in either direction; only the midpoint depends on both points equally.

The change row shows how far you move along each axis to get from the first point to the second.

Assumptions and limits

  • Flat axesStraight-line distance on a grid.
  • Same unitEvery axis uses one unit.
  • Not for the globeLatitude and longitude need a great-circle formula.
  • Exact formFor whole-number d² up to 1,00,00,00,00,000.

Distance comes from Pythagoras. Slopes and vectors use the same coordinates.

For the slope, equation and angle of the line, use the slope calculator. The vector calculator adds dot and cross products, and the root calculator simplifies the square root in an exact answer.

Common mistakes

  • Mistake: Adding the differences, not their squares.

    Instead: Square each difference, add, then take the root.

  • Mistake: Losing a minus sign: 2 − (−3) as −1.

    Instead: Subtracting a negative adds: 2 − (−3) = 5.

  • Mistake: Subtracting coordinates for the midpoint.

    Instead: Average them: add and divide by 2.

Checking the method

Every golden case is re-worked with exact fractions and Newton square roots, including OpenStax Examples 6 to 8.

An independent script squares the differences exactly and finds the largest square factor by trial, then compares each answer.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

What is the distance formula?

d = √((x₂ − x₁)² + (y₂ − y₁)²). From (−3, −1) to (2, 3) it gives √41 ≈ 6.403124.

How do I find the midpoint?

Average the coordinates. The midpoint of (7, −2) and (9, 5) is (8, 1.5).

How do I find the distance in 3D?

Add the z difference squared: (1, 2, 3) to (4, 6, 15) is √169 = 13.

How do I find the centre of a circle from a diameter?

Take the midpoint of the diameter's ends: (−1, −4) and (5, −4) give (2, −4).

Can I use this for latitude and longitude?

Only roughly, over short distances. The Earth is curved, so map coordinates need a great-circle formula.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 3 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.