Skip to main content
CalcMax

Distance Calculator

Range: -1,000,000,000 – 1,000,000,000

Range: -1,000,000,000 – 1,000,000,000

Range: -1,000,000,000 – 1,000,000,000

Range: -1,000,000,000 – 1,000,000,000

Result

5.0000

Distance

Change in x (Δx)
3.0000
Change in y (Δy)
4.0000

A distance calculator gives you the straight-line distance between two points: the length of the segment joining them, measured as the crow flies rather than along any path you might walk. Type in the two points, four numbers in total, and the answer comes back to four decimal places. Behind it sits the distance formula, which is the Pythagorean theorem wearing coordinate clothing. Drop a horizontal line from one point and a vertical line from the other and they meet at a corner, forming a right triangle whose legs are the differences between the coordinates and whose hypotenuse is the distance you asked for. For the points (0, 0) and (3, 4) the legs are 3 and 4, so the distance is √(9 + 16), which is exactly 5. That triangle is why the page prints three numbers instead of one. The two legs come back as the horizontal and vertical distance between the points, and they are the working: the answer is the square root of the sum of their squares, and with both of them on screen you can follow the arithmetic without doing any of it yourself. They are also signed, which surprises people the first time. The vertical step is negative whenever the second point is lower than the first, because it is a directed difference rather than a gap, and the page deliberately keeps the sign instead of taking an absolute value — the sign is the only thing that tells you which way the second point lies from the first, and it is what a slope calculation would need next. Two limits are worth knowing before you rely on the answer. This page measures distances in a flat plane and only in a flat plane. There is no third coordinate box, because a page with optional z fields would have to invent an answer for the case where one point has a z and the other does not, and the two other coordinate pages in this family — the midpoint and the endpoint — would then have a different shape from this one for no reason a reader could see. If your points are in space you can still use the page twice, but you will have to add the third leg yourself. And the coordinates carry no unit. Whatever you measure in, the answer is in: metres if your numbers are metres, kilometres if they are kilometres, grid squares if they came off a graph. The page will not convert and cannot warn you that one point is in metres and the other in millimetres.

Distances between points that come up often

First xFirst ySecond xSecond yHorizontal legVertical legDistance
0034345
1258467.2111
0011111.4142
2.5-1.52.5-1.5000
-347-210-611.6619
0010010010
3400-3-45
00600000080000006000000800000010000000

Eight pairs, with two columns of working and the answer in the last one. Start with the first row, which is the input the page loads with: the legs are 3 and 4 and the distance is exactly 5, the smallest right triangle with whole-number sides. The second row is the same kind of diagonal without the exactness — legs of 4 and 6, a distance of 7.2111, and a square root that goes on forever. The third row is a diagonal of one and one, where the distance is the square root of two and prints as 1.4142, worth knowing by heart because it is the shortest irrational distance there is. The fourth row is the same point twice, a distance of zero. The fifth row is the one to study if the signs keep catching you out: the second point is far to the right and below the first, so the horizontal leg is positive ten and the vertical leg is negative six, and the distance of 11.6619 comes out positive regardless. The sixth row runs flat along the x axis, so the vertical leg is zero and the distance is simply the horizontal one. The seventh row is the three four five segment measured backwards, from (3, 4) to the origin, which turns both legs negative while leaving the distance at 5 — and the eighth is the same triangle scaled up by two million, which shows that large coordinates introduce no rounding of their own.

Formula

Distance = √((x₂ − x₁)² + (y₂ − y₁)²) Horizontal leg = x₂ − x₁ Vertical leg = y₂ − y₁

First point
An x and a y, the point you are measuring from. Its coordinates are plain numbers, so they may be negative, fractional or zero, and there is no unit to choose
Second point
The point you are measuring to, with the same rules. It may lie in any direction from the first, including directly above, below, left or right of it
Horizontal leg
The first x subtracted from the second, so it is the sideways step from one point to the other. A negative value means the second point lies to the left of the first, and it is the same number a slope calculation would use as its run
Vertical leg
The first y subtracted from the second, the upward step between the points. A negative value means the second point is lower. Together with the horizontal leg it forms a right triangle whose hypotenuse is the distance
Distance
The square root of the two legs squared and added. It is never negative, it is zero only when the two points coincide, and since it is usually a square root it is rounded to four decimal places

Use it whenever you have two points and want the gap between them without caring which way it runs. How far apart two map references are, how long a fence between two posts will be, how much cable it takes to run diagonally across a room, how far a delivery is from a depot when the route is a straight line rather than a road. It is also the check to reach for when a longer calculation has gone wrong: any two results you can place on a plane can be measured against each other, and a distance that comes out an order of magnitude off is a sign error somewhere upstream. The two legs earn their place in a different set of jobs. If you need to know how much of the gap is sideways and how much is up, they answer that directly, and they answer it with signs, so they tell you the direction as well as the size. That is exactly what you need before working out a slope, an angle or a bearing — the distance page will not give you any of those, but it hands you the two numbers they are all built from. A worked habit worth having: square the two legs in your head before reading the answer. Nine plus sixteen is twenty-five, so a distance of 5 is right, and a distance of 50 would mean a misplaced decimal point rather than a surprising result.

Worked examples

  1. Three across and four up

    1. Horizontal leg: 3 − 0 = 3
    2. Vertical leg: 4 − 0 = 4
    3. Square both: 9 and 16
    4. Add and take the square root: √25 = 5

    The pair the page loads with, and the smallest right triangle whose three sides are all whole numbers. Two things are worth noticing. The two legs are the numbers you typed, which only happens when one point is the origin, and the distance is exact rather than a rounded square root, which is rare on this page. Use this input as a calibration: if the page returns 5 here, the arithmetic is sound and any odd-looking answer elsewhere is a property of the input rather than a fault.

  2. A diagonal where the distance is a rounded square root

    1. Horizontal leg: 5 − 1 = 4
    2. Vertical leg: 8 − 2 = 6
    3. Square both: 16 and 36
    4. Add: 52, then take the square root, which is 7.21110255… and rounds to 7.2111

    The ordinary case rather than the tidy one. Fifty-two is not a perfect square, so the answer is irrational and the four printed digits are the beginning of it rather than the whole thing. A useful check that costs nothing: the distance has to be longer than either leg, so 7.2111 against legs of 4 and 6 is plausible, while a distance shorter than the longer leg would mean the square root was applied to the wrong quantity.

  3. The same two points measured the other way round

    1. Horizontal leg: 0 − 3 = −3
    2. Vertical leg: 0 − 4 = −4
    3. Square both: 9 and 16, since squaring removes the signs
    4. Add and take the square root: √25 = 5

    The three four five segment with its endpoints swapped, and the clearest demonstration of two properties at once. Both legs come back negative because both differences are now measured in the other direction, while the distance is unchanged at 5, because squaring throws the signs away before they can do any harm. That is the whole reason the distance is always positive: it is a length, and the direction it was measured in never enters the arithmetic.

  4. A distance measured in the millions

    1. Horizontal leg: 6000000 − 0 = 6000000
    2. Vertical leg: 8000000 − 0 = 8000000
    3. Square both and add: 3.6 × 10¹³ plus 6.4 × 10¹³ is 10¹⁴
    4. Take the square root: 10000000

    The three four five triangle scaled up by two million, which is what happens when the same coordinates are used for a projected map grid in metres rather than a graph on paper. Nothing on the page changes with the size of the numbers — the two legs are as exact as the inputs and the distance comes out whole — and this row is here to make that plain, since a reader who expects large coordinates to introduce rounding will otherwise suspect the exact answer.

  5. Two points that are the same point

    1. Horizontal leg: 2.5 − 2.5 = 0
    2. Vertical leg: ((−1.5) − (−1.5)) = 0
    3. Square both: 0 and 0
    4. Add and take the square root: √0 = 0

    A distance of zero is the correct answer for a point and itself, and it is the only input that can produce one, since the sum of two squares is zero only when both squares are zero. The page will not treat this as an empty result. It is worth seeing once so that a zero in the first column does not read as a field that failed to fill.

Limitations

The page measures in a plane and only in a plane. There is no box for a third coordinate, so a distance between two points in space is out of reach: you would need the difference in the third axis as well, and this page has nowhere to put it. A page with optional z fields was considered and rejected, because one point with a z and the other without it has no sensible answer and the two neighbouring coordinate pages would have had to grow the same fields to stay consistent. The coordinates are unitless, so the answer is in whatever you measured in, and the page cannot spot a mixed pair — if one point is in metres and the other in millimetres the arithmetic will run happily and return a number that is wrong, and nothing on the page will say so. The two legs are signed differences rather than distances, so a leg that prints as a negative number is correct and not an error to be fixed. The distance itself is rounded to four decimal places and is usually irrational, so the printed value is where the digits stop rather than the whole answer. Coordinates are limited to plus or minus one billion, which is far beyond any graph but well inside the range of some projected coordinate systems measured in metres, and the page will refuse those rather than compute them. Finally, this is a straight-line distance and not a route: if you have to follow roads, walls or a coastline, the number here is the shortest possible path and will always be shorter than the one you can actually travel.

Frequently asked questions

What is the distance formula?
It is the Pythagorean theorem with coordinates in it. Take the difference between the two x values and the difference between the two y values, square each, add them and take the square root. The two differences are the legs of a right triangle and the distance is its hypotenuse, so the formula is not a separate rule to memorise — it is the triangle rule applied to the steps between the points. For (0, 0) and (3, 4) that is √(9 + 16), which is 5.
Why are the two extra columns negative sometimes?
Because they are directed steps rather than gaps, and a step has a direction. The horizontal leg is the first x subtracted from the second, so it is negative exactly when the second point lies to the left of the first; the vertical leg is negative when the second point is lower. The page keeps the sign on purpose. It is the only thing that says which way the second point lies, it is what a slope or bearing calculation needs next, and the distance itself ignores the signs entirely because squaring removes them.
Does this work for points in three dimensions?
No, and the page does not pretend otherwise — there is no third coordinate box to fill in. A three-dimensional distance needs the difference in the third axis as well, added to the sum of squares before the root is taken, and with only two coordinates to work from the page would have to assume a value for the third. If your points are in space, you can compute the two-dimensional distance with this page and then combine it with the height difference yourself, but the page will not do that step for you.
Are the coordinates in metres, centimetres or something else?
Whatever you say they are. The page treats them as plain numbers, attaches no unit to the answer and offers no dropdown to pick one, which is deliberate: a coordinate pair from a graph or a map grid does not come with a unit until you decide what the grid was drawn in. If your numbers are in metres the distance is in metres, if they are in degrees of longitude the distance is in degrees, and that last one cannot be converted to kilometres without knowing where on the globe you are.
Can the distance ever be negative or zero?
It cannot be negative, because squaring the two legs removes any signs before they are added and a square root of a non-negative number is never negative. It is zero only when both legs are zero, which means the two points are the same point — a genuine answer rather than a failed calculation. Every other pair of distinct points gives a positive distance, however close together they are.
How do I check the answer without a calculator?
Square the two legs and add them, then ask what number squares to that total. Four and six give 16 plus 36, which is 52, and 7.2111 squared is close to 52 — so the answer is in the right region even though 52 is not a perfect square. Two properties make the check quick: the distance is always longer than either leg, since the hypotenuse of a right triangle is its longest side, and it is always shorter than the two legs added together. Anything outside those bounds is wrong.

References

Related calculators