📐 Distance Between Two Points Calculator
By ToolNimba Math Team · Updated 2026-06-19
Enter the coordinates of two points to find the straight-line distance and the midpoint between them.
The distance between two points is the length of the straight line that joins them. Enter the coordinates of point A (x1, y1) and point B (x2, y2) and this calculator returns the exact distance using the distance formula, plus the midpoint that sits halfway between them. Each calculation is shown step by step, so you can check the working as well as the answer, which makes it handy for homework, geometry, drafting and quick coordinate checks.
What is the Distance Calculator?
The distance formula is the Pythagorean theorem written for coordinates. If you draw the horizontal gap (x2 − x1) and the vertical gap (y2 − y1) between two points, they form the two legs of a right triangle, and the straight line joining the points is the hypotenuse. The theorem says the hypotenuse squared equals the sum of the squares of the legs, so the distance d satisfies d² = (x2 − x1)² + (y2 − y1)², and taking the square root gives d = √((x2 − x1)² + (y2 − y1)²).
This is the Euclidean distance, the ordinary notion of how far apart two locations are on a flat plane. Because every difference is squared before being added, the result is always zero or positive, and the order of the points does not matter: the distance from A to B equals the distance from B to A. Negative coordinates are fine, since squaring removes the sign. The same idea extends to three dimensions by adding a (z2 − z1)² term, but this calculator works in the two-dimensional plane.
The midpoint is a separate but related result: it is the point exactly halfway along the segment, found by averaging the two x values and the two y values, M = ((x1 + x2) / 2, (y1 + y2) / 2). The midpoint always lies on the line between the two points and is equidistant from each of them, which is why it shows up in geometry, computer graphics and mapping whenever you need a centre point.
When to use it
- Checking geometry and coordinate homework where you need both the distance and the midpoint of a segment.
- Finding how far apart two pixels or screen positions are when laying out a game or graphic.
- Measuring the straight-line gap between two plotted points on a chart or grid.
- Locating the centre point between two coordinates, for example to place a label or a marker halfway along a line.
How to use the Distance Calculator
- Enter the x and y coordinates of the first point, point A (x1, y1).
- Enter the x and y coordinates of the second point, point B (x2, y2).
- Read off the distance and the midpoint, which update as you type.
- Open the step-by-step panel to see each part of the calculation, or use a sample button to load an example.
Formula & method
Worked examples
Find the distance and midpoint between A(1, 2) and B(4, 6).
- Δx = x2 − x1 = 4 − 1 = 3
- Δy = y2 − y1 = 6 − 2 = 4
- Δx² + Δy² = 3² + 4² = 9 + 16 = 25
- d = √25 = 5
- Midpoint = ((1 + 4) / 2, (2 + 6) / 2) = (2.5, 4)
Result: Distance = 5 units, midpoint = (2.5, 4).
Find the distance and midpoint between A(-2, 3) and B(3, -9).
- Δx = x2 − x1 = 3 − (−2) = 5
- Δy = y2 − y1 = −9 − 3 = −12
- Δx² + Δy² = 5² + (−12)² = 25 + 144 = 169
- d = √169 = 13
- Midpoint = ((−2 + 3) / 2, (3 + (−9)) / 2) = (0.5, −3)
Result: Distance = 13 units, midpoint = (0.5, -3).
Worked distances and midpoints for common point pairs
| Point A | Point B | Distance | Midpoint |
|---|---|---|---|
| (0, 0) | (3, 4) | 5 | (1.5, 2) |
| (1, 2) | (4, 6) | 5 | (2.5, 4) |
| (0, 0) | (5, 5) | 7.071068 | (2.5, 2.5) |
| (-2, 3) | (3, -9) | 13 | (0.5, -3) |
| (2, 2) | (2, 9) | 7 | (2, 5.5) |
Some Pythagorean point pairs that give whole-number distances
| Horizontal gap Δx | Vertical gap Δy | Distance d |
|---|---|---|
| 3 | 4 | 5 |
| 6 | 8 | 10 |
| 5 | 12 | 13 |
| 8 | 15 | 17 |
| 7 | 24 | 25 |
Common mistakes to avoid
- Forgetting to square the differences. The distance is not (x2 − x1) + (y2 − y1). You must square each difference, add them, then take the square root. Adding the raw gaps gives the wrong, larger answer except in trivial cases.
- Mishandling negative coordinates. Subtracting a negative coordinate flips the sign, so x2 − x1 with x1 = −2 becomes x2 + 2. Because the result is squared anyway, the sign of the gap does not change the distance, but getting the subtraction wrong does.
- Mixing up the distance and the midpoint formulas. Distance squares and roots the differences, while the midpoint just averages the coordinates. Do not square anything when finding the midpoint, simply add the pair and divide by two.
- Taking the square root of each term separately. You cannot write d as √(Δx²) + √(Δy²), which would just give |Δx| + |Δy|. The square root applies to the whole sum, after the squared terms are added together.
Glossary
- Coordinate
- A pair of numbers (x, y) that fixes the position of a point on the plane.
- Euclidean distance
- The ordinary straight-line distance between two points, the length of the segment joining them.
- Distance formula
- d = √((x2 − x1)² + (y2 − y1)²), the Pythagorean theorem applied to coordinates.
- Midpoint
- The point exactly halfway between two points, found by averaging their x values and their y values.
- Pythagorean theorem
- For 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 between two points (x1, y1) and (x2, y2) is d = √((x2 − x1)² + (y2 − y1)²). It comes straight from the Pythagorean theorem: the horizontal and vertical gaps are the legs of a right triangle and the distance is the hypotenuse.
How do I find the distance between two points?
Subtract the x values to get the horizontal gap and the y values to get the vertical gap, square each gap, add them, then take the square root. For example, from (1, 2) to (4, 6) the gaps are 3 and 4, so d = √(9 + 16) = √25 = 5.
Does the order of the points matter?
No. Because each difference is squared, swapping the points only changes the sign of the gaps, which disappears when you square them. The distance from A to B is always the same as the distance from B to A.
How is the midpoint calculated?
The midpoint is M = ((x1 + x2) / 2, (y1 + y2) / 2). You average the two x coordinates and the two y coordinates. The result is the point exactly halfway along the segment and the same distance from each end.
Can I use negative coordinates?
Yes. Negative coordinates work fine. Just be careful with the subtraction, since subtracting a negative number adds it. The squaring step means the sign of each gap never affects the final distance.
Does this calculator work in three dimensions?
This tool covers the two-dimensional plane with x and y. In three dimensions you add a (z2 − z1)² term inside the square root, giving d = √((x2 − x1)² + (y2 − y1)² + (z2 − z1)²), but the idea is the same.