Distance and Midpoint Calculator
Distance (d):
Midpoint (M):
Distance squared (d²):
Exact distance:
Differences (Δx, Δy):
Calculation:
This calculator finds the distance between two points and their midpoint, in the plane or in space. Type the coordinates, or drag the points on the graph, and you will see the segment, the right triangle made by the coordinate differences and the midpoint marked. Every step with your numbers is shown below.
Further down you will find the formulas, worked examples, a table of exact distances and the most common questions.
How to use the distance and midpoint calculator?
Step 1: Choose In the plane (2D) if your points have two coordinates, or In space (3D) if they have three.
Step 2: Type the coordinates of A and B. A decimal point or comma both work, for example 2.5 or 2,5, and negative numbers are fine. In 2D you can also drag A and B on the graph.
Step 3: Press Calculate or the Enter key. The results also update as you type.
Step 4: Read the distance, the midpoint and the differences. With whole-number coordinates you also get the exact distance with a root, such as 2√13. The Calculation box shows every operation.
Distance formula between two points
The distance is the length of the segment joining A (x1, y1) and B (x2, y2). It comes from the Pythagorean theorem: the coordinate differences are the legs of a right triangle and the segment is the hypotenuse.
| d = √[(x2 - x1)² + (y2 - y1)²] |
In space you add a third difference:
| d = √[(x2 - x1)² + (y2 - y1)² + (z2 - z1)²] |
The differences are squared, so the order of the points does not matter: the distance from A to B equals the distance from B to A, and it is never negative.
Midpoint formula
The midpoint M sits exactly halfway along the segment. Its coordinates are the average of the coordinates of the two endpoints:
| M = ((x1 + x2) ÷ 2, (y1 + y2) ÷ 2) |
If you know the midpoint M and one endpoint A, the other endpoint is B = (2xM - xA, 2yM - yA).
Examples of distance and midpoint
Example 1: Points (1, 2) and (7, 10)
d = √[(7 - 1)² + (10 - 2)²] = √[6² + 8²] = √[36 + 64]
d = √100 = 10
M = ((1 + 7) ÷ 2, (2 + 10) ÷ 2) = (4, 6)
The distance is a whole number: 10. The differences 6 and 8 are a multiple of the 3, 4, 5 triple.
Example 2: Points (-2, 1) and (4, 5), with a root
d = √[(4 - (-2))² + (5 - 1)²] = √[6² + 4²] = √[36 + 16]
d = √52 = 2√13 ≈ 7.211
M = (((-2) + 4) ÷ 2, (1 + 5) ÷ 2) = (1, 3)
Since 52 = 4 × 13, the root simplifies to 2√13. That is the exact distance, and 7.211 is its approximate value.
Example 3: Points with decimals
The points (-3.5, 2) and (6, -1.5) have decimal coordinates, so there is no exact form with a whole-number root:
d = √[(6 - (-3.5))² + ((-1.5) - 2)²] = √[9.5² + (-3.5)²] = √[90.25 + 12.25]
d = √102.5 ≈ 10.12
M = (((-3.5) + 6) ÷ 2, (2 + (-1.5)) ÷ 2) = (1.25, 0.25)
Example 4: Distance in 3D
Between A(1, 2, 3) and B(4, 6, 15) the differences are 3, 4 and 12:
d = √[(4 - 1)² + (6 - 2)² + (15 - 3)²] = √[3² + 4² + 12²] = √[9 + 16 + 144]
d = √169 = 13
M = ((1 + 4) ÷ 2, (2 + 6) ÷ 2, (3 + 15) ÷ 2) = (2.5, 4, 9)
The distance is exactly 13, because 3, 4 and 12 make a triple that gives an exact root in space.
Table of exact distances in 2D and 3D
These differences give a whole-number distance. They are handy for building problems whose answer needs no root.
| Δx | Δy | Distance |
|---|---|---|
| 3 | 4 | 5 |
| 5 | 12 | 13 |
| 8 | 15 | 17 |
| 7 | 24 | 25 |
| 20 | 21 | 29 |
| 9 | 40 | 41 |
| Δx | Δy | Δz | Distance |
|---|---|---|---|
| 1 | 2 | 2 | 3 |
| 2 | 3 | 6 | 7 |
| 4 | 4 | 7 | 9 |
| 1 | 4 | 8 | 9 |
| 2 | 6 | 9 | 11 |
Frequently asked questions
How do you find the distance between two points?
Subtract the coordinates, square each difference, add the squares and take the square root. For (0, 0) and (3, 4): d = √(3² + 4²) = √25 = 5.
How do you find the midpoint of a segment?
Average the coordinates separately. For (0, 0) and (6, 8) the midpoint is ((0 + 6) ÷ 2, (0 + 8) ÷ 2) = (3, 4), and the full distance is 10.
How do you find the distance in 3D?
It is the same formula with a third difference, the one for the z coordinates. Between (0, 0, 0) and (1, 1, 1) it is √(1 + 1 + 1) = √3 ≈ 1.732, the diagonal of a cube with side 1.
Does the order of the points matter?
No. The differences are squared, so the sign disappears. The distance from A to B equals the distance from B to A, and the midpoint is the same too.
How do I find an endpoint if I know the midpoint?
Double the midpoint and subtract the endpoint you already have. If M = (1, 3) and A = (-2, 1), then B = (2 × 1 - (-2), 2 × 3 - 1) = (4, 5).
Learn more
- Distance between two points: formula and examples
- Midpoint formula and examples
- Examples of distance between two points on the coordinate plane
- How to find the midpoint of a line segment
Related calculators
You can explore other calculators here.