Distance Calculator
Pythagoras in disguise
Plot two points and draw the segment between them. Now complete the right triangle: one leg runs horizontally from the first point, the other vertically to the second. The horizontal leg's length is the difference of the x-coordinates, the vertical leg's is the difference of the y-coordinates, and the segment is the hypotenuse. That is the entire derivation — the distance formula is not a new fact to memorize but the Pythagorean theorem read off a graph. It also explains the squares: they are there because lengths combine through the theorem, and they conveniently erase sign, which is why the formula does not care which point you call first.
The 3D version follows by applying the theorem twice — first across the floor of a box to get the diagonal of the base, then up the side. The pattern continues into any number of dimensions, which is why the same formula measures distances between data points in statistics and machine learning, where each "coordinate" is a variable and the "points" are observations.
Choosing the right distance
Euclidean distance assumes the straight line is open. When it is not — a street grid, a chessboard king's guard, a warehouse aisle layout — the honest measure is the path you can actually travel: Manhattan distance on a grid, or a routing engine on a real road network. A third measure, Chebyshev distance (the larger of the two gaps), fits movement that allows diagonals at no extra cost, like a king in chess. Picking the measure is a modelling decision, not a mathematical one: the calculator gives you Euclidean and Manhattan side by side so the difference is visible before it matters.
Distance in the real world: screens, games and workshops
The formula's busiest modern home is the screen. Game engines compute it thousands of times a second — to decide which enemies notice the player, which sounds are audible, and what falls inside a blast radius — usually comparing squared distances to skip the square root, since ordering is preserved without it. Interface and data-visualisation code uses it to find the nearest point to a cursor. In the workshop the same arithmetic runs in reverse: given a diagonal measurement across a rectangle, equal diagonals prove the corners are square, which is why builders check both diagonals of a frame rather than trusting a tape on each side. And in statistics, standardising variables and measuring Euclidean distance between observations is the engine inside clustering and nearest-neighbour methods — the classroom formula, scaled to a thousand dimensions, still doing the same job of saying what "close" means.
One habit prevents most errors with this formula in exams and in code alike: check the units and the sanity of the answer before trusting it. The distance can never exceed the sum of the two gaps (the Manhattan figure) nor be less than the larger single gap, and it must carry the same unit as the coordinates — metres in, metres out. A result outside those bounds means a sign, a square or a square root went missing, and the two bounds take five seconds to verify. Programmers meet the same check as an assertion; students should treat it as the last line of every solution.
Frequently asked questions
What is the distance formula?
In two dimensions, d = sqrt((x2 - x1)^2 + (y2 - y1)^2): subtract the coordinates, square both differences, add, and take the square root. It is Pythagoras' theorem wearing coordinate clothes — the straight line between the points is the hypotenuse of a right triangle whose legs are the horizontal and vertical gaps. Between (0, 0) and (3, 4): the gaps are 3 and 4, so d = sqrt(9 + 16) = sqrt(25) = 5. In three dimensions a third squared term joins: sqrt(dx^2 + dy^2 + dz^2).
How do you find the midpoint between two points?
Average the coordinates: midpoint = ((x1 + x2)/2, (y1 + y2)/2), with a third average for z in 3D. Between (2, 4) and (6, 10) the midpoint is (4, 7) — exactly halfway along the segment, the same distance from each end. The midpoint formula is the one to reach for in geometry proofs (it anchors medians and perpendicular bisectors) and in practical work from centering a design element to averaging two GPS readings.
Does the order of the points matter?
No. The differences are squared, so (x1 - x2) and (x2 - x1) give the same result — distance is symmetric and always positive (or zero, when the two points are the same point). The midpoint is symmetric too. Order only starts to matter when you want direction as well as distance: a displacement or a vector, where the sign of each difference tells you which way you travelled. Distance alone deliberately throws direction away.
What is Manhattan distance, and when is it the right one?
Manhattan distance adds the absolute gaps instead of combining them with Pythagoras: |x2 - x1| + |y2 - y1|. It is named for a grid of city blocks, where you cannot cut diagonally through buildings. Between (0, 0) and (3, 4) it is 7, against the Euclidean 5. Use it whenever movement is constrained to a grid — city driving, warehouse robots, board games with orthogonal moves, and some machine-learning measures. Use Euclidean whenever the straight line is genuinely available: geometry, physics, graphics and open ground.
Can I use this for distances on a map?
Only approximately, and only over short spans. Latitude and longitude are angles on a sphere, not x and y on a plane: a degree of longitude shrinks from about 111 km at the equator toward zero at the poles, so plugging raw coordinates into the flat formula distorts east-west distances badly away from the equator. Real map distances need the haversine formula or a proper map projection. For classroom coordinates, screen pixels, game worlds and workshop measurements — anywhere the plane really is flat — the formula here is exact.
Related tools
Figures checked on 24 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.