Amara and Ben live in the same town. On a city map drawn on a grid where each square is km wide, Amara's home is at and Ben's is at . They want to meet at a café exactly halfway between their homes, and they want to know how far apart they live in a straight line ("as the crow flies"). You could measure the map with a ruler, but a ruler gives an estimate that depends on how carefully the map was drawn. Analytic geometry answers both questions exactly, using nothing but the coordinates. By the end of this lesson you will be able to say that the café belongs at and that the homes are exactly km apart, and you will know why.
A line segment is the part of a line between two endpoints. It is named by its endpoints, so the segment from to is written . The midpoint of a segment is the point on the segment that is the same distance from both endpoints; it cuts the segment into two equal halves. The length of a segment is the distance between its endpoints. To write formulas that work for any segment, label the endpoints with subscripts: the first endpoint is and the second is . The small and are labels, not exponents: is read "x one" and just means "the x-coordinate of the first point".

Developing the midpoint formula
Look only at the x-coordinates first. Going from to , the x-coordinate runs from to . The number halfway between and on a number line is their average (mean): . Now the y-coordinates: halfway between and is . So the midpoint is . Why can the two coordinates be treated separately? From to the segment goes right (the run) and up (the rise). Starting at and going half the run and half the rise ( right and up) lands on the segment, because the slope stays . That point is exactly halfway along. The small triangle from to is a half-size copy of the big triangle from to .
The formula also runs backwards. Suppose is the midpoint of and you know but not . Getting from to takes right (from to ) and down (from to ). Because is halfway, getting from to takes the same move again: right and down, so . Algebraically, set , so and ; and set , so and . Either way, check by finding the midpoint of and : it is .
Developing the length formula
Horizontal and vertical segments are easy: subtract. From to is units, and from to is units. A slanted segment needs one more idea. Draw a horizontal line through and a vertical line through . They meet at , the corner of a right triangle whose hypotenuse is . The horizontal leg has length and the vertical leg has length . The Pythagorean theorem (, true for every right triangle) gives , so . Amara and Ben live km apart. Replacing the numbers by the general coordinates gives the length formula (also called the distance formula):
Three details make the formula reliable. First, the order of the points does not matter: and , because squaring removes the sign. Second, a difference can be negative, so put it in brackets before squaring: , but a calculator reads as . Third, most lengths are not whole numbers. For and : and , so . Give the exact answer as a radical in simplest form by taking out the largest perfect-square factor, , and give a decimal approximation when one is asked for: .
| Endpoints | Run | Rise | Sum of squares | Exact length | Decimal |
|---|---|---|---|---|---|
| and | |||||
| and | |||||
| and | |||||
| and |
With both formulas you can measure any shape whose corners have coordinates. The perimeter of a triangle is the sum of its three side lengths, each found with the length formula. A side length that is a radical can stay exact until the end: a triangle with sides , and has perimeter . Round only the final answer, not the pieces along the way, so rounding errors do not build up.