MAT040 Beginning Algebra All classes

Lines and Graphing · Chapter 12

Finding the Equation of a Line

The numbered examples below are interactive: the numbers change every time you load the page. Type your answer, press Enter or Check, and use New numbers to practice again.

The physical sciences, social sciences and the business world are full of situations that can be modeled with linear equations relating two variables. If data points appear to form a straight line, the equation of that line can be used to predict the value of one variable from the value of the other. To build such a model we need to be able to find the equation of a line. The method we use depends on what information we are given.

Given the Slope and yy-Intercept

If we know the slope and yy-intercept, we substitute them into slope-intercept form, y=mx+by=mx+b.

Example 1

Find an equation of a line with slope −7-7 and yy-intercept (0,−1)(0,-1).

We are given the slope and yy-intercept, so substitute into y=mx+by=mx+b.

m=−7b=−1(the y-intercept is (0,−1))y=−7x+(−1)y=−7x−1\begin{align*} m&=-7\\ b&=-1\quad\text{(the $y$-intercept is $(0,-1)$)}\\ y&=-7x+(-1)\\ y&=-7x-1 \end{align*}

Sometimes the slope and intercept need to be read from a graph.

Example 2

Find the equation of the line shown.

Graph of a line on a coordinate grid. The line passes through (0, −4) and (3, −2). A red right triangle joins the two points: a horizontal run from (0, −4) to (3, −4), then a vertical rise up to (3, −2).

The yy-intercept is (0,−4)(0,-4) and the graph passes through (3,−2)(3,-2). Count the rise and run: the rise is 22 and the run is 33, so m=23m=\frac23. Substitute into y=mx+by=mx+b:

y=23x−4.y=\tfrac23x-4.

Point-Slope Form

What if we know the slope and a point that is not the yy-intercept? Suppose a line has slope mm and contains the point (x1,y1)(x_1,y_1), and let (x,y)(x,y) be any other point on the line. Write the slope of the line and rewrite it:

m=y−y1x−x1m(x−x1)=y−y1x−x1(x−x1)multiply both sides by x−x1m(x−x1)=y−y1y−y1=m(x−x1)\begin{align*} m&=\frac{y-y_1}{x-x_1}\\ m(x-x_1)&=\frac{y-y_1}{x-x_1}(x-x_1)&&\text{multiply both sides by }x-x_1\\ m(x-x_1)&=y-y_1\\ y-y_1&=m(x-x_1) \end{align*}

Point-Slope Form. The point-slope form of an equation of a line with slope mm and containing the point (x1,y1)(x_1,y_1) is

y−y1=m(x−x1).y-y_1=m(x-x_1).

We use point-slope form to find the equation of a line when we are given the slope and one point, and then rewrite the equation in slope-intercept form, which most applications use.

How to find an equation of a line given the slope and a point.
Step 1. Identify the slope.
Step 2. Identify the point.
Step 3. Substitute the values into the point-slope form y−y1=m(x−x1)y-y_1=m(x-x_1).
Step 4. Write the equation in slope-intercept form.

Example 3

Find an equation of a line with slope m=25m=\dfrac25 that contains the point (10,3)(10,3). Write the equation in slope-intercept form.

m=25,(x1,y1)=(10,3)y−y1=m(x−x1)y−3=25(x−10)y−3=25x−4distributey=25x−1add 3 to both sides\begin{align*} m&=\frac25,\qquad(x_1,y_1)=(10,3)\\ y-y_1&=m(x-x_1)\\ y-3&=\frac25(x-10)\\ y-3&=\frac25x-4&&\text{distribute}\\ y&=\frac25x-1&&\text{add $3$ to both sides} \end{align*}
Example 4

Find an equation of a line with slope m=−13m=-\dfrac13 that contains the point (6,−4)(6,-4). Write the equation in slope-intercept form.

m=−13,(x1,y1)=(6,−4)y−(−4)=−13(x−6)y+4=−13x+2distributey=−13x−2subtract 4 from both sides\begin{align*} m&=-\frac13,\qquad(x_1,y_1)=(6,-4)\\ y-(-4)&=-\frac13(x-6)\\ y+4&=-\frac13x+2&&\text{distribute}\\ y&=-\frac13x-2&&\text{subtract $4$ from both sides} \end{align*}
Example 5

Find an equation of a horizontal line that contains the point (−1,2)(-1,2). Write the equation in slope-intercept form.

Every horizontal line has slope 00, so m=0m=0 and (x1,y1)=(−1,2)(x_1,y_1)=(-1,2).

y−2=0(x−(−1))y−2=0(x+1)y−2=0y=2\begin{align*} y-2&=0(x-(-1))\\ y-2&=0(x+1)\\ y-2&=0\\ y&=2 \end{align*}

This is in yy-form, but it can also be written y=0x+2y=0x+2. It is the horizontal line y=ay=a with a=2a=2.

Given Two Points

When real-world data is collected, a linear model can be created from two data points. We have two options so far, slope-intercept or point-slope. Since we know two points, it makes more sense to use point-slope form. First we need the slope, which we find with the slope formula from the two points. Then we use the slope and one of the given points.

How to find an equation of a line given two points.
Step 1. Find the slope using the given points, m=y2−y1x2−x1m=\dfrac{y_2-y_1}{x_2-x_1}.
Step 2. Choose one point.
Step 3. Substitute the values into the point-slope form y−y1=m(x−x1)y-y_1=m(x-x_1).
Step 4. Write the equation in slope-intercept form.

Example 6

Find an equation of a line that contains the points (5,4)(5,4) and (3,6)(3,6). Write the equation in slope-intercept form.

Step 1. Find the slope: m=6−43−5=2−2=−1m=\dfrac{6-4}{3-5}=\dfrac2{-2}=-1.
Step 2. Choose one point, (x1,y1)=(5,4)(x_1,y_1)=(5,4).
Step 3. Substitute into point-slope form.

y−4=−1(x−5)y−4=−x+5distributey=−x+9add 4 to both sides\begin{align*} y-4&=-1(x-5)\\ y-4&=-x+5&&\text{distribute}\\ y&=-x+9&&\text{add $4$ to both sides} \end{align*}

Check: using the point (3,6)(3,6) gives y−6=−1(x−3)y-6=-1(x-3), so y−6=−x+3y-6=-x+3 and y=−x+9y=-x+9. The same equation.

Example 7

Find an equation of a line that contains the points (−3,−1)(-3,-1) and (2,−2)(2,-2). Write the equation in slope-intercept form.

Find the slope: m=−2−(−1)2−(−3)=−15=−15m=\dfrac{-2-(-1)}{2-(-3)}=\dfrac{-1}5=-\dfrac15.
Choose the point (2,−2)(2,-2).

y−(−2)=−15(x−2)y+2=−15x+25y=−15x+25−105y=−15x−85\begin{align*} y-(-2)&=-\frac15(x-2)\\ y+2&=-\frac15x+\frac25\\ y&=-\frac15x+\frac25-\frac{10}5\\ y&=-\frac15x-\frac85 \end{align*}
Example 8

Find an equation of a line that contains the points (−2,4)(-2,4) and (−2,−3)(-2,-3). Write the equation in slope-intercept form.

Find the slope: m=−3−4−2−(−2)=−70m=\dfrac{-3-4}{-2-(-2)}=\dfrac{-7}0, which is undefined. This tells us the line is vertical. Both points have an xx-coordinate of −2-2, so the equation of the line is x=−2x=-2. Since there is no yy, we cannot write it in slope-intercept form. (Sketching the two points confirms that this is a vertical line.)

Summary

Which form we use depends on the information we are given.

If givenUseForm
Slope and yy-interceptslope-intercept formy=mx+by=mx+b
Slope and a pointpoint-slope formy−y1=m(x−x1)y-y_1=m(x-x_1)
Two pointspoint-slope formy−y1=m(x−x1)y-y_1=m(x-x_1)

Worked-example videos

Adapted from OpenStax Elementary Algebra 2e, licensed under CC BY 4.0.