Writing a Line Equation from Two Endpoints
This article starts with coordinates and the linear functions learned in middle school. Our question is: given the two endpoints of a segment, how can we use an equation to describe its containing line?
First Understand What It Means for a Point to Satisfy an Equation
The point has horizontal coordinate and vertical coordinate . Below, denotes the horizontal coordinate and the vertical coordinate. These capital letters work just like the lowercase in textbooks.
Consider this equation:
It says: the vertical coordinate is times the horizontal coordinate, plus .
| Horizontal coordinate | Calculate the vertical coordinate | Resulting point |
|---|---|---|
The four dots below plot the four points in the table. They all lie on the blue line. A cross additionally marks for comparison.
Look at in the figure. The equation requires , so lies on the line. The point , which is higher, does not, since . Sharing a horizontal coordinate does not mean both points satisfy the equation; the vertical coordinate must also meet its requirement.
Only finitely many points are marked. From linear functions in middle school, we know that letting range over all real numbers, including negative numbers and decimals, gives an entire straight line as the graph of .
This equality is therefore called the line's “equation.” To test whether a point lies on the line, substitute both coordinates and check whether the equality holds.
How Can We Find the Equation from Two Endpoints?
Now reverse the question. Given only the endpoints and , how do we find the equation of their line?
First consider how much each coordinate changes from to . The dashed lines split the change into two parts: move right by , then up by . These are auxiliary reading guides, not the original segment.
Two distinct points determine a line. Since this line is not vertical, start with the linear-function form
Here are two unknown numbers. Textbooks often use for the last number. We use for now because will appear in another form later.
The line passes through , so substitution must give a true equation:
It also passes through , so
Subtract the first equation from the second to eliminate :
which gives . The and are exactly the upward and rightward changes in the figure: a horizontal increase of gives a vertical increase of , and we know that increase is . Divide both sides by to obtain . This number is the “slope.” Here it means moving to the right along the line takes us upward.
Substitute back into to get . Subtract from both sides to obtain .
The line equation is therefore
Why Also Write aX+bY=c?
Rewrite the same equation. First move to the left:
Then multiply both sides by :
Neither transformation changes the equation's solutions, so it still describes the same line.
Call the number before by the name , the number before by , and the number on the right by . Then we can write the general form
In , we have , , and . Remember that means , so is here.
are three fixed numbers; are the coordinates of a point on the line and can vary.
Can We Calculate a, b, c Directly from the Endpoints?
Yes, without first finding in the linear-function form. However, “calculate” does not mean that there is only one possible triple . We need to find a triple making describe the line through the two endpoints.
Keep using and . Start with the equalities these two points must satisfy, rather than rushing to memorize a formula.
What Requirements Do the Two Points Place on a and b?
The line passes through , so substituting , into must make the equality true:
That is,
The line also passes through . Substituting , gives
or
Both equations have the same number on the right. Subtract the first from the second to eliminate it:
Remove the parentheses. When subtracting an entire parenthesized expression, change the signs of both terms:
Group the terms and the terms:
Combine like terms:
Look back at the dashed-line diagram. From to , the horizontal coordinate increases by and the vertical coordinate by . Thus the total change in is . Both substituted points must give the same , so this change must equal .
Find One Triple, Then See Why It Is Not Unique
Starting from , subtract from both sides:
Divide both sides by the nonzero number :
This says that once we choose , is times . It does not prescribe a particular value for .
In this example, we cannot choose , because that would also make . Substituting an endpoint would then give , and the equation would become . Every point satisfies it, so it cannot describe the line we want.
First choose an easy value, . Substitute into :
The equation is now
Only remains unknown. The first point lies on the line, so substituting its coordinates must make the equation true:
First multiply to get , then subtract to get , or . We have found an equation:
Check the second point : the left side is , equal to the right side too.
Multiplying both sides of this equation by gives
Expand the left side using the distributive law and calculate the right side:
Now , , and . Multiplication by can be reversed by dividing both sides by , so exactly the same points satisfy the two equations. and are different coefficient triples describing the same line.
Choose a and b Directly to Avoid That Division
We first chose and later multiplied the whole equation by to explain why the coefficients are not unique. In an actual calculation, we can directly choose , from the latter triple.
Why choose these numbers? Look again at the condition imposed by the endpoints:
We want the two terms on the left to cancel. Multiplication is commutative: equals . Therefore, choosing in the first term and in the second makes the left side
This is a choice requiring no division: take as the change in vertical coordinate, and as the negative of the change in horizontal coordinate. Here the vertical change is , so . The horizontal change is , whose negative is , so . We can also write that negative as , which explains the reversed subtraction order in the second coefficient.
Having chosen these two numbers, the equation is temporarily
The right side must equal the value obtained by substituting any point on the line into the left side. We already know the first point lies on the line, so use it to calculate. Substitute , :
First calculate the two products: and . Then add:
We are not multiplying the coordinates of the two different points together. We multiply the first point's horizontal coordinate by , its vertical coordinate by , and add the results. Using the second point also works: , the same result.
Write This Choice as a General Formula
First name the coordinates of the two points:
| Symbol | Meaning | Value in this example |
|---|---|---|
| Horizontal coordinate of the first point | ||
| Vertical coordinate of the first point | ||
| Horizontal coordinate of the second point | ||
| Vertical coordinate of the second point |
The subscripts are just labels distinguishing the two points; does not mean .
Write the first point as and the second as . From the first to the second, the horizontal change is and the vertical change is .
Following the choice above, first take as the vertical change:
then take as the negative of the horizontal change. Removing parentheses preceded by a minus sign changes both signs:
Finally, because the first point is on the line, substitute , into to obtain
Omitting multiplication signs, the last line is . It still means “substitute the first point into the left side to calculate what the right side must be.”
The endpoints must be distinct so that are not both . If , their vertical coordinates are equal. If , their horizontal coordinates are equal too. If both hold, the points coincide.
These three steps use only addition, subtraction, and multiplication. Integer endpoint coordinates therefore give integer . Next we prove why the method works in general and check vertical and horizontal lines.
Why Do These Three Steps Always Work?
Repeat the earlier calculation of , now using coordinates for the two points. First consider the case where their horizontal coordinates differ.
Both points lie on , so substituting each gives
Subtract the first equation from the second to eliminate :
Since is nonzero, divide both sides by it:
Now take any point on the line. Subtract the first endpoint's equation from its equation , again eliminating :
Substitute the value of just found:
Multiply both sides by to clear the denominator:
Expand both sides with the distributive law:
Move the terms containing to the left and the remaining terms to the right:
Note that . Thus the coefficient of on the left is exactly , and the coefficient of is exactly . The right side is , which is .
This gives . The subtraction order in the formula comes from rearranging the equation; it is not arbitrary.
Does This Also Work for Vertical and Horizontal Lines?
Yes for vertical lines, but they need a separate explanation. We divided by above. Two points on a vertical line have equal horizontal coordinates, and division by is not allowed.
The figure below places the two special cases in one coordinate system. First consider the vertical blue line. From to , the vertical coordinate changes, but the horizontal coordinate remains , so its equation is .
This also explains why cannot describe a vertical line: when , the right side produces only one value, , which cannot equal both and from the figure.
Apply the three-step formula:
We obtain , or , which is correct. For any two distinct endpoints with the same horizontal coordinate, and . The equation becomes ; dividing by gives .
Horizontal lines work too. Consider the horizontal orange line: from to , the horizontal coordinate changes but the vertical coordinate stays , so the equation should be .
Substitution into the formula gives , , and . The equation is therefore , or .
Thus expresses ordinary slanted lines, horizontal lines, and vertical lines in the same form.
Finally, Distinguish Two Issues
The endpoints must be distinct points. If they coincide, the formula gives and the equation becomes . Every point satisfies it, so it cannot specify a particular line. The geometry agrees: through a single known point, we can draw many different lines.
A line equation describes the entire extended line. In the figure below, the thick solid part is only the segment from to . Dashed portions at both ends show that the line continues.
Consider in the figure. Substitution gives , a true equality, so it lies on the line. But it is beyond , outside the thick solid segment.
Follow the two vertical guides downward: the horizontal coordinates of are . Therefore this example requires both
to describe the original segment. The two equality signs in the bounds include its endpoints. The equation determines the line containing the points; the coordinate bounds then select which part of it to take. We use horizontal bounds here because this line is not vertical. For a vertical line, use the endpoints' vertical coordinates to bound the segment instead.
With these coefficients understood, continue to Integer Scaling and Intersection Denominators to see how they are used to compute the intersection of two lines.