Video Lesson: How to Find the Equation of a Line when Given Two Points
The equation of a straight line can be calculated if two points it passes through are known. The equation can be written in the slope-intercept form, y = m๐ฅ + c (sometimes written as y = m๐ฅ + b) or the point-slope form, y – y1 = m(๐ฅ – ๐ฅ1).
Both of these forms can be rearranged to write the equation in the general form, a๐ฅ + by = c.

The point-slope form of the equation of a line is easier to calculate as only the value of the slope (m) is required. This is either given to us or we can calculate it from two points.
The gradient can be easily seen from an equation in point-slope form as it is the number in front of the brackets.
For example, the gradient of is 3.
The slope-intercept form of the line requires both the value of the slope (m) and the y-intercept (c). However it is beneficial in that both of these values can be easily read from the equation. The slope is the coefficient of ๐ฅ and the y-intercept is the constant term added to the ๐ฅ term.
For example, the gradient of is 5 and the y-intercept is 3.
The slope-intercept form of the line is generally shorter and simpler to write. Since it conveys more information, it is the most common way to write the equation of a straight line.
How to Find the Equation of a Line from Two Points
To find the equation of a line given two points:- Label one point as (๐ฅ1, y1) and the other point as (๐ฅ2, y2).
- Calculate the slope using m = (y2 – y1) รท (๐ฅ2 – ๐ฅ1).
- Substitute m and either (๐ฅ1, y1) or (๐ฅ2, y2) into y = m๐ฅ + c.
- Solve the resulting equation for c.
- Write the equation of the line as y = m๐ฅ + c using the calculated values of m and c.
For example, find the slope-intercept form of the equation of the line passing through the two points (5, 2) and (9, 6).

Step 1. Label one point as (๐ฅ1, y1) and the other point as (๐ฅ2, y2)
The values must be labelled in the order: (๐ฅ1, y1) and (๐ฅ2, y2).
That is the ๐ฅ1 and y1 values are from the first point and the ๐ฅ2 and y2 values are from the second point.
Considering the points: (5, 2) and (9, 6), we obtain the following values:
- ๐ฅ1 = 5
- y1 = 2
- ๐ฅ2 = 9
- y2 = 6
Step 2. Calculate the slope using m = (y2 – y1) รท (๐ฅ2 – ๐ฅ1)
Substituting the values listed above, we obtain:
This becomes
and so, .

Step 3. Substitute m and either (๐ฅ1, y1) or (๐ฅ2, y2) into y = m๐ฅ + c
Either point can be chosen, so we will use the first point of (5, 2).
Therefore we will substitute:
- ๐ฅ = 5
- y = 2
- m = 1
into the equation of a straight line:
Therefore, becomes

Step 4. Solve the resulting equation for c
becomes
and so,
.
Step 5. Write the equation of the line as y = m๐ฅ + c using the calculated values of m and c
Now we have m = 1 and c = -3.
can be written as
.
The equation of the line in slope-intercept form is .
We can write the steps to find the equation of a straight line in simple terms.
The steps for the equation of a straight line given two points are:- Calculate the slope, m.
- Substitute m into y = m๐ฅ + c.
- Substitute either coordinate to work out c.

Examples of Calculating the Slope-Intercept Equation of a Line when Given Two Points
Find the equation of the line between (1, 5) and (2, 8).
Here, ๐ฅ1 = 1, y1 = 5 and ๐ฅ2 = 2, y2 = 8.
Step 1. Calculate the slope, m
The gradient (or slope) of the line is found using the equation:
Therefore .
Step 2. Substitute m into y = m๐ฅ + c
Now that we know that m = 3,
can be written as
.
Step 3. Substitute either coordinate to work out c
We can choose either (1, 5) or (2, 8).
In this example, we will choose (2, 8).
Therefore we substitute ๐ฅ = 2 and y = 8 into .
Therefore, we obtain .
and so, c = 2.

Having now calculated both m and c, we can write the equation of the straight line.
becomes
.
Formula for the Slope-Intercept Equation of a Line From Two Points
Given any two points, (๐ฅ1, y1) and (๐ฅ2, y2), the formula for the slope-intercept equation of a straight line is y = m๐ฅ + c, where m = (y2 – y1) / (๐ฅ2 – ๐ฅ1) and c = y1 – m๐ฅ1.
Slope-Intercept Equation of a Straight Line
Where: and
.

- Calculate m = (y2 – y1) รท (๐ฅ2 – ๐ฅ1)/.
- Calculate c = y1 – m๐ฅ1.
- Substitute these values into y = m๐ฅ + c
Examples of using the Formula for the Equation of a Line Given Two Points
Find the equation of the line passing through (3, 4) and (5, 8).
Step 1. Label the coordinates
Using the order (๐ฅ1, y1) and (๐ฅ2, y2), we have the following:
๐ฅ1 = 3 y1 = 4 ๐ฅ2 = 5 y2 = 8
Step 2. Calculate the slope (m)
and so,
and therefore
.
Step 3. Calculate the y-intercept (c)
and so,
and therefore
.
Step 4. Form the equation
becomes
.

Formula for the Point-Slope Equation of a Line Given Two Points
The formula for the point-slope equation of a straight line when given two points, (๐ฅ1, y1) and (๐ฅ2, y2), can be written as y – y1 = m(๐ฅ – ๐ฅ1), where m = (y2 – y1) / (๐ฅ2 – ๐ฅ1).
Point-Slope Equation of a line when Given Two Points
The point-slope form of the equation of a line is always written as y – y1 = m(๐ฅ – ๐ฅ1).
The point-slope equation is easy to obtain as only the gradient and one point is required. The disadvantage to the point-slope form is that the y-intercept is not obvious until the equation is rearranged.

For example, find the point-slope equation of the line passing through the points (7, 2) and (3, 0).
Therefore: ๐ฅ1 = 7 —- y1 = 2 —- ๐ฅ2 = 3 —- y2 = 0.
Firstly, the slope (m) is calculated:
Then the values of m, y1 and ๐ฅ1 are substituted into .
We obtain the point-slope form of the equation as .
The formula for the equation of a straight line in slope-intercept form can be written as y = [ (y2 – y1) / (๐ฅ2 – ๐ฅ1) ] (๐ฅ –๐ฅ1) + y1.
Equation of a Line From Two Points: Calculator
This calculator calculates the equation of a line from two given points. Simply enter the two coordinates and the calculator will calculate the gradient (m) and y-intercept (c) for any straight line written in slope-intercept form (y = m๐ฅ + c).
To use this calculator, you must have two different coordinates.
Steps for using the calculator:
- Choose one point to be the first point (๐ฅ1, y1) and the other point to be the second point (๐ฅ2, y2). It does not matter which one is which.
- Enter both numbers from the first point (๐ฅ1, y1) in the first row of the calculator.
- Enter both numbers from the second point (๐ฅ2, y2) in the second row of the calculator.
- The calculator will then tell you the values of m and c for the line.
- Write y = m๐ฅ + c but replace m and c with the values given on the calculator to obtain your equation. Note, if c is negative, we write a subtraction instead of an addition as in the example below.

The numbers must be entered in the order: ๐ฅ1, y1, ๐ฅ2, y2.

๐ฅ1 = 2 —- y1 = 1 —- ๐ฅ2 = 4 —- y2 = 7
In the example above, the calculator calculated m = 3 and c = -5.
Therefore we write y = 3๐ฅ – 5.
We don’t write y = 3๐ฅ + – 5.
We keep ‘y’ and ‘๐ฅ’ as ‘y’ and ‘๐ฅ’. We only substitute the values of m and c.
How to Find the Slope from Two Points
When given two points (๐ฅ1, y1) and (๐ฅ2, y2), the slope is calculated using the formula: slope = (y2 – y1) รท (๐ฅ2 – ๐ฅ1). For example, the slope between (2, 1) and (4, 7) is calculated as slope = (7 – 1) รท (4 – 2). This is evaluated as slope = 6 รท 2 = 3.

How to Find the y-intercept from Two Points
The formula for the y-intercept of a line passing through two points (๐ฅ1, y1) and (๐ฅ2, y2) is c = y1 – m๐ฅ1, where m = (y2 – y1) รท (๐ฅ2 – ๐ฅ1).
Formula for the y-intercept from two points
where
For example, calculate the y-intercept of the line passing through the two points (2, 9) and (3, 13).
Step 1. Label the coordinates
Using the order (๐ฅ1, y1) and (๐ฅ2, y2):
- ๐ฅ1 = 2
- y1 = 9
- ๐ฅ2 = 3
- y2 = 13
Step 2. Calculate m
m = (y2 – y1) รท (๐ฅ2 – ๐ฅ1)
Using the values of
- ๐ฅ1 = 2
- y1 = 9
- ๐ฅ2 = 3
- y2 = 13
We obtain, and so,
.
Step 3. Calculate the y-intercept
The formula for the y-intercept given two points is .
Using the values of m = 4, ๐ฅ1 = 2 and y1 = 9:
Therefore, c = 1.
