Distance and Midpoint Calculator
Find the distance between two points with the distance formula, as an exact square root (√50 = 5√2) and a decimal, plus the midpoint, slope and a picture. Advanced adds 3D points, a missing coordinate, the other endpoint, a point that splits the segment in a ratio, line equations and the distance from a point to a line.
A number, a fraction or a root: 13, 2.5, 3/4, √50 or 5√2.
Any form: 3x + 4y − 10 = 0, y = 2x + 1, 2x − y = 4 or x = 3.
Whole numbers, decimals and fractions all work: 3, −2.5, 3/4 or 1 1/2.
Changing the unit converts the numbers above. The distance gets the unit too.
How your distance is worked out
Your points: the gaps, squared, added, then the square root.
- 1
Find the gaps
x: 6 − 1 = 5y: 7 − 2 = 5
- 2
Square them
5² = 255² = 25add: 50
- 3
Take the root
√50= 5√2≈ 7.0711
- 4
Midpoint
add, then halve(3.5, 4.5)
Read more: the formulas, worked examples and simplifying roots
The distance formula gives the straight-line length between two points on a grid. It is Pythagoras’ theorem in disguise: the gap across (in x) and the gap up (in y) are the two short sides of a right triangle, and the distance is the long side. The midpoint is the point exactly halfway between them.
The formula
Distance d = √((x₂ − x₁)² + (y₂ − y₁)²)
In 3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
Slope = (y₂ − y₁) ÷ (x₂ − x₁)
Missing coordinate: x₂ = x₁ ± √(d² − (y₂ − y₁)²)
Other endpoint: x₂ = 2 × midpoint x − x₁ (same for y and z)
Point dividing in m : n: inside ((m·x₂ + n·x₁) ÷ (m + n), …), outside ((m·x₂ − n·x₁) ÷ (m − n), …)
Manhattan = |x₂ − x₁| + |y₂ − y₁| · Chebyshev = the bigger of |x₂ − x₁| and |y₂ − y₁|
Point (p, q) to the line ax + by + c = 0: |a·p + b·q + c| ÷ √(a² + b²)
Worked example
For the default points (1, 2) and (6, 7): the gap in x is 6 − 1 = 5 and the gap in y is 7 − 2 = 5. Squared, they are 25 and 25, and 25 + 25 = 50. The distance is √50. Because 50 = 25 × 2 and √25 = 5, √50 = 5√2 ≈ 7.0711. The midpoint is ((1 + 6) ÷ 2, (2 + 7) ÷ 2) = (3.5, 4.5), and the slope is 5 ÷ 5 = 1, so the line is y = x + 1.
Advanced extras for the same points: the Manhattan distance is 5 + 5 = 10 and the Chebyshev distance is 5. The perpendicular bisector is x + y = 8 (it goes through the midpoint, since 3.5 + 4.5 = 8). The point that splits the segment 2 : 1 is ((2 × 6 + 1 × 1) ÷ 3, (2 × 7 + 1 × 2) ÷ 3) = (13/3, 16/3) ≈ (4.33, 5.33); the outside point at 2 : 1 is ((12 − 1) ÷ 1, (14 − 2) ÷ 1) = (11, 12).
3D: from (1, 2, 3) to (6, 7, 8) the gaps are 5, 5 and 5, so d = √(25 + 25 + 25) = √75 = 5√3 ≈ 8.6603, and the midpoint is (3.5, 4.5, 5.5).
Missing coordinate: point 1 is (1, 2), point 2 is (x, 7) and the distance is 13. The y gap is 5, so (x − 1)² = 13² − 5² = 169 − 25 = 144, x − 1 = ±12, and x = 13 or −11.
Other endpoint: one end is (1, 2) and the midpoint is (3.5, 4.5). The other end is (2 × 3.5 − 1, 2 × 4.5 − 2) = (6, 7).
Point to a line: from (4, 5) to 3x + 4y − 10 = 0: |3 × 4 + 4 × 5 − 10| ÷ √(3² + 4²) = 22 ÷ 5 = 4.4. The nearest point on the line is (34/25, 37/25) = (1.36, 1.48).
Simplifying square roots
| Sum of squares | Biggest square factor | Exact | Decimal |
|---|---|---|---|
| 8 | 4 | 2√2 | 2.8284 |
| 18 | 9 | 3√2 | 4.2426 |
| 20 | 4 | 2√5 | 4.4721 |
| 45 | 9 | 3√5 | 6.7082 |
| 50 | 25 | 5√2 | 7.0711 |
| 72 | 36 | 6√2 | 8.4853 |
| 75 | 25 | 5√3 | 8.6603 |
| 13 | none | √13 | 3.6056 |
Notes
- The order of the points does not matter for the distance or the midpoint, because squaring removes the sign of each gap.
- Manhattan (taxicab) distance is how far you go along a grid of streets; Chebyshev distance is the number of moves a chess king needs. Both are never more than the straight-line distance times √2 (in 2D).
- This works on a flat grid. For two places on Earth by latitude and longitude, use the great-circle distance on the flight distance calculator instead.
- Answers are exact when the inputs are exact (fractions and decimals are kept as fractions). Decimals are rounded to 4 places.
Common questions
What is the distance formula?
The distance between (x₁, y₁) and (x₂, y₂) is d = √((x₂ − x₁)² + (y₂ − y₁)²). Find the gap in x and the gap in y, square each one, add them and take the square root. It is Pythagoras’ theorem: the two gaps are the short sides of a right triangle and the distance is the long side.
How do you find the distance between (1, 2) and (6, 7)?
The gaps are 6 − 1 = 5 and 7 − 2 = 5. Squared, they are 25 and 25, which add to 50. The distance is √50. Since 50 = 25 × 2, √50 = 5√2 ≈ 7.0711.
How do you find the midpoint of two points?
Add the two x values and halve the answer, then do the same with the y values: M = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). For (1, 2) and (6, 7) that is (7 ÷ 2, 9 ÷ 2) = (3.5, 4.5).
What is the distance formula in 3D?
Add a third gap for z: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). From (1, 2, 3) to (6, 7, 8) every gap is 5, so d = √75 = 5√3 ≈ 8.6603.
Why are there two answers for a missing coordinate?
Squaring hides the sign: (x − 1)² = 16 is true for x − 1 = 4 and for x − 1 = −4. So the missing point can sit on either side, at x = 5 or x = −3. Both are the same distance away.
Related calculators
Made by Zulu Calculator, part of AlphaZulu LLC. Formulas are shown in full and rule figures are checked against official sources; see how we build calculators.