Sub topic 11
Finding a midpoint
This chapter assumes you can plot an ordered pair (x, y), read the signs of coordinates, and work out horizontal and vertical distances between points. You should also be comfortable halving positive and negative numbers, including fractions and decimals. The distance check near the end uses the Pythagorean theorem, but you can do the main work without it.
What a midpoint is
The midpoint of a segment is the point exactly halfway between its two endpoints. It lies on the segment, and it is the same distance from each end. Because the plane has two directions, you need two numbers to describe it: how far along the x-axis it sits and how far up or down the y-axis.
Starting on one number line
Take two numbers on a number line, such as 2 and 10. The halfway point is 6. You can find it in two equivalent ways:
- Average the two numbers: (2 + 10) / 2 = 6.
- Start at 2 and add half the distance: 10 − 2 = 8, half of 8 is 4, and 2 + 4 = 6.
The average method also works when a number is negative. The midpoint of −7 and 3 is (−7 + 3) / 2 = −2. Check it: −2 is 5 units from −7 and 5 units from 3.
The midpoint formula
The coordinate plane is two number lines at right angles. The x-coordinate of the midpoint is the midpoint of the two x-values, and the y-coordinate is the midpoint of the two y-values. For endpoints P(x₁, y₁) and Q(x₂, y₂):
M = ((x₁ + x₂) / 2, (y₁ + y₂) / 2)
In words: average the x-coordinates, then average the y-coordinates. The two calculations are independent of each other.
Why the formula works
Move from P to Q. The horizontal change is x₂ − x₁ and the vertical change is y₂ − y₁. The midpoint is reached after half of each change:
- x-coordinate: x₁ + (x₂ − x₁) / 2
- y-coordinate: y₁ + (y₂ − y₁) / 2
Simplify the first expression: x₁ + x₂/2 − x₁/2 = x₁/2 + x₂/2 = (x₁ + x₂) / 2. The y-coordinate simplifies the same way. So the "average" formula and the "go halfway" description are the same thing. The second view is useful when you want to picture the point: you walk half of the horizontal distance and half of the vertical distance.
Walking half of each leg also puts you halfway along the straight segment. The two legs and the segment form a right triangle, and the point halfway along both legs lies halfway along the hypotenuse.
Worked examples
Example 1: endpoints in different quadrants
Find the midpoint of A(−6, 3) and B(2, −9).
- x: (−6 + 2) / 2 = −4 / 2 = −2
- y: (3 + (−9)) / 2 = −6 / 2 = −3
- Midpoint: (−2, −3)
Put the sign inside the sum. Writing 3 + (−9) in brackets prevents the usual slip of calculating 3 + 9.
Example 2: a vertical segment
Find the midpoint of (3, −2) and (3, 6).
- x: (3 + 3) / 2 = 3
- y: (−2 + 6) / 2 = 2
The midpoint is (3, 2). When both endpoints share an x-value, the midpoint keeps that x-value. A horizontal segment behaves the same way with y.
Example 3: fractions and decimals
Find the midpoint of (1/2, 3) and (5/2, −1).
- x: (1/2 + 5/2) / 2 = (6/2) / 2 = 3/2
- y: (3 + (−1)) / 2 = 1
The midpoint is (3/2, 1), or (1.5, 1). Midpoints often have non-integer coordinates even when both endpoints are integers. The midpoint of (1, 2) and (4, 6) is (2.5, 4).
Midpoints in code
The function below implements the formula directly. It also checks the result using the distance formula. The midpoint should be the same distance from each endpoint, and those two distances should add up to the full length.
import math
def midpoint(p, q):
return ((p[0] + q[0]) / 2, (p[1] + q[1]) / 2)
a = (1, 2)
b = (4, 6)
m = midpoint(a, b)
print(m)
print(math.dist(a, m))
print(math.dist(m, b))
print(math.dist(a, b))The output is:
(2.5, 4.0)
2.5
2.5
5.0The two half-distances are both 2.5, and they sum to the full distance of 5.0.
Floating-point numbers can introduce tiny rounding differences for decimals such as 0.1. When you compare distances in code, use math.isclose(d1, d2) instead of ==.
Working backwards: finding a missing endpoint
Sometimes you know the midpoint M and one endpoint P, and you need the other endpoint Q. Start from the formula for the x-coordinate:
mx = (px + q_x) / 2
Multiply both sides by 2 and subtract px: qx = 2·mx − px. The y-coordinate works the same way. In words, Q is as far past M as P is before it. You can also say that you apply the step from P to M a second time.
def other_endpoint(m, p):
return (2 * m[0] - p[0], 2 * m[1] - p[1])
m = (3, -1)
p = (5, 2)
q = other_endpoint(m, p)
print(q)
print(((p[0] + q[0]) / 2, (p[1] + q[1]) / 2))This prints (1, -4) and then (3.0, -1.0). The second line confirms that averaging P and Q returns the original midpoint M. Whenever you solve for an endpoint, run this check by hand: average your answer with the known endpoint and see whether you get the given midpoint back.
Midpoints and polygons
The midpoint formula is the main tool for questions about the sides and diagonals of polygons. One well-known fact is that the diagonals of a parallelogram cross at their common midpoint. Take A(0, 0), B(4, 1), C(7, 5) and D(3, 4). Side AB goes 4 right and 1 up, and so does side DC, so ABCD is a parallelogram.
def midpoint(p, q):
return ((p[0] + q[0]) / 2, (p[1] + q[1]) / 2)
A, B, C, D = (0, 0), (4, 1), (7, 5), (3, 4)
print(midpoint(A, C))
print(midpoint(B, D))Both lines print (3.5, 2.5). The diagonals AC and BD share the same midpoint, so they cross there and cut each other in half. A later chapter on polygons returns to this idea.
Common errors
| Error | What goes wrong | Fix |
|---|---|---|
| Subtracting instead of adding | You get half the distance (the step size), not the position | Add the coordinates, then halve |
| Mixing coordinates | Averaging x₁ with y₂ gives a meaningless point | Pair x with x and y with y |
| Dropping a negative sign | 3 + (−9) becomes 12 | Bracket negatives and check with a sketch |
| Halving only one coordinate | The result is far from the segment | Halve both sums |
| Using floor division in code | Non-integer midpoints are rounded down | Use `/` |
Checking your answer
Two quick checks catch most mistakes before you finish.
- Range check. Each coordinate of the midpoint must lie between the matching coordinates of the endpoints, or equal them. If the x-values are −6 and 2, an x-coordinate of 5 cannot be correct.
- Sketch check. Plot both endpoints and the midpoint. The three points should lie on one straight line, with M visibly in the middle.
A midpoint can fall in a different quadrant from both endpoints. The midpoint of (−4, 3) and (6, 3) is (1, 3), which is in quadrant I. One endpoint is in quadrant II and the other is in quadrant I, so this case is not as surprising. A stronger example is (−5, 2) and (3, −6), where the midpoint (−1, −2) is in quadrant III and neither endpoint is. A midpoint can also land on an axis: the midpoint of (−2, 5) and (2, 1) is (0, 3), on the y-axis. The signs of the endpoints alone do not tell you where the midpoint is, so compute it.
Summary of the method
- Write the two endpoints and label their coordinates clearly.
- Add the two x-values and halve the sum.
- Add the two y-values and halve the sum.
- Write the result as an ordered pair, x first.
- Check it against the range check or a sketch.
To go the other way, double the midpoint's coordinates and subtract the known endpoint's coordinates.
Exercise
Find the midpoint of the segment with endpoints (−5, −2) and (9, 6).
Show answer
x: (−5 + 9) / 2 = 2. y: (−2 + 6) / 2 = 2. The midpoint is (2, 2).
Exercise
The midpoint of segment PQ is (2, −1) and P is (−3, 4). Find Q, then verify your answer.
Show answer
qx = 2·2 − (−3) = 7 and qy = 2·(−1) − 4 = −6, so Q is (7, −6). Check: (−3 + 7) / 2 = 2 and (4 + (−6)) / 2 = −1, which matches the given midpoint.
Exercise
Segment AB has endpoints A(−5, 2) and B(3, −6). Find the midpoint, name its quadrant, and say whether the quadrant matches either endpoint.
Show answer
x: (−5 + 3) / 2 = −1. y: (2 + (−6)) / 2 = −2. The midpoint is (−1, −2), in quadrant III. A is in quadrant II and B is in quadrant IV, so the midpoint is in neither endpoint's quadrant.
Exercise
A student computes the midpoint of (2, 7) and (6, 1) as (2, 3), reasoning "(6 − 2) / 2 = 2 and (7 − 1) / 2 = 3". What did they do wrong, and what is the correct midpoint?
Show answer
They subtracted, which gives half the horizontal and vertical change, not the position. The correct calculation adds: (2 + 6) / 2 = 4 and (7 + 1) / 2 = 4, so the midpoint is (4, 4).