Distance Calculator: Distance Between Two Points
Enter two points and get the straight-line distance between them, the midpoint, the change in x and y, and the slope, with the formula worked out.
Formulas verified against standard references. Calculator logic tested with verified worked examples. Last reviewed: October 2026. Our methodology
The Distance Formula
The distance between two points is the length of the straight line joining them, found with the distance formula: the square root of (x2 minus x1) squared plus (y2 minus y1) squared. It is Pythagoras theorem applied to the right triangle formed by the horizontal and vertical gaps between the points.
For points (0, 0) and (3, 4), the gaps are 3 and 4, so the distance is the square root of 9 plus 16, which is the square root of 25, which is 5. That 3-4-5 triangle is the classic check that the formula is working, and it appears in construction, navigation, and graphics alike.

Midpoint and Slope
The midpoint is the point exactly halfway between the two points: average the x coordinates and average the y coordinates. The midpoint of (0, 0) and (3, 4) is (1.5, 2). The slope is the change in y divided by the change in x, here 4 divided by 3, or 1.333, which means the line rises 4 units for every 3 units it runs.
A slope of zero means a horizontal line, and an undefined slope means a vertical line, where the change in x is zero and division by zero is impossible. A positive slope rises left to right, and a negative slope falls left to right. Slope and distance together describe a line segment completely.
| Quantity | Formula | Example (0,0) to (3,4) |
|---|---|---|
| Distance | sqrt(dx squared + dy squared) | 5 |
| Midpoint | ((x1+x2)/2, (y1+y2)/2) | (1.5, 2) |
| Slope | dy / dx | 1.333 |
| dx, dy | x2-x1, y2-y1 | 3, 4 |

Worked Examples
Example 1: (0, 0) to (3, 4) gives distance 5, midpoint (1.5, 2), slope 1.333. Example 2: (1, 2) to (4, 6) gives dx = 3, dy = 4, distance 5 again, midpoint (2.5, 4), slope 1.333. The same gaps always give the same distance, wherever the segment sits on the plane.
Example 3: (-2, 1) to (2, 1) is horizontal, so dy = 0, distance 4, midpoint (0, 1), slope 0. Example 4: (5, 1) to (5, 6) is vertical, so dx = 0, distance 5, midpoint (5, 3.5), slope undefined. Negative coordinates work exactly the same way, because squaring removes the sign.
| Points | Distance | Midpoint |
|---|---|---|
| (0,0) to (3,4) | 5 | (1.5, 2) |
| (1,2) to (4,6) | 5 | (2.5, 4) |
| (-2,1) to (2,1) | 4 | (0, 1) |
| (5,1) to (5,6) | 5 | (5, 3.5) |
Distance in the Real World
On a map, the distance formula gives the straight-line, as-the-crow-flies distance between two coordinates, not the road distance, which follows streets and bends. For GPS work, the same idea extends to three dimensions by adding a z gap squared inside the square root, and to the Earth's surface with a more complex great-circle formula for long distances.
In design and construction, the distance formula checks diagonals: a rectangular frame 3 units by 4 units must have a diagonal of 5 units to be truly square, which is the 3-4-5 rule builders use on site. In games and graphics, distance decides collisions, ranges, and camera placement.
Common Mistakes
The most common mistake is forgetting the square root at the end and reporting dx squared plus dy squared instead of its root. For (0, 0) to (3, 4), that mistake gives 25 instead of 5. A second mistake is mixing up the order of subtraction, though squaring makes the order harmless for distance, it matters for slope sign.
A third mistake is using the distance formula on coordinates in different units, such as degrees and meters, without converting first. A fourth is treating a vertical line's slope as zero: it is undefined, not zero, because dividing by a zero change in x has no answer.
Checking Your Answer
A distance can never be negative, and it can never exceed the sum of the absolute gaps, |dx| plus |dy|. For (0, 0) to (3, 4), the distance 5 sits between the larger gap, 4, and the sum, 7, which is a quick sanity check. If the points are identical, the distance is zero, and the midpoint is the point itself.
Plot the points when an answer looks wrong. The segment, its horizontal gap, and its vertical gap form a right triangle, and the distance is its hypotenuse, always the longest side. If a reported distance is shorter than either gap, it is certainly wrong.

Frequently asked questions
What is the distance between (0, 0) and (3, 4)?
5. The gaps are 3 and 4, so the distance is the square root of 9 plus 16, which is the square root of 25, which is 5.
What is the distance formula?
The square root of (x2 minus x1) squared plus (y2 minus y1) squared. It is Pythagoras theorem applied to the gaps between the points.
How do you find the midpoint?
Average the x coordinates and average the y coordinates: ((x1 + x2) / 2, (y1 + y2) / 2). The midpoint of (0, 0) and (3, 4) is (1.5, 2).
What is the slope between two points?
Change in y divided by change in x: (y2 minus y1) / (x2 minus x1). For (0, 0) to (3, 4), the slope is 4 / 3, or 1.333.
What does an undefined slope mean?
The line is vertical. The change in x is zero, and dividing by zero has no answer, so the slope is undefined, not zero.
Can distance ever be negative?
No. Distance is a length, so it is zero or positive. The squares in the formula remove any negative sign from the gaps.
Is this the same as road distance?
No. This is the straight-line distance. Road distance follows streets and is almost always longer.