πŸ—ΊοΈ Distance & Midpoint Calculator

Last updated: June 10, 2026

Distance & Midpoint Calculator

Enter two coordinate points to find the distance, midpoint, gradient and line equation.

Please enter valid numbers for all four coordinates.
Point A (x₁, y₁)
Point B (x₂, y₂)
πŸ“
Distance
πŸ“
Midpoint
πŸ“
Gradient (Slope)
πŸ“ˆ
Line Equation (y = mx + c)

Works with positive, negative, and decimal coordinates.

Why the Distance Formula Actually Makes Sense (And How to Stop Mixing It Up)

Ask any maths teacher what formula students forget most often in a coordinate geometry exam, and the distance formula comes up every time. Not because it is hard β€” once you see where it comes from, it becomes unforgettable. But because students memorise it without understanding the shape hiding underneath it.

The distance formula is just Pythagoras in disguise. Every time you draw two points on a grid, you can always build a right-angled triangle between them. The horizontal leg has length |xβ‚‚ βˆ’ x₁| and the vertical leg has length |yβ‚‚ βˆ’ y₁|. The straight-line distance between the two points is the hypotenuse. Apply Pythagoras' theorem β€” aΒ² + bΒ² = cΒ² β€” and you arrive at the distance formula exactly:

d = √((xβ‚‚ βˆ’ x₁)Β² + (yβ‚‚ βˆ’ y₁)Β²)

That squared sign cancels out the need for absolute values, so you never have to worry about which point is "bigger". Squaring a negative gives you a positive anyway.

The Midpoint: Thinking in Averages

The midpoint formula is even more intuitive once you think of it as an average. If you are driving from city A to city B and you want to find the halfway point, you take the average of the two distances from the start. Coordinates work exactly the same way in two dimensions β€” you just do it for x and y separately.

Midpoint M = ((x₁ + xβ‚‚)/2, (y₁ + yβ‚‚)/2)

A common exam trap: students add only the x-coordinates or forget to divide by 2 for one of the axes. Writing it out step-by-step, treating x and y as completely separate calculations, removes nearly all errors.

The midpoint matters beyond just finding the centre of a line segment. In circle geometry, if you know the two endpoints of a diameter, the midpoint gives you the centre of the circle. In vector questions, the midpoint appears when you bisect a line segment. In data analysis, averaging coordinates is how you find centroids. The formula is surprisingly versatile.

Gradient: Rise Over Run β€” But What Does That Mean Physically?

The gradient (also called slope) measures how steep a line is. The formula is:

m = (yβ‚‚ βˆ’ y₁) / (xβ‚‚ βˆ’ x₁)

A positive gradient means the line rises left to right. A negative gradient means it falls. A gradient of zero means the line is perfectly horizontal β€” y does not change at all. An undefined gradient (division by zero, when x₁ = xβ‚‚) means the line is perfectly vertical.

Gradient has real-world meaning. A road with a gradient of 0.1 rises 1 metre for every 10 metres of horizontal travel. On a graph, a steeper gradient means a faster rate of change. In physics, the gradient of a velocity-time graph gives you acceleration. In economics, the gradient of a cost function gives you marginal cost. The formula itself is simple arithmetic, but what it represents carries weight across every quantitative field.

One thing trips students up regularly: the order of subtraction. You must subtract in the same order for both numerator and denominator. (yβ‚‚ βˆ’ y₁)/(xβ‚‚ βˆ’ x₁) is correct. (yβ‚‚ βˆ’ y₁)/(x₁ βˆ’ xβ‚‚) flips the sign and gives you the wrong answer. Either order works as long as it is consistent β€” if you swap the labels of your two points, you get (y₁ βˆ’ yβ‚‚)/(x₁ βˆ’ xβ‚‚), which simplifies to the same value because both signs flip.

Building the Full Line Equation from Two Points

Once you have the gradient, you can write the full equation of the line. The standard form is y = mx + c, where m is the gradient and c is the y-intercept (the value of y when x = 0).

To find c, substitute one of your known points into the equation and solve:

c = y₁ βˆ’ mΒ·x₁

If your two points are (1, 2) and (4, 6), the gradient is (6βˆ’2)/(4βˆ’1) = 4/3. Substituting point (1, 2): c = 2 βˆ’ (4/3)(1) = 2/3. So the line equation is y = 4/3Β·x + 2/3.

This matters in exams because questions often ask you to "find the equation of the line passing through..." β€” and the two-point method is the most reliable approach when no gradient is given explicitly.

Perpendicular and Parallel Lines: The Gradient Connection

Once you have calculated the gradient between two points, you can immediately deduce information about related lines. Two lines are parallel if and only if they have the same gradient. Two lines are perpendicular if the product of their gradients equals βˆ’1 β€” which means the perpendicular gradient is the negative reciprocal of the original.

If a line has gradient 3, a perpendicular line has gradient βˆ’1/3. If a line has gradient βˆ’2/5, a perpendicular line has gradient 5/2. This comes up repeatedly in GCSE and A-Level questions about perpendicular bisectors, which combine all three ideas: you find the midpoint of a segment (to know where the bisector passes through), calculate the gradient of the segment, then flip it and negate it to get the bisector's gradient.

Coordinate Geometry in Exams: Where Marks Are Lost

Most marks lost on coordinate geometry questions are not from using the wrong formula β€” they are from arithmetic errors inside the formula. The safest habit is to label your points clearly (call them A and B or just write x₁, y₁, xβ‚‚, yβ‚‚ with the values substituted before doing any arithmetic), compute the subtraction before squaring, and show the intermediate step. Examiners award method marks even if you make an arithmetic slip, as long as the structure is visible.

A second common issue: students write the midpoint as a single number instead of a coordinate pair. The midpoint is always two values in the form (x, y) β€” forgetting the brackets or writing just one value loses the mark entirely.

For gradient, always double-check the sign. A single sign error changes a positive gradient to negative, which changes the character of the line entirely and will almost certainly cause errors in any follow-up parts of the question.

Using a calculator like the one above during revision helps because it shows the working formula alongside the answer. Checking your hand-calculated answers against a tool with transparent step-by-step formulas is far more useful than just seeing a number β€” you can trace exactly where your method diverged from the correct one.

FAQ

What is the distance formula and where does it come from?
The distance formula is d = √((xβ‚‚ βˆ’ x₁)Β² + (yβ‚‚ βˆ’ y₁)Β²). It comes directly from Pythagoras' theorem β€” the horizontal and vertical gaps between two points form the two legs of a right triangle, and the straight-line distance is the hypotenuse. Squaring each difference removes any sign issues, so it works regardless of which point is labelled first.
How do you find the midpoint between two coordinate points?
Add the two x-coordinates and divide by 2, then add the two y-coordinates and divide by 2. The midpoint formula is M = ((x₁ + xβ‚‚)/2, (y₁ + yβ‚‚)/2). Think of it as taking the average x-position and the average y-position independently. Always write the result as a coordinate pair, for example (2.5, 4), not just a number.
What does it mean if the gradient comes out as undefined?
An undefined gradient means both points share the same x-coordinate, so the line is perfectly vertical. Division by zero is not defined in normal arithmetic, which is why we say the gradient is undefined rather than zero. A horizontal line has a gradient of zero (the y-values are the same); a vertical line has an undefined gradient (the x-values are the same). The line equation in this case is simply x = k, where k is the shared x-coordinate.
Can I use negative coordinates with the distance and midpoint formulas?
Yes, fully. Both formulas work with any real numbers β€” positive, negative, zero, or decimals. In the distance formula the differences are squared, so negatives disappear automatically. In the midpoint formula you just carry out the arithmetic carefully: for example, the midpoint between (βˆ’3, 1) and (5, βˆ’7) is ((βˆ’3+5)/2, (1+(βˆ’7))/2) = (1, βˆ’3).
How do I find the equation of a line passing through two given points?
First calculate the gradient using m = (yβ‚‚ βˆ’ y₁)/(xβ‚‚ βˆ’ x₁). Then substitute the gradient and one of the known points into y = mx + c and solve for c: rearrange to get c = y₁ βˆ’ mΒ·x₁. Write the final equation in y = mx + c form. If the x-coordinates are equal the line is vertical and its equation is simply x = that shared value.
What is the relationship between the gradient and perpendicular lines?
Two perpendicular lines have gradients that multiply to βˆ’1. So if a line has gradient m, any line perpendicular to it has gradient βˆ’1/m (the negative reciprocal). For instance, if the gradient between two points is 2, the perpendicular gradient is βˆ’1/2. This is essential for questions on perpendicular bisectors, where you find the midpoint of a segment and then draw a perpendicular through it.