Equation of a Line from 2 Points
 |
Coordinates
I will be using Cartesian Coordinates, where you mark a point on a graph by how far along and how far up it is. |
Example: The point (12,5) is
12 units along, and 5 units up. |
|
Finding Slope (or Gradient) from 2 Points
 |
|
We know two points:
- point "A" is (6,4) (x is 6 when y is 4)
- point "B" is (2,3) (x is 2 when y is 3).
|
The formula is:
| Slope m = |
change in y |
= |
yA - yB |
|
|
| change in x |
xA - xB |
|
|
 |
So what we do is
- subtract the Y values,
- subtract the X values
- then divide
Like this:
It doesn't matter which point comes first, it still works out the same. Try swapping the points:
Finding an Equation from 2 Points
Now you know how to find the slope, let us look at finding a whole equation.
 |
|
What is the equation of this line?
|
The easiest method is to start with the "point-slope" formula:
y - y1 = m(x - x1)
We can choose any point on the line as being point "1", so let us just use point (2,3):
y - 3 = m(x - 2)
Use the formula from above for the slope "m":
And we have:
That is an acceptable answer, but we could simplify it further:
y - 3 = x/4 - 2/4
y = x/4 - ½ + 3
y = x/4 + 5/2
Which is now in the "Slope-Intercept (y = mx + b)" form.
Check It!
Let us confirm by testing with the second point (6,4):
y = x/4 + 5/2 = 6/4 + 2.5 = 1.5 + 2.5 = 4
Yes, when x=6 then y=4, so it works!
The Big Exception
The previous method works nicely except for one particular case: a vertical line:
 |
In that case the gradient is undefined (because you cannot divide by 0):
But there is still a way of writing the equation ... use "x =" instead of "y=", like this:
|
|