Distance Formula Calculator
The distance between two points in exact radical form, with every step of the substitution shown — in 2D or 3D.
Updated
Distance and midpoint
4√13
Exactly 4√13, which is about 14.4222.
- Δx — the gap along x
- 12, squared 144
- Δy — the gap along y
- 8, squared 64
- Sum under the root
- 208
- Distance
- 4√13 ≈ 14.4222
- Midpoint
- (6, 4)
- Manhattan distance
- 20
The substitution, written out. d = √(12² + 8²) = √(144 + 64) = √208 = 4√13 ≈ 14.4222.
Euclidean against Manhattan. The distance above cuts straight through the space; the Manhattan figure of 20 goes along the axes instead, as a taxi would along a grid of streets. They agree only when the two points already share every coordinate but one.
This is distance on a coordinate plane. Distance between two street addresses follows roads and is longer, and distance between a pair of latitudes and longitudes curves with the Earth. Neither comes from this formula.
Advertisement
In short
What is the distance formula?
The distance between (x₁, y₁) and (x₂, y₂) is the square root of (x₂ − x₁)² + (y₂ − y₁)². It is the Pythagorean theorem with the two gaps as the short sides. From (0, 0) to (12, 8) that is √208, which is exactly 4√13 and about 14.4222.
The exact answer is usually a radical. A decimal is a rounding of it, which is fine for a drawing and wrong on an answer sheet.
How to use the distance formula calculator
The distance formula is the Pythagorean theorem wearing coordinates. Draw the horizontal gap between two points and the vertical gap, and you have the two short sides of a right triangle whose hypotenuse is the distance you want. That is the whole idea, and it is why the formula never needs memorising separately from a² + b² = c².
Because both gaps are squared, their signs disappear before the root is taken. The two points can therefore be given in either order, and negative coordinates need no special treatment. From (−2, −3) to (2, 5) the gaps are 4 and 8 whichever end you start from, and the distance is the same either way.
4√13
Distance from (0,0) to (12,8)
about 14.4222
5
Distance from (0,0) to (3,4)
a whole number, and rare
√2
Distance from (0,0) to (1,1)
irrational, like most
Those three are worth comparing. A distance that lands on a whole number needs the two gaps to form a Pythagorean triple, and triples are scarce: 3-4-5, 5-12-13, 8-15-17, 7-24-25 and their multiples. Every other pair of whole-number coordinates gives an irrational distance, so a radical is the normal case rather than the awkward one.
Advertisement
A third axis changes nothing structurally. In space the formula gains one more squared term and becomes the square root of Δx² + Δy² + Δz², which is the Pythagorean theorem applied twice — once in the base plane and once to lift that result to the point above it. The toggle above switches between the two.
- Two points in the same space
- required
- The order they are given
- does not matter
- Negative coordinates
- need no special handling
- A straight, unobstructed path
- assumed
- Any units at all
- never used — the answer is in whatever the inputs were
That last row is the one that trips people up. The formula is dimensionless: feed it metres and it returns metres, feed it pixels and it returns pixels. It has no way to know and never converts anything.
Do
- Give the exact radical when an answer sheet asks for a distance
- Subtract the coordinates in the same order on every axis
- Check the two gaps against the picture before trusting the number
- Use a great-circle formula for latitude and longitude instead
Don't
- Round to a decimal and call it the exact answer
- Feed latitudes and longitudes into this formula
- Expect the answer to a whole-number pair to be whole
- Assume the result carries the units you had in mind
The line through those two points
The same pair of coordinates also determines a slope, an equation and both intercepts. The slope page works all of them out from the two points you already have.
Open the slope calculator →Point pairs with their two gaps, the number that ends up under the root, and the distance in exact form.
| From → to | Δx, Δy | Under the root | Distance |
|---|---|---|---|
| (0,0) → (3,4) | 3, 4 | 25 | 5 |
| (0,0) → (5,12) | 5, 12 | 169 | 13 |
| (0,0) → (8,15) | 8, 15 | 289 | 17 |
| (0,0) → (7,24) | 7, 24 | 625 | 25 |
| (0,0) → (12,8) | 12, 8 | 208 | 4√13 |
| (0,0) → (1,1) | 1, 1 | 2 | √2 |
| (1,2) → (4,8) | 3, 6 | 45 | 3√5 |
| (−2,−3) → (2,5) | 4, 8 | 80 | 4√5 |
| (3,1) → (3,9) | 0, 8 | 64 | 8 |
| (0,0,0) → (1,2,2) | 1, 2, 2 | 9 | 3 |
Three different things are called the distance between two points
Search for the distance between two points and the results split three ways, because three unrelated quantities share the phrase. This page computes one of them, and knowing which is the difference between a right answer and a confidently wrong one.
- Coordinate distance
- √(Δx² + Δy²) — this page
- Driving distance
- follows roads, and is always longer
- Great-circle distance
- follows the curve of the Earth
- What tells them apart
- what the two inputs actually are
- The giveaway
- latitudes and longitudes are not coordinates on a plane
A pair of street addresses wants driving distance. A pair of latitudes and longitudes wants a great-circle calculation, because the Earth is not flat and degrees of longitude shrink towards the poles. Only a pair of Cartesian coordinates wants this formula.
The failure is quiet, which is what makes it worth naming. Feed a latitude and longitude into the formula here and it returns a number rather than an error — a meaningless one, in degrees, which is not a unit of length. Nothing about the output will tell you the wrong tool was used.
Why it is called Euclidean distance
The name distinguishes it from other ways of measuring how far apart two points are. Euclidean distance goes straight through the space between them. Manhattan distance, also called taxicab distance, goes along the axes instead, the way a taxi crosses a grid of streets rather than driving through the buildings.
- From
- (0, 0)
- To
- (3, 4)
- Euclidean, through the space
- √(9 + 16) = 5
- Manhattan, along the axes
- 3 + 4 = 7
- The gap between them
- 2, or forty percent
- Both are correct
- they answer different questions
The two agree only when the points already share every coordinate but one, because then there is no corner to go around. Otherwise Euclidean is the smaller of the two, which is the triangle inequality showing up as arithmetic.
The distinction matters beyond geometry. Machine learning uses both as measures of similarity between records, and they can rank the same set of neighbours differently. Euclidean is the default almost everywhere, which is precisely why the name is worth attaching to it rather than calling it just the distance.
The idea also extends past three axes without changing shape. For points described by many numbers rather than two or three, the Euclidean distance is still the square root of a sum of squared differences, with one term per number. This page handles two axes and three, which is where the geometry stays drawable.
One distance, and infinitely many points that give it
The formula runs one way without complaint and refuses to run backwards, which is worth understanding rather than treating as a limitation. Two points give exactly one distance. One point and a distance give infinitely many second points, and no amount of algebra narrows that down, because the information genuinely is not there.
The set of them has a familiar shape. Every point sitting a distance d from a fixed point (x₁, y₁) satisfies (x − x₁)² + (y − y₁)² = d², which is the equation of a circle of radius d centred on that point. The distance formula and the equation of a circle are the same statement, rearranged.
- (3, 4)
- √(9 + 16) = 5
- (4, 3)
- √(16 + 9) = 5
- (−3, 4)
- √(9 + 16) = 5
- (0, 5)
- √(0 + 25) = 5
- (5cos θ, 5sin θ)
- 5, for every angle θ
- How many such points
- infinitely many — a whole circle
The last row is the general case and the first four are just convenient members of it. This is why a GPS fix needs several satellites rather than one: a single distance narrows you to a sphere, not to a place.
In three dimensions the same rearrangement gives (x − x₁)² + (y − y₁)² + (z − z₁)² = d², which is a sphere rather than a circle. Adding an axis adds a squared term and nothing else, exactly as it does in the distance formula itself, because the two equations were never really different.
When a decimal is the wrong answer
Most distances between whole-number coordinates are irrational, meaning no decimal ever finishes writing them. The square root of 208 is not 14.4222; it is a number whose digits continue without repeating, and 14.4222 is where the rounding stopped. Writing an equals sign between them is false, and this page uses "about" instead.
- The gaps
- Δx = 12 and Δy = 8
- Squared
- 144 and 64
- Under the root
- 208
- Largest square factor
- 16, since 208 = 16 × 13
- Which comes out as
- √16 = 4
- Simplified
- 4√13
Nothing was approximated anywhere in that column. 4√13 is exactly as precise as √208 and easier to read, which is why it is the form an answer sheet expects. The decimal is a separate, lossy step taken afterwards.
Not every radicand simplifies. The square root of 13 stays as it is because 13 is prime and has no square factor to remove, and the same is true of √2 and √145. In those cases the radical shown is simply the root itself, and it is still the exact answer rather than the decimal beneath it.
Advertisement
The formula, worked line by line
One formula, and a third axis only lengthens the sum underneath the root. Nothing else about it changes between two dimensions and three.
“Square the gaps, add them, take the root. The only judgement in the whole calculation is whether to leave the answer as a radical or spend precision on a decimal.”
That judgement is worth making deliberately rather than by habit. A radical is exact and belongs in an algebra answer; a decimal is measurable and belongs on a drawing. Neither is more correct in general, and the two are not interchangeable in either direction.
distance = √((x₂ − x₁)² + (y₂ − y₁)²)
in three dimensions = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
Manhattan distance = |x₂ − x₁| + |y₂ − y₁|
simplified radical: pull the largest square factor out from under the root- Horizontal gap
- 2 − (−2) = 4
- Vertical gap
- 5 − (−3) = 8
- Squared and added
- 16 + 64 = 80
- Simplified
- √80 = 4√5
- Midpoint
- (0, 1)
- Distance
- 4√5, about 8.9443
The midpoint is the one figure here that involves no squaring, which is why it can come out negative and the distance never can. It is a plain average of each axis, taken separately.
Why the formula cannot go wrong by a sign
Every term under the root is a square, and a square is never negative. That makes the sum non-negative, the root real, and the distance zero only when the two points coincide. There is no arrangement of inputs that produces a negative distance or an imaginary one, which is not true of most formulas with a root in them.
The midpoint, which behaves quite differently
- Distance
- subtracts, then squares
- Midpoint
- adds, then halves
- Distance sign
- never negative
- Midpoint sign
- negative whenever the points are
- Order of the points
- irrelevant to both
They are computed from the same two points and share almost nothing else. Confusing which one squares is the quickest way to produce a midpoint that is nowhere near the segment it belongs to.
One consequence is a useful check: the midpoint should sit the same distance from each endpoint. If those two halves come out unequal, the arithmetic went wrong, because the midpoint is the only point on the segment for which they must match.
Advertisement
Questions people ask
What is the distance formula?
The distance between (x₁, y₁) and (x₂, y₂) is √((x₂ − x₁)² + (y₂ − y₁)²). It is the Pythagorean theorem applied to the horizontal and vertical gaps between the points, which form the two short sides of a right triangle whose hypotenuse is the distance. From (0, 0) to (12, 8) that gives √208, or exactly 4√13.
How do you find the distance between two points?
Subtract the x coordinates, subtract the y coordinates, square both results, add them, and take the square root. The order of the two points makes no difference because the differences are squared. Simplify the radical if the number under the root has a square factor, since that form is exact where a decimal is not.
Does the order of the two points matter?
No. Reversing them flips the sign of every difference, and squaring removes the signs before anything else happens. The same is true of the midpoint, which adds rather than subtracts. Slope is the calculation where order does matter, because it divides one difference by another instead of squaring them.
What is the distance formula in three dimensions?
It gains one more squared term: √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). That is the Pythagorean theorem applied twice, once across the base plane and once to lift the result up to the point above it. From the origin to (1, 2, 2) the terms are 1, 4 and 4, which add to 9, so the distance is exactly 3.
Why is my answer a square root instead of a number?
Because most distances between whole-number coordinates are irrational, and the radical is the exact value. A whole-number distance requires the two gaps to form a Pythagorean triple such as 3-4-5 or 5-12-13, and those are scarce. Leaving the answer as 4√13 is more precise than rounding it to 14.4222.
What is Euclidean distance?
It is this formula — the straight-line distance through the space between two points, named to distinguish it from other measures. Manhattan or taxicab distance instead adds the gaps along each axis, the way a taxi crosses a grid of streets. From (0, 0) to (3, 4) the Euclidean distance is 5 and the Manhattan distance is 7.
Can I use this for the distance between two cities?
No. Latitudes and longitudes are angles on a sphere rather than coordinates on a plane, so this formula returns a meaningless number in degrees rather than a length. City distances need a great-circle calculation, and travel distances need a route that follows roads. Both are longer than any straight line through the Earth.
Sources
Where the constants and formulas on this page come from. Each line names the figure it backs.
The distance between two points follows from the Pythagorean theorem applied to their horizontal and vertical separations.
Distance — Wolfram MathWorld
Taxicab or Manhattan distance sums the absolute differences along each axis rather than taking the root of their squares.
Taxicab Metric — Wolfram MathWorld
A Pythagorean triple is a set of three positive integers satisfying a² + b² = c², which is why so few whole-number coordinate pairs give a whole-number distance.
Pythagorean Triple — Wolfram MathWorld
Related guides
Math
Why the Quadratic Formula Loses Accuracy on One of Its Two Roots
Completing the square takes four lines and produces the formula. It also shows which of the two roots is safe to trust, and the calculator on this site was corrected to use the other route.
August 19, 2026 · 10 min read
Math
Geometry Backwards: Finding the Radius from the Area
Every geometry formula is printed in the direction you need least. Running it backwards is not the same operation reversed; it is a root, and roots can refuse.
August 17, 2026 · 10 min read
Math
When Cross Multiplication Gives You the Wrong Answer
Cross multiplication answers every question you put to it, including the ones it should refuse. The test is one line: if the input were zero, would the output be zero?
August 17, 2026 · 10 min read