Equations of a Straight Line
In the applet below, lines can be dragged as a whole or with one of the two defining points. When a line is dragged or clicked upon, one of its equations is displayed just beneath the graph. With the Reduce box checked, the equation appears in its simplest form. The applet can display several lines simultaneously. To obtain additional lines, check the Duplicate box and start dragging one of the already present lines to the desired position. In fact, you'll be dragging a newly created copy of that line.
As of 2018, Java plugins are not supported by any browsers (find out more). This Wolfram Demonstration, Two Points Determine a Line, shows an item of the same or similar topic, but is different from the original Java applet, named 'LinearFunc'. The originally given instructions may no longer correspond precisely.
(image below from deprecated 'LinearFunc' applet)
Below I give several forms of the equation of a straight line depending on the attributes it is defined with. In every case, the verification is straightforward. Plug in the data and see that it satisfies the equation. All the equations below are derived in the usual Cartesian coordinate system.
Line through two points
The line through two distinct points
|(1)||y = y1 + [(y2 - y1) / (x2 - x1)]·(x - x1),|
where x1 and x2 are assumed to be different. In case they are equal, the equation is simplified to
x = x1
and does not require a second point.
Equation (1) can also be written as
y - y1 = [(y2 - y1) / (x2 - x1)]·(x - x1),
or even as
(x2 - x1)·(y - y1) = (y2 - y1)·(x - x1),
where one does not have to worry whether x1 = x2 or not. However, the simplest for me to remember is this
(y - y1)/(y2 - y1) = (x - x1)/(x2 - x1)
which is not as universal is the one before.
A straight line is defined by a linear equation whose general form is
Ax + By + C = 0,
where A, B are not both 0.
The coefficients A and B in the general equation are the components of vector
r·n = const.
That is a straight line is a locus of points whose radius-vector has a fixed scalar product with a given vector n, normal to the line. To see why the line is normal to n, take two distinct but otherwise arbitrary points r1 and r2 on the line, so that
r1·n = r2·n.
But then we conclude that
(r1 - r2)·n = 0.
In other words the vector r1 - r2 that joins the two points and thus lies on the line is perpendicular to n.
The norm ||n|| of a vector
Note that the line defined by a general equation would not change if the equation were to be multiplied by a non-zero coefficient. This property can be used to keep the coefficient A non-negative. It can also be used to normalize the equation by dividing it by ||n||. As a result, in a normalized equation
Ax + By + C = 0,
A2 + B2 = 1.
(In the applet, the coefficients of the normalized equation are rounded to up to 6 digits, for which reason the above identity may only hold approximately.)
The normalized equation is conveniently used in determining the distance from a point to a line.
Assume a straight line intersects x-axis at
x/a + y/b = 1,
which also can be written as
xb + ya = ab.
The latter form is somewhat more general as it allows either a or b to be 0. a and b are defined as x-intercept and y-intercept of the linear function. These are signed distances from the points of intersection of the line with the axes.
The equation of a straight line through point
y = m(x - a) + b, or y - b = m(x - a).
As a particular case, we have
The equation of a line with a given slope m and the y-intercept b is
y = mx + b.
This is obtained from the point-slope equation by setting a = 0. It must be understood that the point-slope equation can be written for any point on the line, meaning that the equation in this form is not unique. The slope-intercept equation is unique because if the uniqueness for the line of the two parameters: slope and y-intercept.
A line through point r0 = (a, b) parallel to vector u =
(x, y) = (a, b) + t·(u, v),
where t is any real number. In the vector form, we have
r = r0 + t·u,
where r = (x, y).
A line through point r0 = (a, b) perpendicular to vector n = (m, n) is given by
m(x - a) + n(y - b) = 0,
or if we take r = (x, y), a generic point on the line, we see that
n·(r - r0) = 0,
where dots indicates the scalar product of two vectors.
A function whose graph is a straight line is linear and continuous.