Square the gap on each axis, add them, take the root. From (0,0) to (3,4): 3² + 4² = 25, and √25 = 5. The order of the two points does not matter, because squaring removes the sign — which is exactly why the formula has no direction in it.
It is just Pythagoras
The distance formula is not a separate thing to learn. Draw the horizontal and vertical gaps between two points and they are the two legs of a right triangle; the distance is the hypotenuse.
So √((x₂−x₁)² + (y₂−y₁)²) is √(a² + b²) with a and b named after where they came from.
Seeing it that way makes two things obvious. The order of the points is irrelevant, because swapping them negates both legs and squaring undoes that. And the answer is never negative, because a hypotenuse is a length.
Three dimensions
A third squared term simply joins the sum: d = √((Δx)² + (Δy)² + (Δz)²).
The reason is Pythagoras applied twice. The horizontal gap across the floor is √(Δx² + Δy²), and that horizontal distance and the vertical rise form a second right triangle whose hypotenuse is the answer. Squaring the first root cancels it, and the three terms end up in one sum.
It keeps extending. In any number of dimensions the distance is the root of the sum of the squared differences — which is why the same formula turns up as the magnitude of a vector and the Euclidean norm in data work, with no visible triangle anywhere.
Manhattan and the other distances
Straight-line distance is one answer to “how far apart”. It is not always the useful one.
Manhattan distance adds the gaps instead of squaring them: |Δx| + |Δy|. It is the route along a grid rather than across it — what a taxi drives in a city laid out in blocks, and what an L1 norm measures. It is never shorter than the straight line, and often considerably longer.
Chebyshev distance takes the largest single gap. It is how far a chess king walks, since a diagonal step covers both axes at once.
The page reports all three, because which one is right depends on what can actually move and how.
Why the squared value is worth having
The squared distance is exact and the distance usually is not, and there are times when that matters.
Comparing. To find which of several points is nearest, comparing squared distances gives the same ordering and skips every square root. Nearest-neighbour code does this routinely.
Exactness. Two points at √2 apart have a squared distance of exactly 2. The decimal 1.4142135624 is not the distance, and a chain of calculations built on it accumulates error that the exact form does not.
Checking for a right angle. Three points form a right triangle exactly when one squared distance equals the sum of the other two — a test in whole numbers, with no roots involved.
Where it gets used
Plans and maps. The straight-line gap between two surveyed points, or between two pixels on a scaled drawing.
Graphics and games. Collision checks, view distances, nearest-object lookups. Almost always done on the SQUARED distance, for the reason above.
Data work. Euclidean distance between two rows of numbers is the same formula in as many dimensions as there are columns, and it is the default measure behind k-means and nearest-neighbour methods.
Geometry problems. Proving a shape is a rhombus, an isosceles triangle or a square usually reduces to computing a few distances and comparing them.
Where it does not apply
On a sphere. The Earth is not flat, and the straight-line distance between two cities passes through the ground. Great-circle distance uses spherical trigonometry instead, and over long distances the two answers differ substantially.
When movement is constrained. A straight line is only the distance if you can travel it. In a building, a city grid or a maze, the route matters more than the gap.
When the axes are not comparable. Distance between (age, salary) points treats a year and a pound as the same size, which they are not. Data has to be scaled before Euclidean distance means anything.
Sources and methodology
The formula is Pythagoras in coordinates; these are the references.
Method. The coordinate gaps and the sum of their squares are carried as exact rationals, so a coordinate of 1/3 contributes exactly a ninth and the squared distance is reported without rounding. Only the final square root is taken in double precision, and the page says which of the two numbers is which. Whether the root is a whole number is tested against the exact squared value rather than by looking at the decimal. That engine is verified on every change against 67 hand-written assertions, including agreement with a direct hypotenuse computation across four thousand generated pairs, and that the reported distance squared always reproduces the exact squared value. The count and the per-case breakdown are published on the formula verification page.
Read the guide
The midpoint of the same two points needs no square root at all — the Midpoint Calculator gives it exactly — and the Slope Calculator turns the same two gaps into a gradient.