Distance and Midpoint Calculator
Enter two points in the plane or in space and get the distance between them in simplest radical form (with a decimal beside it), their midpoint, and the point that divides the segment in any ratio m : n. Switch modes to find the other endpoint when you know one endpoint and the midpoint. The working is written out and, in 2D, the segment is drawn to scale. Free, no sign-up.
Whole numbers, decimals or fractions such as 3/4.
Results
2√13 ≈ 7.211103
Distance
(1, 1)
Midpoint
52
Distance squared
The working
d = √(sum of the squared differences in x, y)
d = √((4 − (−2))² + ((−1) − 3)²) = √(6² + (−4)²) = √(36 + 16) = √52 = 2√13 ≈ 7.211103
√52 = √(4 × 13) = 2√13
M = ((x₁ + x₂) / 2, (y₁ + y₂) / 2, …)
M = (((−2) + 4) / 2, (3 + (−1)) / 2) = (1, 1)
Section formula
(0, 5/3)
Point dividing P₁P₂ internally 1 : 2
S = (n·P₁ + m·P₂) / (m + n)
S = (2 × P₁ + 1 × P₂) / (1 + 2) = (0, 5/3)
Diagram
How to Use the Distance and Midpoint Calculator
- 1. Choose 2D or 3D and a mode. The first mode measures between two points; the second finds an endpoint from a point and the midpoint.
- 2. Enter the coordinates. Integers, decimals and fractions such as 1/2 are kept exact, so a distance of √13 never turns into 3.6055.
- 3. Read the distance and midpoint. The distance is in simplest radical form with a decimal approximation; the midpoint is shown as a fraction or decimal point.
- 4. Try the section formula. Set m and n and choose internal or external division to find the point that splits the segment in that ratio. In 2D the segment, midpoint and section point are plotted.
The Formulas
| Quantity | 2D | 3D |
|---|---|---|
| Distance | d = √((x₂ − x₁)² + (y₂ − y₁)²) | d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²) |
| Midpoint | ((x₁ + x₂)/2, (y₁ + y₂)/2) | ((x₁ + x₂)/2, (y₁ + y₂)/2, (z₁ + z₂)/2) |
| Point dividing P₁P₂ internally m : n | (n·P₁ + m·P₂) / (m + n) | the same, applied to each coordinate |
| Point dividing P₁P₂ externally m : n | (m·P₂ − n·P₁) / (m − n) | the same, applied to each coordinate |
| Other endpoint, given P₁ and the midpoint M | P₂ = 2M − P₁ | the same, applied to each coordinate |
The distance formula is the Pythagorean theorem applied to the horizontal and vertical differences between the points: they are the legs of a right triangle whose hypotenuse is the segment. In 3D the same idea applies twice. The midpoint is simply the average of each coordinate, and it is the section point for the ratio 1 : 1.
Worked Examples
- Distance and midpoint in 2D. For P₁ = (−2, 3) and P₂ = (4, −1) the differences are 6 and −4, so d = √(36 + 16) = √52 = 2√13 ≈ 7.211103. The midpoint is ((−2 + 4)/2, (3 − 1)/2) = (1, 1).
- Section formula. The point that divides the same segment internally in the ratio 1 : 2 is ((2 × (−2) + 1 × 4)/3, (2 × 3 + 1 × (−1))/3) = (0, 5/3). It lies one-third of the way from P₁ to P₂.
- External division. For P₁ = (0, 0) and P₂ = (4, 0), the ratio 3 : 1 externally gives ((3 × 4 − 1 × 0)/(3 − 1), 0) = (6, 0), a point beyond P₂.
- Distance in 3D. From (1, 2, 3) to (4, −2, 15) the differences are 3, −4 and 12, so d = √(9 + 16 + 144) = √169 = 13, and the midpoint is (5/2, 0, 9).
- Missing endpoint. If one endpoint is (1, 2) and the midpoint is (5/2, 4), the other endpoint is (2 × 5/2 − 1, 2 × 4 − 2) = (4, 6).
Internal and External Division
Saying a point divides P₁P₂ in the ratio m : n means its distances to P₁ and P₂ are in the ratio m to n. For an internal division the point lies between the two, with m/(m + n) of the length on the P₁ side. For an external division it lies on the line but outside the segment: beyond P₂ when m > n, beyond P₁ when m < n. A ratio of 1 : 1 has no external point, because the formula would divide by zero. Section points are how a line segment is split into equal parts, how a centroid is found, and how coordinates are interpolated between two known points.
Frequently Asked Questions
- What is the distance formula?
- d = √((x₂ − x₁)² + (y₂ − y₁)²) in the plane, with a (z₂ − z₁)² term added in space. It comes from the Pythagorean theorem: the horizontal and vertical differences are the two legs of a right triangle and the distance is its hypotenuse.
- How do you find the midpoint of a segment?
- Average the coordinates: add the two x-values and halve, add the two y-values and halve (and likewise for z). The midpoint of (−2, 3) and (4, −1) is (1, 1).
- How do you find an endpoint when you know the other endpoint and the midpoint?
- Double the midpoint and subtract the known endpoint, coordinate by coordinate: P₂ = 2M − P₁. The midpoint is exactly halfway, so the unknown endpoint is as far beyond M as the known endpoint is before it.
- What is the section formula?
- It gives the point that divides a segment in a given ratio. For an internal division in the ratio m : n the point is (n·P₁ + m·P₂)/(m + n); for an external division it is (m·P₂ − n·P₁)/(m − n). The midpoint is the special case m = n.
- Does the order of the points matter for the distance?
- No. Swapping the points changes the sign of every difference, and the differences are squared, so the distance is the same. The order does matter for the section formula, because m : n is measured from P₁ to P₂.
- Why is the distance left as a square root?
- A square root such as √52 is the exact distance; a decimal is rounded. The calculator simplifies it (√52 = 2√13) and also gives the decimal, so you can use the exact value in a proof and the decimal in a measurement.