Graphics / Reference / Line equation (slope–intercept)

Line equation (slope–intercept)

A non-vertical straight line can be described by y = mx + c, where m gives its slope and c gives its y-intercept. The form can be derived directly from two known points.

For a non-vertical straight line, use y = mx + c.

m is the slope: the change in y for one unit of change in x. Geometrically, a horizontal run of 1 corresponds to a vertical rise of m. c is the y-intercept: the value of y where the infinite line crosses x = 0.

For a line through (x0,y0) and (x1,y1), with x1 != x0:

m = (y1 - y0)/(x1 - x0)

c = y0 - m*x0

The same c is obtained by substituting the second point: c = y1 - m*x1.

The standard diagram shows the line through the two endpoints, a right triangle marking a unit horizontal run and vertical rise m, and c marked where the line crosses the y axis.

A line through two labelled endpoints crosses the y axis at c, with a small right triangle showing horizontal run 1 and vertical rise m.
Slope is the rise produced by a unit run, while c is where the infinite line crosses the y axis.

Read