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
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
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
- Find the difference in each coordinate: Δx = x₂ − x₁ = 6 − 1 = 5; Δy = y₂ − y₁ = 7 − 2 = 5.
- The distance formula is d = √((x₂ − x₁)² + (y₂ − y₁)²) = √(5² + 5²).
- Square and add: 5² = 25, 5² = 25, so d² = 25 + 25 = 50.
- Take the largest square out of 50: 50 = 25 × 2, and √25 = 5, so √50 = 5√2.
- So d = 5√2, which is about 7.0711 to 4 decimal places.
- The midpoint formula averages each coordinate: M = ((x₁ + x₂)/2, (y₁ + y₂)/2) = ((1 + 6)/2, (2 + 7)/2) = (7/2, 9/2).
- The slope is rise over run: m = (y₂ − y₁)/(x₂ − x₁) = 5/5 = 1.
- The y-intercept comes from y = mx + b at the first point: b = y₁ − m × x₁ = 2 − 1 × 1 = 1, so y = x + 1.
- With whole-number coefficients (Ax + By = C): x − y = −1.
Worked examples
| Points | Distance | Midpoint |
|---|---|---|
| (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
| Point | Squared distance | Distance |
|---|---|---|
| (3, 4) | 25 | 5 |
| (5, 12) | 169 | 13 |
| (8, 15) | 289 | 17 |
| (7, 24) | 625 | 25 |
| (20, 21) | 841 | 29 |
| (9, 40) | 1681 | 41 |
Simplifying square roots
| Root | Simplified | Decimal |
|---|---|---|
| √8 | 2√2 | ≈ 2.8284 |
| √12 | 2√3 | ≈ 3.4641 |
| √18 | 3√2 | ≈ 4.2426 |
| √20 | 2√5 | ≈ 4.4721 |
| √27 | 3√3 | ≈ 5.1962 |
| √32 | 4√2 | ≈ 5.6569 |
| √45 | 3√5 | ≈ 6.7082 |
| √50 | 5√2 | ≈ 7.0711 |
| √72 | 6√2 | ≈ 8.4853 |
| √75 | 5√3 | ≈ 8.6603 |
| √98 | 7√2 | ≈ 9.8995 |
| √200 | 10√2 | ≈ 14.1421 |
How to find the distance and midpoint between two points
- 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.
- Square the differences and add them. d² = (x₂ − x₁)² + (y₂ − y₁)² = 5² + 5² = 25 + 25 = 50. For three dimensions add (z₂ − z₁)².
- 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.
- 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.
- 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 free tools
- Slope CalculatorSlope from rise and run as percent, degrees and ratio (1:12). Convert 2% or 20% slope to degrees and find the drop over 10 ft. Feet, inches or metric.
- Circle CalculatorEnter a radius, diameter, circumference or area and get the other three, plus arc length, sector area and chord for a central angle, with the working.
- Pythagorean Theorem CalculatorFind the hypotenuse or a missing leg from any two sides, with area, angles and altitude. Test 3-4-5 right angles and find rectangle or screen diagonals.
- Surface Area CalculatorTotal, lateral and base surface area of a cube, box, sphere, cylinder, cone, pyramid, triangular prism or hemisphere, with your numbers in the formula.
- Percent Slope ConverterConvert percent slope to degrees, a 1:n ratio and inches of drop over a run, or the reverse. Handles 0%, 100% (45°), vertical and negative grades.
- Area CalculatorPick a shape (rectangle, triangle, circle, trapezoid, ellipse, polygon, ring and more) and get its area and perimeter, with the formula and working.
More: Geometry and measurementAll math & numbersAll toolsHome & DIY calculators