The line through two points

Through two distinct points there is exactly one straight line1. Through a single point you can draw any number of lines, but the moment a second point is fixed the direction is settled and only one line survives. Here we find the line through A(1,1)A(1, 1) and B(3,5)B(3, 5).

The slope

The slope measures how much yy increases while xx increases by 11. It is the difference in yy divided by the difference in xx.

5131=42=2\frac{5 - 1}{3 - 1} = \frac{4}{2} = 2

Building the equation

Writing the line as y=2x+by = 2x + b and substituting AA gives 1=21+b1 = 2 \cdot 1 + b, so b=1b = -1. The line is therefore y=2x1y = 2x - 1.

Let us check with the other point B(3,5)B(3, 5): 231=52 \cdot 3 - 1 = 5, so the line does pass through BB. Substituting BB instead of AA to find the intercept gives the same b=1b = -1; either point will do.

Three standard forms

FormEquationThis example
Slope-intercepty=mx+by = mx + by=2x1y = 2x - 1
Point-slopeyy1=m(xx1)y - y_1 = m(x - x_1)y1=2(x1)y - 1 = 2(x - 1)
Two-pointyy1y2y1=xx1x2x1\dfrac{y - y_1}{y_2 - y_1} = \dfrac{x - x_1}{x_2 - x_1}y14=x12\dfrac{y - 1}{4} = \dfrac{x - 1}{2}

The point-slope form gives the equation immediately, with no intercept to compute. In the two-point form, each side measures the fraction of the journey from AA to BB already covered, vertically on the left and horizontally on the right, and on the line those two fractions always agree. All three rearrange to y=2x1y = 2x - 1.

The vertical case

One case needs care: x1=x2x_1 = x_2. If the two points share an xx-coordinate the denominator is 00 and there is no slope. The line through them is vertical, and it cannot be written as y=mx+by = mx + b at all; it is written x=x1x = x_1. A line parallel to the yy-axis simply has no slope.

Testing collinearity

The same idea tests whether three points lie on one line: if the slope from AA to BB equals the slope from AA to CC, the three points are collinear. This routine, get the slope from two points and then build the equation through one of them, is the foundation for the intersection problems too.

The large dots on the graph are the two points AA and BB.

  1. Linear equation, Wikipedia