Distance & Midpoint
Enter two points to compute the straight-line distance between them with the distance formula d = √(Δx² + Δy²), and the midpoint as the average of the coordinates. Both results are shown with intermediate steps.
Two formulas from one pair of differences
Two points in the plane determine a segment, and two questions follow immediately: how long is it, and where is its centre. The first is answered by the distance formula, the second by the midpoint formula, and both are short enough to do by hand — which is precisely why sign errors slip through unnoticed.
This calculator takes the four coordinates and returns both results, showing the horizontal and vertical differences it derived them from. Those two intermediate numbers are where nearly every mistake in this calculation originates.
Distance and midpoint are usually taught together because they share a first step. Both relate the two points coordinate by coordinate: distance squares the differences and adds them, midpoint averages the coordinates instead. Computing them in one place makes that shared structure visible.
The tool reports Δx and Δy on their own line rather than folding them into the answer. If your hand-worked distance disagrees, comparing that line against your own subtraction usually localises the error in one glance.
How to use this calculator
- Enter the first point as x₁ and y₁ Two separate numeric fields. Negative coordinates take a minus sign and need no other special treatment.
- Enter the second point as x₂ and y₂ The same convention. Which point you call first does not affect either result, so there is no wrong order — a useful property that not every coordinate formula shares.
- Check the differences line Δx and Δy are shown before the distance. Confirming they match the subtraction you expected catches a mistyped coordinate.
- Read the distance and the midpoint The distance is a single non-negative number; the midpoint is an ordered pair. Both are shown to the same six-significant-figure display precision as the rest of the site.
The formula, and where it comes from
d = √((x₂ − x₁)² + (y₂ − y₁)²) M = ((x₁ + x₂)/2, (y₁ + y₂)/2)
The distance formula is the Pythagorean theorem in disguise. Draw a horizontal line from the first point and a vertical line to the second, and you have a right triangle whose legs are Δx and Δy and whose hypotenuse is the segment you want. Squaring, adding and taking the root is exactly a² + b² = c² with the legs named after coordinate differences.
Because both differences are squared, their signs vanish. That is why swapping the two points leaves the distance unchanged, and why entering the coordinates in the wrong order is harmless here even though it would flip the sign of a slope.
The midpoint is the componentwise average, which follows from the segment's centre being halfway along in each direction independently. Averaging is also sign-safe, so the midpoint of two points is likewise independent of their order.
The implementation computes the distance with the hypotenuse function rather than by squaring and adding directly. The result is the same for ordinary inputs, but the hypotenuse routine avoids intermediate overflow when the differences are very large, and loses less precision when one is far smaller than the other.
What each input means
- x₁ First x-coordinate — form field “x₁”
- The horizontal position of the first point. Any real number.
- y₁ First y-coordinate — form field “y₁”
- The vertical position of the first point.
- x₂ Second x-coordinate — form field “x₂”
- The horizontal position of the second point.
- y₂ Second y-coordinate — form field “y₂”
- The vertical position of the second point.
- Δx, Δy Coordinate differences
- Not entered — computed as x₂ − x₁ and y₂ − y₁. They are the legs of the right triangle whose hypotenuse is the distance, and they are reported so the working can be checked.
Worked examples
Every number below is produced by the same calculation engine the tool above runs. Nothing here is typed by hand, so the walkthrough cannot drift from what you get when you enter the same values yourself.
The 3-4-5 triangle in coordinates
From (1, 2) to (4, 6). The differences come out as 3 and 4, making this the classic right triangle whose hypotenuse is exactly 5 — a case where the answer can be verified without any arithmetic.
Inputs x₁ = 1, y₁ = 2, x₂ = 4, y₂ = 6
- Points P₁(1, 2), P₂(4, 6)
- Differences Δx = 3, Δy = 4
- Distance d = √(Δx² + Δy²) = √(9 + 16) = 5
- Midpoint M = ((x₁+x₂)/2, (y₁+y₂)/2) = (2.5, 4)
Result distance = 5, midpoint = (2.5, 4)
The differences line shows Δx = 3 and Δy = 4, so the distance is √(9 + 16) = √25 = 5 exactly. Whole-number distances are rare; they occur only for Pythagorean triples, which is what makes this pair a standard textbook example.
The midpoint is (2.5, 4), and note that it need not have integer coordinates even when both endpoints do. A midpoint has a fractional coordinate whenever the two values on that axis differ by an odd number.
Crossing the origin with negative coordinates
From (−3, −1) to (2, 5). Both coordinates of the first point are negative, which is where sign errors in the subtraction usually appear.
Inputs x₁ = -3, y₁ = -1, x₂ = 2, y₂ = 5
- Points P₁(-3, -1), P₂(2, 5)
- Differences Δx = 5, Δy = 6
- Distance d = √(Δx² + Δy²) = √(25 + 36) = 7.81025
- Midpoint M = ((x₁+x₂)/2, (y₁+y₂)/2) = (-0.5, 2)
Result distance = 7.81025, midpoint = (-0.5, 2)
Δx is 2 − (−3) = 5, not −1. Subtracting a negative adds, and this is the single most common slip in the whole calculation: the difference is larger in magnitude than either coordinate.
The midpoint falls at (−0.5, 2), between the two points and on the opposite side of the y-axis from the second one. Averaging a negative with a positive lands wherever the larger magnitude pulls it, which is a useful plausibility check on the result.
Reading the result
Distance is never negative
A square root of a sum of squares cannot be negative, so a negative distance always means a misread output. Zero is possible, and means the two points coincide.
The midpoint always lies between the points
Each of its coordinates is the average of the corresponding pair, so it sits strictly between them on both axes unless the points share that coordinate. If your computed midpoint falls outside the segment, the arithmetic is wrong — usually a sum used where a difference belonged.
What exactness to expect
Midpoints of whole-number coordinates are exact, since averaging halves at worst. Distances rarely are: √25 is a lucky case, and most results are irrational and shown rounded to six significant figures rather than as a surd.
When you would use this
Classifying a triangle from its vertices
Computing all three side lengths tells you whether a triangle given by coordinates is scalene, isosceles or equilateral, and comparing the squares of the sides tests for a right angle without needing any angle measure.
Finding the centre and radius of a circle
Given the two ends of a diameter, the midpoint is the centre and half the distance is the radius. That pair of results is all the circle equation needs, which makes this a common first step in coordinate-geometry problems.
Assumptions and limitations
What this calculator assumes
- Both points lie in the Cartesian plane, with the usual perpendicular axes and equal scales.
- All four coordinates are finite real numbers; no units are attached, so the distance carries whatever unit the coordinates were measured in.
- Distance is straight-line Euclidean distance, not a path length or a grid distance.
Where it stops being the right tool
- Two dimensions only. A three-dimensional distance needs a third squared difference, which this solver does not accept.
- Euclidean metric only: no Manhattan distance, no great-circle distance for latitude and longitude pairs, which lie on a sphere rather than a plane.
Common mistakes
Mishandling a subtraction of negatives
Why it happens. With x₁ = −3 and x₂ = 2, the difference is 5, but writing 2 − 3 gives −1. The result still looks plausible, and squaring hides the sign, so the distance simply comes out too small with nothing to flag it.
How to avoid it. Read the differences line before the answer. If Δx is smaller than the gap you expected from a sketch, the double negative was dropped.
Averaging in the distance formula, or subtracting in the midpoint
Why it happens. The two formulas are taught in the same lesson and look structurally similar, so under time pressure the operations get exchanged between them.
How to avoid it. Anchor each to its meaning: distance is a length, so it must involve differences; a midpoint is a position, so it must involve an average of positions. A midpoint that falls outside the segment gives the swap away immediately.
Forgetting the square root
Why it happens. Δx² + Δy² is a natural stopping point, and it is the quantity used when only comparing lengths, so it can be mistaken for the answer.
How to avoid it. Check the magnitude against a rough sketch. The distance is always less than Δx + Δy and at least as large as the bigger of the two, which the un-rooted sum violates for anything beyond very small values.
Key terms
Frequently asked questions
What is the distance formula?
d = √((x₂ − x₁)² + (y₂ − y₁)²). It is the Pythagorean theorem applied to the right triangle whose legs are the horizontal and vertical differences between the two points.
Does the order of the points matter?
No, for either result. The differences are squared in the distance formula, so their signs disappear, and the midpoint is an average, which is symmetric in its two arguments.
Can the coordinates be negative or fractional?
Yes. Any finite real numbers are accepted. Negative coordinates are the case worth double-checking, because subtracting one adds rather than subtracts.
Can this handle points in three dimensions?
No. The solver takes four coordinates describing two points in the plane. A three-dimensional distance adds a (z₂ − z₁)² term under the same square root, but that is a different calculation.