About the Distance Formula Calculator
The distance formula looks like something you have to memorise. It is not. It is Pythagoras' theorem, written for points instead of triangles, and if you can draw a right triangle you can rebuild it from scratch any time you forget it.
Mark two points on a grid. Now draw a horizontal line from the first and a vertical line from the second until they meet. You have made a right triangle whose legs you can read straight off the axes, and whose hypotenuse is exactly the gap you wanted to measure. a² + b² = c² finishes the job.
That is the whole derivation, and it explains why the formula extends to three dimensions without changing shape: you are simply applying the same theorem once more, upwards.
This calculator reports the answer as a decimal, as a simplified square root that loses no accuracy, as the individual differences along each axis, and as the squared distance — which turns out to be the more useful number more often than people expect.
How to Use the Distance Formula Calculator
Pick two dimensions or three dimensions.
Enter both points. In 2D that is x₁, y₁ and x₂, y₂; in 3D add z₁ and z₂. Negatives and decimals are accepted, and a coordinate of zero is a real value, not a blank.
Either point can go first — see the FAQ for why the order genuinely cannot matter here.
Press Calculate to see the answer and the intermediate squares.
The Distance Formula
Two dimensions:
d = √( (x₂ - x₁)² + (y₂ - y₁)² )
Three dimensions:
d = √( (x₂ - x₁)² + (y₂ - y₁)² + (z₂ - z₁)² )
Equivalently:
d² = dx² + dy² ( + dz² )
Read it as three instructions: subtract along each axis, square each result, add them up and take the root.
Because each difference is squared, its sign disappears. dx of −6 contributes 36 exactly as dx of +6 does. This is why you can enter the points in either order, and it is a genuinely different situation from gradient work, where reversing one coordinate changes the answer.
Why the squares matter
Adding the raw differences instead of their squares gives a different quantity altogether. From (0, 0) to (3, 4) the raw sum is 7, but the true distance is 5.
Seven is the distance you would walk following the grid — three across, then four up. Five is the distance a bird flies. Both are real measurements, and confusing them is the single most common error in this topic. The distance formula always gives the bird's answer.
Step-by-Step Example
Find the distance from (1, 2) to (7, 6).
Step 1 — differences. dx = 7 − 1 = 6, and dy = 6 − 2 = 4.
Step 2 — square them. 6² = 36, and 4² = 16.
Step 3 — add. 36 + 16 = 52.
Step 4 — root. d = √52 ≈ 7.2111.
Step 5 — simplify the surd. 52 = 4 × 13, and 4 is a perfect square, so √52 = 2√13. That is the exact answer; 7.2111 is a rounded one.
Try the reverse order to prove the point. dx = 1 − 7 = −6 and dy = 2 − 6 = −4. Squaring gives 36 and 16 again, so d = √52 once more.
Now a 3D case: from (1, 1, 1) to (4, 5, 13).
dx = 3, dy = 4, dz = 12
9 + 16 + 144 = 169
d = √169 = 13
A whole-number answer, which happens because 3, 4, 12, 13 form a Pythagorean quadruple — the 3D cousin of the familiar 3-4-5 triple.
Exact Answers and Why This Calculator Shows Surds
Most distances are irrational. The diagonal of a unit square is √2, a number whose decimal expansion never terminates or repeats. Writing it as 1.4142 is an approximation, and every approximation you carry forward makes the next answer a little wronger.
So this calculator simplifies the root wherever it can:
| Squared total | Simplified | Decimal | |---------------|-----------|---------| | 52 | 2√13 | 7.2111… | | 72 | 6√2 | 8.4853… | | 169 | 13 | exact | | 13 | √13 | 3.6056… |
The method is to pull out the largest perfect-square factor. For 72: 72 = 36 × 2, and √36 = 6, so √72 = 6√2. When nothing can be pulled out — 13 is prime — the root is already in its simplest form and the calculator says so rather than pretending otherwise.
If your work carries on beyond this step, use the surd. If you are measuring something physical, take the decimal and round it to the precision your ruler deserves.
Distance Squared: the Answer You Often Want
The squared distance is reported on its own because taking the root is sometimes a wasted step.
Suppose you want to know which of two shops is closer. Their squared distances are 169 and 200. That settles it — the first is nearer — and you never needed either root, because squaring preserves order for non-negative numbers.
This is exactly why graphics engines, collision detection and nearest-neighbour searches compare squared distances. Square roots are comparatively slow, and if the only question is "which is smaller?", the root changes nothing.
The squared distance is also the natural input to a circle equation, since (x − h)² + (y − k)² = r² is the distance formula with both sides squared.
Understanding Your Result
The distance is the decimal value, the straight-line gap between your points.
The exact form is the simplified square root, or a plain integer when the root resolves cleanly.
The differences show dx, dy and dz separately. Scan these first — a sign error or a mis-typed digit is obvious here and invisible in the final answer.
The distance squared is the sum before the root, ready for comparisons or a circle equation.
When Should You Use This Calculator?
Coordinate geometry coursework. Proving a triangle is isosceles means showing two distances are equal; proving a quadrilateral is a rhombus means showing four are. Exact surds make those comparisons clean.
Verifying a right angle. If the three side lengths satisfy a² + b² = c², the triangle is right-angled. Compute all three squared distances and check.
Mapping and surveying. With coordinates on a flat local grid, this is the as-the-crow-flies distance. Over long distances on the globe you need a great-circle formula instead, because the Earth is not a plane.
CAD, 3D modelling and games. The 3D mode gives the gap between two points in space, and the squared output is what most engine code actually compares.
Physics. Displacement magnitude is the distance between start and end positions, whatever route was taken in between.
Data work. Euclidean distance between two records with numeric fields is this same formula generalised to as many dimensions as you have columns.
Common Mistakes
Adding the differences instead of their squares. That gives the walking-the-grid distance, not the straight line.
Forgetting to take the root at the end. Stopping at 52 leaves you with the square of the answer.
Squaring only part of a subtraction. Compute (x₂ − x₁) fully, then square the result. Squaring each coordinate first and subtracting gives a different number entirely.
Mishandling negative coordinates. From −3 to 0 the difference is 0 − (−3) = 3. The double negative is where sign slips happen.
Treating a zero coordinate as missing. The origin is (0, 0), and those zeros belong in the formula.
Mixing units. Both points must be on the same scale. Metres against kilometres produces a meaningless answer with no warning.
Rounding the intermediate squares. Round once, at the end, or the error compounds under the root.