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 = y_{1} + [(y_{2} - y_{1}) / (x_{2} - x_{1})]·(x - x_{1}), |
where x_{1} and x_{2} are assumed to be different. In case they are equal, the equation is simplified to
x = x_{1}
and does not require a second point.
Equation (1) can also be written as
y - y_{1} = [(y_{2} - y_{1}) / (x_{2} - x_{1})]·(x - x_{1}),
or even as
(x_{2} - x_{1})·(y - y_{1}) = (y_{2} - y_{1})·(x - x_{1}),
where one does not have to worry whether x_{1} = x_{2} or not. However, the simplest for me to remember is this
(y - y_{1})/(y_{2} - y_{1}) = (x - x_{1})/(x_{2} - x_{1})
which is not as universal is the one before.
General equation
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 r_{1} and r_{2} on the line, so that
r_{1}·n = r_{2}·n.
But then we conclude that
(r_{1} - r_{2})·n = 0.
In other words the vector r_{1} - r_{2} that joins the two points and thus lies on the line is perpendicular to n.
Normalized equation
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,
A^{2} + B^{2} = 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.
Intercept-intercept
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.
Point-slope
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
Slope-intercept equation
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.
Parametric equation
A line through point r_{0} = (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 = r_{0} + t·u,
where r = (x, y).
Implicit equation
A line through point r_{0} = (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 - r_{0}) = 0,
where dots indicates the scalar product of two vectors.
A function whose graph is a straight line is linear and continuous.
|Contact| |Front page| |Contents| |Algebra|
Copyright © 1996-2018 Alexander Bogomolny
65423766 |