Back
How to Find the Equation of a Line from Two Points
> ... Math > Slopes, Intercepts, Equation of a Straight Line > How to Find the Equation of a Line from Two Points

Introduction

In this lesson, you will learn how to find the equation of a line using two given points.


This video illustrates the lesson material below. Watching the video is optional.


How to Find the Equation of a Line From Two Points

Here are two points: \((-5, 13)\) and \((3, -3)\). Both of these points are on the same line (see Figure 1). To find the equation of this line, follow three steps:

Cartesian coordinate system with a line running through two points: (-5, 13) and (3, -3). 

Figure 1

Step 1
Find the slope using the slope formula: \(m=\frac{y_{2-}y_{1}}{x_{2-}x_{1}}\)

\begin{align*} m&=\frac{y_{2} - y_{1}}{x_{2} - x_{1}} &\color{red}\small\text{Slope formula}\\\\
m&=\frac{13 - (-3)}{-5 - 3} &\color{red}\small\text{Substitute values of x & y}\\\\ m&=\frac{16}{-8}&\color{red}\small\text{Simplify numerator and denominator}\\\\ m&=-2 &\color{red}\small\text{Simplify the fraction}\\\ \end{align*}

The slope is -2 for this equation.

Cartesian coordinate system with a line running through two points: (-5, 13) and (3, -3). The rise is labeled 13 - (-3) = 16. The run is labeled -5 - 3 = -8. 

Figure 2

Step 2
Use the slope and one of the points to solve for the y-intercept using the slope-intercept form: \(y=mx + b\). It does not matter which point you use to find the equation. Here, \((3, -3)\) is used with \(m = -2\).

\begin{align*} y&=mx+b&\color{red}\small\text{Slope-intercept form}\\\\
-3&=-2(3)+b&\color{red}\small\text{Substitute values of m, x, & y}\\\\ -3&= -6 +b &\color{red}\small\text{Right side: multiply -2 & 3}\\\\ -3 \color{red}\text{+6} &= -6 + b \color{red}\text{+6} &\color{red}\small\text{Add 6 to both sides} \\\\ -3 \color{red}\text{+6} &= b &\color{red}\small\text{Right side: the 6's will cancel} \\\\ 3&= b &\color{red}\small\text{Left side: subtract 3 from 6} \end{align*}

The y-intercept, or b, is equal to 3.

Step 3
Once you know the value for m and the value for b, you can substitute these into the slope-intercept form to get the equation for the line. The equation of the line that both of these points go through is \(y=-2x+3\).


Things to Remember

  • The slope formula is \(m=\frac{y_{2-}y_{1}}{x_{2-}x_{1}}\).
  • The steps to find the equation of a line, when given two points are:
    1. Find the slope using the slope formula.
    2. Use the slope and one of the points given to solve for the y-intercept in the slope-intercept form of a line: \(y=mx + b\).
    3. Use the slope (m) and y-intercept (b) to write the equation of the line using the slope-intercept form.

Practice Problems

For each of the following problems, find the equation of the line that passes through the following two points:
  1. \(\left ( -5,10 \right )\) and \(\left ( -3,4 \right )\) (
    Solution
    x
    Solution: \({\text{y}}=-3{\text{x}}-5\)

    Details:

    Step 1: Find the slope using the formula:

    \(\displaystyle{\text{Slope}}={\text{m}}=\frac{\text{rise}}{\text{run}}=\frac{{\text{y}}_2-{\text{y}}_1}{{\text{x}}_2-{\text{x}}_1}\)

    You have two points,\(\left ( -5,10 \right )\) and \(\left ( -3,4 \right )\). For this example, choose \(\left ({\color{Red} -5},{\color{Red} 10} \right )\) as point one and \(\left ({\color{blue} -3},{\color{blue} 4} \right )\) as point two. (It does not matter which is point one and which is point two as long as you stay consistent throughout the calculations.) Input the points into the formula for slope:

    \(\displaystyle\frac{{\text{y}}_2-{\text{y}}_1}{{\text{x}}_2-{\text{x}}_1}=\frac{{\color{blue}4}-{\color{Red}10}}{{\color{blue}-3}-({\color{Red}-5})}\)

    Simplify:

    \(\dfrac{4-10}{-3-(-5)}=\dfrac{4-10}{-3+5}=\dfrac{-6}{2}=-3\)

    The slope of the line is \({\color{blue} -3}\), so the m in \(y=mx+b\) is \({\color{blue} -3}\).

    Step 2: Use the slope and one of the points to find the y-intercept b:

    It doesn’t matter which point you use. They will both give you the same value for b since they are on the same line. In this example, choose the point \(\left ( {\color{Green} -3},{\color{Red} 4} \right )\). Input the slope, \({\color{blue} -3}\), and the point into \(y=mx+b\) to get the equation of the line:

    \({\color{Red} 4}={\color{blue} -3}\left ( {\color{Green} -3} \right )+\text{b}\)

    Simplify:

    \(4 = 9 + b\)

    Then subtract 9 from both sides:

    \(4 − 9 = 9 + b − 9\)

    \({\color{Red} -5}=\text{b}\)

    Step 3: Input the slope (m=\({\color{blue} -3}\)), and the y-intercept (b= \({\color{Red} -5}\)), into \(y=mx+b\):

    \(\text{y}={\color{blue} -3}{\text{x}}-{\color{Red} 5}\)
    )
  2. \(\left ( -5,-26 \right )\) and \(\left ( -2,-8 \right )\) (
    Solution
    x
    Solution: \({\text{y}}=6{\text{x}}+4\)
    )
  3. \(\left ( -4,-22 \right )\) and \(\left ( -6,-34 \right )\) (
    Solution
    x
    Solution: \({\text{y}}=6{\text{x}}+2\)

    Details:

    Step 1: Find the slope using the formula:

    \(\displaystyle{\text{Slope}}={\text{m}}=\frac{\text{rise}}{\text{run}}=\frac{{\text{y}}_2-{\text{y}}_1}{{\text{x}}_2-{\text{x}}_1}\)

    You have two points, \(\left ( -4,-22 \right )\) and \(\left ( -6,-34 \right )\). In this example, choose \(\left ( {\color{blue} -4},{\color{blue} -22} \right )\) as point one and \(\left ( {\color{Red} -6},{\color{Red} -34} \right )\) as point two. (It does not matter which is point one and which is point two as long as you stay consistent throughout the calculations.) Input the points into the formula for slope:

    \(\displaystyle\frac{{\text{y}}_2-{\text{y}}_1}{{\text{x}}_2-{\text{x}}_1}=\frac{{\color{Red}-34}-({\color{blue}-22})}{{\color{Red}-6}-({\color{blue}-4})}\)

    Simplify:

    \(\dfrac{-34-(-22)}{-6-(-4)}=\dfrac{-34+22}{-6+4}=\dfrac{-12}{-2}=6\)

    So the slope of the line is 6.

    Step 2: Use the slope and one of the points to find b.

    It doesn’t matter which point you use. They will both give you the same value for b since they are on the same line. In this example, choose the point \(\left ({\color{Green} -4}, {\color{Magenta} -22} \right )\). Input the slope, 6, and the point into \(y=mx+b\) to get the equation of the line.

    \({\color{Magenta} -22}={\color{Purple} 6}({\color{Green} -4})+\text{b}\)

    Simplify:

    \(-22=-24+\text{b}\)

    Then add 24 to both sides.

    \(-22{\color{Red} +24}=-24+\text{b}{\color{Red} +24}\)

    \(2 = b\)

    Step 3: Plug the slope \(m = 6\), and the y-intercept \(b = 2\), into \(y=mx+b\).

    \(y= 6x +2\)
    )
  4. \(\left ( 3,1 \right )\) and \(\left ( -6,-2 \right )\) (
    Solution
    x
    Solution: \({\text{y}}=\dfrac{1}{3}{\text{x}}\)
    )
  5. \(\left ( 4,-6 \right )\) and \(\left ( 6,3 \right )\) (
    Solution
    x
    Solution: \({\text{y}}=\dfrac{9}{2}{\text{x}}-24\)
    )
  6. \(\left ( 5,5 \right )\) and \(\left ( 3,2 \right )\) (
    Solution
    x
    Solution: \(\text{y}=\dfrac{3}{2}{\text{x}}{-}{\dfrac{5}{2}}\)
    )

Need More Help?


  1. Study other Math Lessons in the Resource Center.
  2. Visit the Online Tutoring Resources in the Resource Center.
  3. Contact your Instructor.
  4. If you still need help, Schedule a Tutor.