Distance Calculator
Find the straight-line distance between two points in 2D or 3D space.
Calculator verified • Last updated: August 2026
Point 1
Point 2
—
Point 1
Point 2
—
The Distance Formula, Explained
The distance formula finds the straight-line (Euclidean) distance between two points. It's a direct application of the Pythagorean theorem: the difference between the two points' coordinates on each axis forms the legs of a right triangle, and the distance itself is the hypotenuse.
In two dimensions, given points (x1, y1) and (x2, y2):
d: the straight-line distance between the two points.
x1, y1: the coordinates of the first point.
x2, y2: the coordinates of the second point.
Extending to Three Dimensions
Adding a third axis (z) extends the same idea one more dimension — a second right triangle forms between the flat 2D distance and the height difference, and the Pythagorean theorem applies again:
z1, z2: the coordinates of each point along the third axis.
The pattern generalizes further still — n-dimensional Euclidean distance simply sums the squared difference across every axis before taking the square root, though beyond three dimensions it stops being something you can literally draw.
Worked Example
For Point 1 at (1, 2) and Point 2 at (4, 6) in 2D: the difference in x is 4 minus 1, or 3; the difference in y is 6 minus 2, or 4. Squaring and adding gives 9 plus 16, or 25, and the square root of 25 is 5 — so the two points are exactly 5 units apart. This is the well-known 3-4-5 right triangle in disguise.
Where the Distance Formula Comes From
The distance formula isn't a separate rule to memorize — it's the Pythagorean theorem, , rearranged. Draw a horizontal line from Point 1 and a vertical line down from Point 2 (or vice versa); the two lines meet at a right angle, and the segment connecting the original two points is the hypotenuse of that right triangle. The legs have lengths equal to the coordinate differences, so their squares summed and square-rooted give exactly the hypotenuse, which is the distance. This connection dates back to ancient Greek geometry, though its coordinate-based (x, y) form was formalized much later, growing out of René Descartes's 17th-century development of coordinate geometry.
Common Distance Formula Mistakes
Subtracting the coordinates in the wrong order is a frequent slip — but since each difference gets squared, a negative sign disappears anyway and the final distance comes out the same regardless of order, so this particular mistake is harmless in practice. A more consequential error is forgetting to square the differences before adding them (adding the raw differences instead), which produces a completely wrong number. Mixing up which coordinate belongs to which axis when a problem lists three or four numbers per point (common once z is added) is another easy way to get a wrong answer from otherwise-correct arithmetic.
Distance Formula Terms You Should Know
Euclidean Distance — the straight-line distance between two points, the type this calculator computes.
Coordinate — a number that specifies a point's position along one axis.
Hypotenuse — the longest side of a right triangle, opposite the right angle; the distance formula computes exactly this.
Pythagorean Theorem — the rule that in a right triangle, the square of the hypotenuse equals the sum of the squares of the other two sides.
Frequently Asked Questions
What is the distance formula?
The distance formula finds the straight-line distance between two points. In 2D it is d = sqrt((x2-x1)^2 + (y2-y1)^2); in 3D it adds a z term: d = sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2). Both come directly from the Pythagorean theorem applied across each axis.
Can the distance formula give a negative result?
No. Distance is always zero or positive because it comes from a square root of a sum of squares, which can never be negative. A result of zero simply means both points are the same location.
Does the order of the two points matter?
No. Swapping Point 1 and Point 2 gives the same distance, since each difference is squared before being added, which erases the sign either order would produce.