Calculate the distance between two points instantly using the distance formula, with step-by-step solutions, graphs, worked examples and practical applications.
For two points in a plane, d = √((x₂ − x₁)² + (y₂ − y₁)²). Subtract the coordinates, square both differences, add them, then take the square root. From (2, 3) to (8, 9): the differences are 6 and 6, the squares add to 72, and d = √72 ≈ 8.485. In three dimensions just add the z term: d = √(Δx² + Δy² + Δz²). This is nothing more than the Pythagorean theorem — Δx and Δy are the legs of a right triangle and the distance is its hypotenuse.
Enter the coordinates of two points. Negatives and decimals are fine, and results update as you type.
Point 1 (P₁)
Point 2 (P₂)
One point per line as x, y — or x, y, z for a 3D path. Commas, spaces and tabs all work as separators.
| Property | Value |
|---|
Distance is the length of the straight line between two positions. In coordinate geometry those positions are given as ordered pairs or triples of numbers, and the distance between them is computed rather than measured — which is the whole point. Once a shape or a site is described by coordinates, every length in it can be calculated exactly, with no tape measure and no accumulated error.
Distance is always positive or zero. It has no direction, which makes it a scalar rather than a vector, and it is zero only when the two points are identical. Swapping the points changes nothing, because squaring removes the sign of the differences.
Read it as four steps: subtract, square, add, square-root. The subtraction gives you how far apart the points are along each axis; squaring makes those differences positive and lets them combine; the square root brings the result back to the original units.
The system underpinning all of this is named after René Descartes, who linked algebra and geometry in the 1630s by describing position with numbers. Two perpendicular axes meet at the origin (0, 0); a point is located by how far it sits along the x-axis and then the y-axis, written (x, y). The plane divides into four quadrants, and coordinates can be negative in any of them, which is why the formula relies on squaring rather than on assuming a positive direction.
Adding a third perpendicular axis gives (x, y, z) and three-dimensional space. Descartes' insight is the reason a surveyor's field notes, a CAD drawing and a video game world can all be handled by the same arithmetic.
Use this whenever both points lie on a flat plane — a site plan, a graph, a screen, a map at small scale. Take the two coordinate pairs, find Δx and Δy, and combine them.
The extension to three dimensions is simply one more squared term. It applies to anything with height as well as position: a crane hook above a slab, a pipe run through a building, a point in a 3D model.
"Euclidean distance" is the formal name for the straight-line distance this calculator returns, so called because it follows the geometry Euclid set out. It is one of several ways to define distance, and knowing the alternatives explains why the calculator reports them too.
| Metric | Formula (2D) | Meaning | Used in |
|---|---|---|---|
| Euclidean | √(Δx² + Δy²) | Straight line, as the crow flies | Geometry, surveying, physics |
| Manhattan | |Δx| + |Δy| | Only along the grid, no diagonals | City-block routing, circuit layout, some machine learning |
| Chebyshev | max(|Δx|, |Δy|) | The larger single-axis move | Chess king moves, CNC and warehouse robotics |
For (−4, 5) to (6, −7) the Euclidean distance is 15.62, the Manhattan distance is 22 and the Chebyshev distance is 12. All three are correct answers to different questions.
The distance formula is not a separate rule to memorise — it is the Pythagorean theorem in disguise. Draw a horizontal line from P₁ and a vertical line down to P₂ and you have a right triangle whose legs are |Δx| and |Δy|. Pythagoras says a² + b² = c², so c = √(Δx² + Δy²), which is exactly the formula. The graph in the calculator draws those legs as dashed lines so the triangle is visible.
That connection explains the squaring, and it means anything you know about right triangles applies here. The classic 3-4-5 triangle shows up whenever Δx = 3 and Δy = 4, giving a distance of precisely 5 — which is why builders use it to check a corner is square. See the Pythagorean theorem calculator for the theorem on its own, or the triangle calculator to solve the whole triangle.
The distance between two points is the length of the line segment joining them, so this one calculation answers several coordinate-geometry questions at once. The midpoint is the average of the coordinates, M = ((x₁ + x₂)/2, (y₁ + y₂)/2), and it lies exactly half the distance from each end. The slope m = Δy / Δx describes the steepness of that segment, and it is undefined for a vertical line, where Δx = 0. From the slope and one point you can write the line's equation as y = mx + b.
Those three together also settle questions about shapes. Equal distances prove a triangle is isosceles; equal diagonals help identify a rectangle; slopes whose product is −1 prove two segments are perpendicular. The slope calculator covers gradients in more detail.
Surveyors record positions as coordinates on a grid — in Australia, typically MGA eastings and northings — and compute every boundary length, offset and traverse leg with the distance formula. Because the arithmetic is exact, a closed traverse can be checked for error by seeing whether the computed positions return to the starting point.
Setting out a building is coordinate geometry with string lines. Diagonals are calculated first and then measured to confirm squareness, since two equal diagonals prove a rectangle where two equal sides do not. Excavation depths, level differences and pipe runs add the third dimension.
Architectural drawings are coordinate models. Clearances, sight lines, ramp lengths and the true length of a sloping roof plane all come from distance calculations rather than scaled measurements off a drawing, which avoids the error that scaling introduces.
Geographic information systems store features as coordinates and use distance constantly — nearest-facility queries, buffer zones, route lengths. There is one important caveat: latitude and longitude are angles on a sphere, not a flat grid, so applying the plain distance formula to degrees gives a wrong answer that grows with latitude. Over long distances GPS software uses the Haversine formula or an ellipsoidal method such as Vincenty. Melbourne to Sydney is about 713 km great-circle; treating the coordinates as flat numbers would not give that. For local work, projected coordinates in metres make the flat formula perfectly valid, which is why surveyors project first and calculate second.
Distance drives collision detection, aim assist, level-of-detail switching and lighting falloff. Because square roots are relatively expensive, engines usually compare squared distances — if you only need to know which of two objects is nearer, or whether something is within range, the square root is unnecessary. That optimisation is one of the most widely used tricks in real-time graphics.
Euclidean distance is the default similarity measure in clustering and nearest-neighbour algorithms, where each observation is a point in many dimensions. The formula generalises straight away: square every coordinate difference, add them all, take the root.
c. 1800 BCE — Ancient Egypt and Babylon. Egyptian rope-stretchers re-established field boundaries after each Nile flood using knotted cords, and Babylonian tablets such as Plimpton 322 list number triples that satisfy the Pythagorean relationship — centuries before any proof existed.
c. 530 BCE — Pythagoras. The relationship a² + b² = c² is formalised and proved in the Greek tradition, giving the rule that still sits underneath every distance calculation.
c. 300 BCE — Euclid. The Elements places length and the right triangle on a deductive footing, defining distance geometrically rather than by measurement.
1637 — René Descartes. La Géométrie links algebra to geometry by describing position with numbers. Once a point is a pair of coordinates, the Pythagorean theorem can be written as a formula — and the distance formula as we use it is born.
1960s onward — CAD. Computer-aided design turns drawings into coordinate models, so every length in a building or component is calculated rather than scaled off paper.
1980s onward — GIS and GPS. Geographic information systems store the world as coordinates, while satellite positioning fixes them to within metres. Both had to confront the same limitation: the Earth is curved, so long-range distances use the Haversine formula or an ellipsoidal method, and only projected coordinates in metres can use the flat formula directly.
| Mistake | Why it goes wrong | How to avoid it |
|---|---|---|
| Forgetting the square root | You have the squared distance, not the distance | √ is the final step, always |
| Adding before squaring | (Δx + Δy)² is not Δx² + Δy² | Square each difference first, then add |
| Mishandling negative coordinates | 6 − (−4) is 10, not 2 | Subtracting a negative adds; brackets help |
| Mixing up the order of coordinates | Pairing x₁ with y₂ gives nonsense | Compute Δx and Δy separately and label them |
| Expecting a negative distance | Squaring removes sign, so distance is never negative | A negative result means an arithmetic slip |
| Using the flat formula on latitude and longitude | Degrees are angles on a sphere, not grid metres | Use Haversine, or project to metres first |
| Ignoring the z coordinate | The 2D distance understates a sloping run | Switch to 3D whenever heights differ |
| Mixing units | Metres with millimetres gives a meaningless length | Convert all coordinates to one unit first |
| Assuming slope and distance are related | Two segments can share a slope and differ in length | Slope is direction; distance is magnitude |
d = √((x₂−x₁)² + (y₂−y₁)²)d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)d = √(Σ(differences)²)d = √(x² + y²)((x₁+x₂)/2, (y₁+y₂)/2)m = Δy/Δx | Line: y = mx + bm₁ × m₂ = −1|Δx| + |Δy| | Chebyshev: max(|Δx|, |Δy|)θ = atan2(Δy, Δx)Haversine, not the flat formula3-4-5, 5-12-13, 8-15-17, 7-24-25
1) √(9 + 16) = 5 2) √(9 + 16) = 5 3) ((2+8)/2, (6+10)/2) = (5, 8) 4) The x values match, so it is just the vertical difference: 7 5) No — squaring removes any sign, so distance is always zero or positive
1) √(100 + 144) = √244 ≈ 15.620 2) √(16 + 9 + 144) = √169 = 13 3) m = 6/6 = 1, so y = x + 1 4) √(17.64 + 12.96) = √30.6 ≈ 5.532 m 5) Path = 5 + 5 = 10; straight line = 6, a detour factor of about 1.67 6) Δx = 6, Δy = 8 → Euclidean 10, Manhattan 14, Chebyshev 8 7) The two upper sides are both √(4 + 9) = √13 ≈ 3.606 while the base is 4, so yes, it is isosceles 8) Because degrees of latitude and longitude are angles on a curved surface, and a degree of longitude shrinks towards the poles — use the Haversine formula or project the coordinates to metres first
What is the distance formula?
In two dimensions it is d = √((x₂ − x₁)² + (y₂ − y₁)²). Subtract the coordinates to get the horizontal and vertical differences, square each one, add them, then take the square root. In three dimensions add a (z₂ − z₁)² term. The formula comes directly from the Pythagorean theorem, with the coordinate differences forming the two legs of a right triangle.
How do you calculate the distance between two points?
Four steps. Find Δx = x₂ − x₁ and Δy = y₂ − y₁. Square both. Add the squares. Take the square root. For (2, 3) and (8, 9): Δx = 6, Δy = 6, squares are 36 and 36, the sum is 72, and d = √72 ≈ 8.485. Squaring means the order of the two points never matters.
What is Euclidean distance?
Euclidean distance is the straight-line distance between two points — the shortest possible path, measured as the crow flies. It is named after Euclid because it follows the geometry set out in his Elements, and it is what the standard distance formula computes. Alternatives such as Manhattan and Chebyshev distance measure movement restricted to a grid instead.
How do I find the distance between coordinates?
Enter both coordinate pairs into the calculator above, or apply the formula by hand. If the coordinates are latitude and longitude, do not use the flat formula — geographic coordinates are angles on a sphere and need the Haversine formula, or a projection into metres first. For coordinates already in metres, such as a survey grid, the flat formula is exactly right.
What is the distance formula in geometry?
It is the formula that gives the length of the line segment joining two points, d = √((x₂ − x₁)² + (y₂ − y₁)²). Together with the midpoint formula and the slope formula it forms the core toolkit of coordinate geometry, letting you prove that shapes are isosceles, right-angled, parallel or perpendicular using arithmetic rather than measurement.
How do you calculate 3D distance?
Add the third dimension to the same pattern: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). From (1, 2, 3) to (4, 6, 3): the differences are 3, 4 and 0, the squares sum to 25, and d = 5. Switch the calculator to 3D whenever the two points differ in height, since the 2D answer would understate a sloping run.
How is distance related to the Pythagorean theorem?
They are the same statement. Draw a horizontal line from the first point and a vertical line to the second and you form a right triangle whose legs are |Δx| and |Δy|. Pythagoras gives c = √(a² + b²), which is precisely the distance formula. This is why Δ values of 3 and 4 always produce a distance of exactly 5.
How do surveyors calculate distance?
Surveyors work in projected grid coordinates — in Australia usually Map Grid of Australia eastings and northings in metres — and apply the distance formula directly, because a projected grid is flat by construction. Modern instruments measure distances electronically and record coordinates, then software computes boundary lengths and checks a closed traverse by testing whether the calculated positions return to the starting point.
How do engineers calculate distance?
Usually in three dimensions, since real structures have height. Bracket positions, pipe runs, cable lengths and clearances all come from coordinate differences in a CAD model. Engineers also use the same arithmetic in vector form, where the distance between two points is the magnitude of the vector joining them — the same square-root-of-squares calculation.
How do GPS systems calculate distance?
Not with the flat distance formula. Latitude and longitude are angles on a curved surface, and a degree of longitude gets shorter towards the poles, so treating them as grid numbers produces an error that grows with latitude. GPS software uses the Haversine formula for great-circle distance on a sphere, or an ellipsoidal method such as Vincenty for higher accuracy. Melbourne to Sydney is roughly 713 km great-circle. For local work the coordinates are projected into metres first, after which the flat formula applies normally.
Can distance be negative?
No. Both differences are squared, which removes any sign, and the square root returns the positive value. Distance is zero only when the two points are identical. If a calculation gives a negative distance, an arithmetic error has been made — most often a mishandled minus sign when subtracting a negative coordinate.
What units are used for distance?
Whatever units the coordinates use — the formula does not change them. Coordinates in metres give a distance in metres; coordinates in pixels give pixels. The one rule is consistency: every coordinate must be in the same unit before you calculate. Australia uses metres and millimetres for construction and survey work, and the SI unit of length is the metre.
How do I calculate distance on a graph?
Read the coordinates of both points off the axes, then apply the formula. If the points sit on grid intersections you can simply count squares across and up to get Δx and Δy. Take care with graphs whose axes use different scales — count in axis units, not in centimetres on the page, or the answer will be wrong.
How do you find the length of a line segment?
The length of a line segment is the distance between its two endpoints, so it is the same calculation. This is how coordinate geometry proves properties of shapes: equal side lengths show a triangle is isosceles or equilateral, and equal diagonals help confirm a rectangle. The midpoint formula then gives the point that divides the segment into two equal halves.
What is Cartesian geometry?
Cartesian or coordinate geometry describes geometric shapes using numbers on a set of perpendicular axes, an idea introduced by René Descartes in the 1630s. It lets algebra solve geometric problems: lines become equations, distances and midpoints become formulas, and intersections become simultaneous equations. Everything from CAD software to computer games rests on it.
How do builders calculate distance?
Mostly by calculating diagonals. Setting out a rectangular slab means checking that both diagonals are equal, because equal sides alone do not guarantee square corners. For a 4.2 m by 3.6 m room each diagonal should measure √(17.64 + 12.96) ≈ 5.532 m. The 3-4-5 method is the same principle applied at a smaller scale with a tape measure.
How do architects use distance formulas?
Architectural models are coordinate models, so clearances, sight lines, ramp lengths, stair runs and the true length of a sloping roof plane are all computed rather than scaled off a drawing — scaling introduces error, calculation does not. Distance also feeds compliance checks such as travel distance to an exit and accessible-ramp gradients.
How is distance used in computer graphics?
Constantly: collision detection, whether a target is within range, which objects to draw at full detail, how light falls off with distance, and pathfinding costs. Because square roots are comparatively slow, engines often compare squared distances instead — if you only need to know which of two objects is closer, or whether something is inside a radius, the square root can be skipped entirely.
What is the difference between Euclidean and Manhattan distance?
Euclidean distance is the straight line between two points, √(Δx² + Δy²). Manhattan distance is the sum of the axis-aligned moves, |Δx| + |Δy|, as if you had to follow a city street grid. Manhattan distance is always greater than or equal to Euclidean distance, and they are equal only when the points share an x or y value. For (−4, 5) to (6, −7) the Euclidean distance is 15.62 and the Manhattan distance is 22.
What is the midpoint formula?
M = ((x₁ + x₂)/2, (y₁ + y₂)/2) — the average of the two x values and the average of the two y values. In 3D add (z₁ + z₂)/2. The midpoint lies exactly half the total distance from each endpoint, and it is the point you would mark to divide a boundary, a beam or a line segment into two equal parts.
Can this calculator solve 3D coordinates?
Yes. Switch the Dimensions option to 3D and z fields appear for both points. The calculator then applies the three-dimensional formula and reports Δz, the 3D midpoint and the direction ratios in place of a slope, since a line in space is described by direction ratios rather than a single gradient. The multi-point path box also accepts three values per line for a 3D route.
What are common mistakes in distance calculations?
Forgetting the final square root, which leaves the squared distance; adding the differences before squaring them, since (Δx + Δy)² is not Δx² + Δy²; mishandling negatives, where 6 − (−4) is 10 rather than 2; pairing x₁ with y₂; ignoring the z coordinate when heights differ; mixing units; and applying the flat formula to latitude and longitude.
Does this distance calculator show the steps?
Yes. It shows each subtraction, each squaring, the sum and the final square root, along with the formula in use. It also reports the midpoint, slope and line equation, Δx, Δy and Δz, Manhattan and Chebyshev distances, the angle from the x-axis and the compass bearing, and draws a graph with the right triangle behind the formula marked in dashed lines. The path tool adds per-segment lengths, the total, the straight-line distance and the detour factor.
A one-page reference with the distance, midpoint and slope formulas plus the Pythagorean triples worth memorising. Use the button to print it or save it as a PDF — everything else on the page is hidden from the printout.
MegaCalcOnline.com · Distance, midpoint, slope and Pythagorean triples
| Find | Formula | Notes |
|---|---|---|
| Distance (2D) | d = √((x₂−x₁)² + (y₂−y₁)²) | Subtract, square, add, square-root |
| Distance (3D) | d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²) | One extra squared term |
| Distance (n dimensions) | d = √(Σ differences²) | Same pattern in any number of axes |
| From the origin | d = √(x² + y²) | Magnitude of the position vector |
| Midpoint (2D) | M = ((x₁+x₂)/2, (y₁+y₂)/2) | Average of the coordinates |
| Midpoint (3D) | add (z₁+z₂)/2 | Half the distance from each end |
| Slope | m = Δy / Δx | Undefined when x₁ = x₂ (vertical) |
| Line through 2 points | y − y₁ = m(x − x₁) | Rearranges to y = mx + b |
| Parallel lines | m₁ = m₂ | Same gradient |
| Perpendicular lines | m₁ × m₂ = −1 | Negative reciprocal |
| Pythagorean theorem | a² + b² = c² | The origin of the distance formula |
| Manhattan distance | |Δx| + |Δy| | Grid movement only, no diagonals |
| Chebyshev distance | max(|Δx|, |Δy|) | The larger single-axis move |
| Angle from x-axis | θ = atan2(Δy, Δx) | Convert to degrees with ×180/π |
| Geographic distance | Haversine (great circle) | Never the flat formula on lat/long |
| Pythagorean triples | Check |
|---|---|
| 3, 4, 5 | 9 + 16 = 25 |
| 5, 12, 13 | 25 + 144 = 169 |
| 8, 15, 17 | 64 + 225 = 289 |
| 7, 24, 25 | 49 + 576 = 625 |
| 9, 40, 41 | 81 + 1600 = 1681 |
| 20, 21, 29 | 400 + 441 = 841 |
| Any multiple | 6-8-10, 30-40-50 and so on also work |
Educational use only. Distance is never negative, and the order of the two points never matters.