Skip to main content
ponderloop

Distance and Midpoint Calculator

The distance between (1, 2) and (6, 7) is 5√2 ≈ 7.0711: d = √((x₂ − x₁)² + (y₂ − y₁)²) = √(5² + 5²) = √50 = 5√2. The midpoint is the average of each coordinate, (7/2, 9/2), and the slope of the line through the points is 1, so the line is y = x + 1. In three dimensions add (z₂ − z₁)² under the root: from (1, 2, 3) to (6, 7, 5) the distance is 3√6 ≈ 7.3485. Type whole numbers, fractions or decimals; the radical, the fractions and the working are exact, and only the decimal is rounded.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Point A
Point B

Type whole numbers, negatives, fractions like 1/2 or decimals like 0.75. Results stay exact.

Need the slope as a percent, an angle or a roof pitch? Try the slope calculator.

From (1, 2) to (6, 7)

5√2 ≈ 7.0711

Midpoint (7/2, 9/2), slope 1.

Distance (exact)
5√2
Distance (decimal)
≈ 7.0711
Distance squared
50
Midpoint
(7/2, 9/2)
Midpoint (decimal)
(3.5, 4.5)
Slope
1
Line equation
y = x + 1
Standard form
x − y = −1

Plot of the two points

Points A (1, 2) and B (6, 7) with the segment between themA segment from A (1, 2) to B (6, 7) of length 5√2 ≈ 7.0711, with its midpoint M (7/2, 9/2). Dashed lines show the horizontal and vertical differences.024682468xyABM

A is the circle, B the square and M the midpoint diamond. Both axes use the same scale, so the solid segment is drawn to length; the dashed legs are the horizontal and vertical differences in the formula.

The working, step by step

  1. Find the difference in each coordinate: Δx = x₂ − x₁ = 6 − 1 = 5; Δy = y₂ − y₁ = 7 − 2 = 5.
  2. The distance formula is d = √((x₂ − x₁)² + (y₂ − y₁)²) = √(5² + 5²).
  3. Square and add: 5² = 25, 5² = 25, so d² = 25 + 25 = 50.
  4. Take the largest square out of 50: 50 = 25 × 2, and √25 = 5, so √50 = 5√2.
  5. So d = 5√2, which is about 7.0711 to 4 decimal places.
  6. The midpoint formula averages each coordinate: M = ((x₁ + x₂)/2, (y₁ + y₂)/2) = ((1 + 6)/2, (2 + 7)/2) = (7/2, 9/2).
  7. The slope is rise over run: m = (y₂ − y₁)/(x₂ − x₁) = 5/5 = 1.
  8. The y-intercept comes from y = mx + b at the first point: b = y₁ − m × x₁ = 2 − 1 × 1 = 1, so y = x + 1.
  9. With whole-number coefficients (Ax + By = C): x − y = −1.

Worked examples

Each distance is simplified to a radical and rounded to four decimal places; type any pair of points to see the steps.
PointsDistanceMidpoint
(0, 0) to (3, 4)5(3/2, 2)
(1, 2) to (6, 7)5√2 ≈ 7.0711(7/2, 9/2)
(−2, 3) to (4, −1)2√13 ≈ 7.2111(1, 1)
(1/2, −3) to (7/3, 1/2)√562/6 ≈ 3.9511(17/12, −5/4)
(2, 1) to (2, 9)8(2, 5)
(0, 0, 0) to (1, 2, 2)3(1/2, 1, 1)
(1, 2, 3) to (6, 7, 5)3√6 ≈ 7.3485(7/2, 9/2, 4)
(−1, 4, 0) to (3, −2, 5)√77 ≈ 8.7750(1, 1, 5/2)

Whole-number distances from the origin

Points whose squared distance from (0, 0) is a perfect square, the Pythagorean triples, so the distance has no radical.
PointSquared distanceDistance
(3, 4)255
(5, 12)16913
(8, 15)28917
(7, 24)62525
(20, 21)84129
(9, 40)168141

Simplifying square roots

Pull the largest perfect square out of the number under the root: √50 = √(25 × 2) = 5√2.
RootSimplifiedDecimal
√82√2≈ 2.8284
√122√3≈ 3.4641
√183√2≈ 4.2426
√202√5≈ 4.4721
√273√3≈ 5.1962
√324√2≈ 5.6569
√453√5≈ 6.7082
√505√2≈ 7.0711
√726√2≈ 8.4853
√755√3≈ 8.6603
√987√2≈ 9.8995
√20010√2≈ 14.1421

How to find the distance and midpoint between two points

  1. Subtract the coordinates. Find the difference in each coordinate, second point minus first: for (1, 2) and (6, 7), Δx = 6 − 1 = 5 and Δy = 7 − 2 = 5. The order does not matter for distance, because the differences are squared.
  2. Square the differences and add them. d² = (x₂ − x₁)² + (y₂ − y₁)² = 5² + 5² = 25 + 25 = 50. For three dimensions add (z₂ − z₁)².
  3. Take the square root and simplify. d = √50. Take out the largest perfect square, 50 = 25 × 2, so d = 5√2, which is ≈ 7.0711 as a decimal.
  4. Average the coordinates for the midpoint. M = ((x₁ + x₂)/2, (y₁ + y₂)/2) = ((1 + 6)/2, (2 + 7)/2) = (7/2, 9/2). Keep it as a fraction for an exact answer.
  5. Divide the rise by the run for the slope. m = (y₂ − y₁)/(x₂ − x₁) = 5/5 = 1. Then b = y₁ − m × x₁ gives the line y = x + 1.

Frequently asked questions

What is the distance formula?
The distance between (x₁, y₁) and (x₂, y₂) is d = √((x₂ − x₁)² + (y₂ − y₁)²). It is the Pythagorean theorem: the two differences are the legs of a right triangle and d is the hypotenuse. For (0, 0) and (3, 4) it gives √(9 + 16) = √25 = 5. In 3D add (z₂ − z₁)² inside the root.
What is the midpoint formula?
The midpoint of two points is the average of each coordinate: M = ((x₁ + x₂)/2, (y₁ + y₂)/2), and in 3D also (z₁ + z₂)/2. The midpoint of (1, 2) and (6, 7) is (7/2, 9/2), which is (3.5, 4.5) as decimals. The calculator keeps fractions, so nothing is rounded.
How do you write a distance as a simplified radical?
Find the squared distance, then take out the largest perfect-square factor. For (1, 2) and (6, 7), d² = 50 = 25 × 2, so d = √50 = 5√2, about 7.0711. If the squared distance is a perfect square, as for (0, 0) and (3, 4), the distance is a whole number and there is no radical. For a fraction, √(p/q) = √(pq)/q, then simplify: the points (1/2, −3) and (7/3, 1/2) are √562/6 ≈ 3.9511 apart.
How do you find the distance between two points in 3D?
Add the squared difference of the z coordinates to the formula: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). From (1, 2, 3) to (6, 7, 5), d² = 25 + 25 + 4 = 54 = 9 × 6, so d = 3√6 ≈ 7.3485. Choose 3D in the calculator to enter the z coordinates; slope and line equation are shown for 2D only.
How do you find the slope between two points?
Divide the rise by the run: m = (y₂ − y₁)/(x₂ − x₁). For (1, 2) and (6, 7) that is 5/5 = 1. The line through the points is then y = mx + b with b = y₁ − m × x₁, here y = x + 1. For the slope as a percent grade, an angle in degrees or a roof pitch, use the slope calculator.
What if the two points share an x or a y?
Then the line is vertical or horizontal. If x₁ = x₂ the run is 0, the slope is undefined and the line is x = 2 (the points (2, 1) and (2, 9) are 8 apart). If y₁ = y₂ the slope is 0 and the line is y = 5, a distance of 7.
Does the order of the points matter?
No. Swapping the points flips the sign of each difference, and squaring removes the sign, so the distance, the midpoint and the slope are the same. (−2, 3) to (4, −1) and (4, −1) to (−2, 3) are both 2√13 ≈ 7.2111 apart.
What if both points are the same?
The distance is 0 and the midpoint is the point itself, (2, 2). Two identical points do not determine a line, so the calculator says the slope is undefined.
Can I use fractions and decimals?
Yes. Type 1/2, a mixed number such as 2 1/4 or a decimal such as 0.75, with an optional minus sign. Every value is read as an exact fraction, so the radical, the midpoint and the line equation are exact and only the decimal of the distance is rounded, to four places.

How it works

Each coordinate you type is read as an exact fraction of two whole numbers (up to 30 digits each). The squared distance is the sum of the squared coordinate differences, kept as a fraction p/q. The distance is √(p/q) = √(pq)/q; the calculator divides pq by 2, 3, 4 and so on to pull out the largest perfect square, k², leaving k√m/q, which it reduces to lowest terms. When pq is too large to be sure of every square factor the radical is shown as found and the working says so. The decimal is the square root computed with integer arithmetic and rounded half up to four places (more for a very small distance), so it never drifts the way a floating-point square root can. The midpoint is the average of each coordinate pair. For two dimensions the slope is the rise over the run, the intercept is b = y₁ − m × x₁, and the standard form Ax + By = C multiplies through to whole-number coefficients with no common factor. The plot uses the same scale on both axes, so the drawn segment has the true length. Everything runs in your browser and nothing you type is sent anywhere.

Sources

More: Geometry and measurementAll math & numbersAll toolsHome & DIY calculators