# Equation of a Line

## Equation of a line

There are various ways of defining a line. In the following subsections, a linear equation of the line is given in each case.

### Slope–intercept form or Gradient-intercept form

A non-vertical line can be defined by its slope m, and its y-intercept y0 (the y coordinate of its intersection with the y-axis). In this case its linear equation can be written

$y=mx+y_{0}.$ If, moreover, the line is not horizontal, it can be defined by its slope and its x-intercept x0. In this case, its equation can be written

$y=m(x-x_{0}),$ or, equivalently,

$y=mx-mx_{0}.$ These forms rely on the habit of considering a non vertical line as the graph of a function. For a line given by an equation

$ax+by+c=0,$ these forms can be easily deduced from the relations

{\begin{aligned}m&=-{\frac {a}{b}},\\x_{0}&=-{\frac {c}{a}},\\y_{0}&=-{\frac {c}{b}}.\end{aligned}} ### Point–slope form or Point-gradient form

A non-vertical line can be defined by its slope m, and the coordinates $x_{1},y_{1}$ of any point of the line. In this case, a linear equation of the line is

$y=y_{1}+m(x-x_{1}),$ or

$y=mx+y_{1}-mx_{1}.$ This equation can also be written

$y-y_{1}=m(x-x_{1})$ for emphasizing that the slope of a line can be computed from the coordinates of any two points.

### Intercept form

A line that is not parallel to an axis and does not pass through the origin cuts the axes in two different points. The intercept values x0 and y0 of these two points are nonzero, and an equation of the line is

${\frac {x}{x_{0}}}+{\frac {y}{y_{0}}}=1.$ (It is easy to verify that the line defined by this equation has x0 and y0 as intercept values).

### Two-point form

Given two different points (x1, y1) and (x2, y2), there is exactly one line that passes through them. There are several ways to write a linear equation of this line.

If x1x2, the slope of the line is ${\frac {y_{2}-y_{1}}{x_{2}-x_{1}}}.$ Thus, a point-slope form is

$y-y_{1}={\frac {y_{2}-y_{1}}{x_{2}-x_{1}}}(x-x_{1}).$ By clearing denominators, one gets the equation

$(x_{2}-x_{1})(y-y_{1})-(y_{2}-y_{1})(x-x_{1})=0,$ which is valid also when x1 = x2 (for verifying this, it suffices to verify that the two given points satisfy the equation).

This form is not symmetric in the two given points, but a symmetric form can be obtained by regrouping the constant terms:

$(y_{1}-y_{2})x+(x_{2}-x_{1})y+(x_{1}y_{2}-x_{2}y_{1})=0$ (exchanging the two points changes the sign of the left-hand side of the equation).

### Determinant form

The two-point form of the equation of a line can be expressed simply in terms of a determinant. There are two common ways for that.

The equation $(x_{2}-x_{1})(y-y_{1})-(y_{2}-y_{1})(x-x_{1})=0$ is the result of expanding the determinant in the equation

${\begin{vmatrix}x-x_{1}&y-y_{1}\\x_{2}-x_{1}&y_{2}-y_{1}\end{vmatrix}}=0.$ The equation $(y_{1}-y_{2})x+(x_{2}-x_{1})y+(x_{1}y_{2}-x_{2}y_{1})=0$ can be obtained be expanding with respect to its first row the determinant in the equation

${\begin{vmatrix}x&y&1\\x_{1}&y_{1}&1\\x_{2}&y_{2}&1\end{vmatrix}}=0.$ Beside being very simple and mnemonic, this form has the advantage of being a special case of the more general equation of a hyperplane passing through n points in a space of dimension n – 1. These equations rely on the condition of linear dependence of points in a projective space.