How to calculate the Slope Intercept equation from two points

A common problem in linear equations is of how to determine the equation of a line, when given any two points on that line.

Here's a simple step by step guide on how to work out the equation in Slope Intercept Form (y = mx + b)

For example, given the two points (1,5) and (3,1), let's work out the solution. Lets call the (1,5) "Point 1" and (3,1) "Point 2" for reference.

Example of solving a Linear Equation from 2 Points

Step 1: Determine the Slope (m)

The Slope of a line is determined by the change in the value of y which corresponds to a given change in the value of x. We can use the two points we have been given to determine the slope:

  Point2.y - Point1.y
Point2.x - Point1.x
Subtract the two y values from eachother, and then divide this through by the difference of the x values

Substituting our values for the Point:

  1 - 5
3 - 1
Note: It doesn't matter whether you subtract Point 2 from Point 1 or Point 1 from Point 2, but it is important to keep the ORDER of the subtraction the same on the numerator and denominator
Do the subtraction on numerator and denominator
Our slope, m, is -2, so it slopes from top left to bottom right

Step 2: Determining the Y-Intercept (b)

The Y intercept is the point where the line intercepts the Y Axis (which is where x = 0). So by using this definition, and EITHER of the two points, we can work back from the point

Our slope, m, is -2. This means for every 1 unit of x we increase, y will decrease by 2 y-units (since m is -2), and conversely, for every x-unit we decrease, y will increase by 2 y-units (since -1 x -2 = 2)!

Taking the first point (1,5), x is 1. To get to the Y axis, we need to subtract 1 x-unit, so a decrease of 1 x-unit will require an increase of 2 y-units.

So the Y Intercept is 5 + 2 = 7

In mathematical terms, the general form of working a point back to the Y Axis using the slope of the line is:

b =
Point1.y - (m × Point1.x)

Taking Point 1, (1,5)

b =
5 - (-2 x 1)
5 - (-2)
5 + 2
5 + 2

Note that you could have ALSO used Point2, (3, 1):

b =
1 - (-2 x 3)
1 - (-6)
1 + 6

So our final equation for the line through the points (1,5) and (3,1), in Slope-Intercept form, is

y = -2 x + 7

See this example, and try your own problems using our Linear Equation solver with a Graph!