Skip to main content
Mathematics LibreTexts

13.2.2: Writing the Equation of a Line

  • Page ID
    70404
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)
    Learning Objectives
    • Find the slope and the y-intercept, and write an equation of the line.
    • Given the slope and a point on the line, write an equation of the line.
    • Given two points, write the equation of a line.

    Introduction

    The concept of slope is important to understand because it is often used to measure the rate at which changes are taking place.

    Slope-intercept Form

    A linear equation can be expressed in the form \(\ y=m x+b\). In this equation, \(\ x\) and \(\ y\) are coordinates of a point, \(\ m\) is the slope, and \(\ b\) is the y-coordinate of the y-intercept. Because this equation describes a line in terms of its slope and its y-intercept, this equation is called the slope-intercept form. When working with linear relationships, the slope-intercept form helps to translate between the graph of a line and the equation of a line.

    Changing the value of \(\ m\) in a linear equation changes the slope of the line. If \(\ m\) is positive, the line slopes up as you move from left to right. If \(\ m\) is negative, the line slopes down as you move from left to right. If \(\ m\) is zero, the line is horizontal.

    When \(\ m\) is positive, as \(\ m\) gets larger the upward slope of the line gets steeper. When the value of \(\ m\) gets close to zero, the upward slope flattens.

    When \(\ m\) is negative, as the absolute value of \(\ m\) gets larger the downward slope of the line gets steeper. When the absolute value of \(\ m\) gets close to zero, the downward slope flattens.

    Changing the value of \(\ b\) (the y-intercept) in a linear equation moves the line up and down on the coordinate plane. A positive y-intercept means the line crosses the y-axis above the origin. The larger the value of \(\ b\), the higher up it crosses the y-axis. A negative y-intercept means that the line crosses below the origin. The larger the absolute value of \(\ b\), the farther down it crosses the y-axis.

    Simply by changing the values of \(\ m\) and \(\ b\) in a linear equation, you can define any line. That’s how powerful and versatile the slope-intercept formula is.

    Supplemental Interactive Activity

    The graph below represents any line that can be written in slope-intercept form. It has two slider bars that can be manipulated. The bar labeled \(\ m\) lets you adjust the slope, or steepness, of the line. The bar labeled \(\ b\) changes the y-intercept. Try sliding each bar back and forth, and see how that affects the line.

    Screen Shot 2021-06-25 at 9.01.05 AM.png

    Now that you understand the slope-intercept form, you can look at the graph of a line and write its equation just by identifying the slope and the y-intercept from the graph. Let’s try it with the line in this graph.

    Screen Shot 2021-06-25 at 9.05.33 AM.png

    For this line, the slope is \(\ \frac{4}{5}\), and the y-intercept is 4. If you put those values into the slope-intercept form, \(\ y=m x+b\), you get the equation \(\ y=\frac{4}{5} x+4\).

    Example

    Write the equation of the line that has a slope of \(\ \frac{1}{2}\) and a y-intercept of -5.

    Solution

    \(\ y=\frac{1}{2} x+b\) Substitute the slope (\(\ m\)) into \(\ y=m x+b\).
    \(\ y=\frac{1}{2} x+(-5)\) or \(\ y=\frac{1}{2}-5\) Substitute the y-intercept \(\ (b)\) into the equation.

    If you know the slope of a line and a point on the line, you can draw a graph. So, using an equation in the point-slope form, you can easily identify the slope and a point. Consider the equation \(\ y=-3 x-1\). You can tell from this equation that the y-intercept is at (0, -1). Start by plotting that point, (0, -1), on a graph.

    You can also tell from the equation that the slope of this line is -3. So start at (0, -1) and count up 3 and over -1 (1 unit in the negative direction, left) and plot a second point. (You could also have gone down 3 and over 1.) Then draw a line through both points, and there it is, the graph of \(\ y=-3 x-1\).

    Screen Shot 2021-06-25 at 9.14.53 AM.png

    Exercise

    What is the equation of a line that has a slope of -2 and goes through the point (0, 8)?

    1. \(\ y=-2 x+8\)
    2. \(\ y=8 x-2\)
    3. \(\ y=-2 x+0\)
    4. \(\ 0=8 x-2\)
    Answer
    1. Correct. The point (0, 8) is also the y-intercept of the line, so \(\ b=8\). The slope, \(\ m\), is -2. Substituting these values into the equation \(\ y=m x+b\), you find \(\ y=-2 x+8\).
    2. Incorrect. Remember that in the slope-intercept form of an equation, \(\ y=m x+b\), \(\ m=\text { slope }\) and \(\ b=\) the y-value of the y-intercept. The correct choice is \(\ y=-2 x+8\).
    3. Incorrect. Remember that in the slope-intercept form of an equation, \(\ y=m x+b\), \(\ b=\) the y-value (not the x-value!) of the y-intercept. The correct choice is \(\ y=-2 x+8\).
    4. Incorrect. Remember that in the slope-intercept form of an equation, \(\ y=m x+b\), \(\ m=\) slope and \(\ b=\) the y-value of the y-intercept. The correct choice is \(\ y=-2 x+8\).

    Slope and a Point on the Line

    Using slope-intercept form to help write the equation of a line is possible when you know both the slope \(\ (m)\) and the y-intercept \(\ (b)\), but what if you know the slope and just any point on the line, not specifically the y-intercept? Can you still write the equation? The answer is yes, but you will need to put in a little more thought and work than you did previously.

    Recall that a point is an \(\ (x, y)\) coordinate pair and that all points on the line will satisfy the linear equation. So, if you have a point on the line, it must be a solution to the equation. Although you don’t know the exact equation yet, you know that you can express the line in slope-intercept form, \(\ y=m x+b\).

    You do know the slope \(\ (m)\), but you just don’t know the value of the y-intercept \(\ (b)\). Since point \(\ (x, y)\) is a solution to the equation, you can substitute its coordinates for \(\ x\) and \(\ y\) in \(\ y=m x+b\) and solve to find \(\ b\)!

    This may seem a bit confusing with all the variables, but an example with an actual slope and a point will help to clarify.

    Example

    Write the equation of the line that has a slope of 3 and contains the point (1, 4).

    Solution

    \(\ y=3 x+b\) Substitute the slope \(\ (m)\) into \(\ y=m x+b\).
    \(\ 4=3(1)+b\) Substitute the point (1, 4) for \(\ x\) and \(\ y\).
    \(\ \begin{array}{c}
    4=3+b \\
    1=b
    \end{array}\)
    Solve for \(\ b\).
    \(\ y=3 x+1\) Rewrite \(\ y=m x+b\) with \(\ m=3\) and \(\ b=1\).

    To confirm our algebra, you can check by graphing the equation \(\ y=3 x+1\). The equation checks because when graphed, it passes through the point (1, 4).

    Screen Shot 2021-06-25 at 9.46.55 AM.png

    Advanced Example

    Write the equation of the line that has a slope of \(\ -\frac{7}{8}\) and contains the point \(\ \left(4, \frac{5}{4}\right)\).

    Solution

    \(\ \begin{aligned}
    y&=m x+b \\
    y&=-\frac{7}{8} x+b
    \end{aligned}\)
    Substitute the slope \(\ (m)\) into \(\ y=m x+b\).
    \(\ \frac{5}{4}=-\frac{7}{8}(4)+b\) Substitute the point \(\ \left(4, \frac{5}{4}\right)\) for \(\ x\) and \(\ y\).
    \(\ \begin{array}{r}
    \frac{5}{4}=-\frac{28}{8}+b \\
    \frac{5}{4}=-\frac{14}{4}+b \\
    \frac{5}{4}+\frac{14}{4}=-\frac{14}{4}+\frac{14}{4}+b \\
    \frac{19}{4}=b
    \end{array}\)
    Solve for \(\ b\).
    \(\ y=-\frac{7}{8} x+\frac{19}{4}\) Rewrite \(\ y=m x+b\) with \(\ m=-\frac{7}{8}\) and \(\ b=\frac{19}{4}\).
    Exercise

    Write the slope-intercept form of the line with a slope of \(\ \frac{2}{3}\) and which contains the point \(\ (9,4)\).

    1. \(\ y=-2 x+\frac{2}{3}\)
    2. \(\ y=\frac{2}{3} x-2\)
    3. \(\ y=\frac{2}{3} x+10\)
    4. \(\ y=\frac{2}{3} x+\frac{19}{3}\)
    Answer
    1. Incorrect. You solved correctly for the y-intercept but you have used the slope for the y-intercept and the y-intercept for the slope when plugging back into \(\ y=m x+b\). The correct answer is \(\ y=\frac{2}{3} x-2\).
    2. Correct. The slope of this line is \(\ \frac{2}{3}\) and the y-intercept is -2.
    3. Incorrect. Check your algebra when you solved for \(\ b\). To find \(\ b\), substitute the known values for \(\ x\), \(\ y\), and \(\ m\) into the slope-intercept form. This gives you \(\ 4=\frac{2}{3}(9)+b\), which simplifies to \(\ 4=6+b\), so \(\ b=-2\). The correct answer is \(\ y=\frac{2}{3} x-2\).
    4. Incorrect. When solving for \(\ b\), you used the 9 as the y-coordinate and 4 as the x-coordinate. To find \(\ b\), substitute the known values for \(\ x\), \(\ y\), and \(\ m\) into the slope-intercept form. This gives you \(\ 4=\frac{2}{3}(9)+b\), which simplifies to \(\ 4=6+b\), so \(\ b=-2\). The correct answer is \(\ y=\frac{2}{3} x-2\).
    Advanced Question

    Write the slope-intercept form of the line with a slope of -0.6 and which contains the point (3.8, 7.25).

    1. \(\ y=-0.6 x+3.8\)
    2. \(\ y=-0.6 x+4.97\)
    3. \(\ y=3.8 x+7.25\)
    4. \(\ y=-0.6 x+9.53\)
    Answer
    1. Incorrect. The value for \(\ m\) is correct in this equation, but the value for \(\ b\) is not. Try substituting \(\ (3.8,7.25)\) into the equation \(\ y=-0.6 x+b\) and solve for \(\ b\). The correct answer is \(\ y=-0.6 x+9.53\).
    2. Incorrect. It looks like you subtracted \(\ 7.25-2.28\) to arrive at a \(\ b \text {-value }\) of 4.97. Check the + and - signs in the problem again. The correct answer is \(\ y=-0.6 x+9.53\).
    3. Incorrect. The value for \(\ m\) is incorrect; remember that \(\ m\) represents the slope. The correct answer is \(\ y=-0.6 x+9.53\).
    4. Correct. Substituting \(\ (3.8,7.25)\) into the equation \(\ y=-0.6 x+b\), you found \(\ b=9.53\). This means the equation of the line is \(\ y=-0.6 x+9.53\).

    Two Points on the Line

    Let’s suppose you don’t know either the slope or the y-intercept, but you do know the location of two points on the line. It is more challenging, but you can find the equation of the line that would pass through those two points. You will again use slope-intercept form to help you.

    The slope of a linear equation is always the same, no matter which two points you use to find the slope. Since you have two points, you can use those points to find the slope \(\ (m)\). Now you have the slope and a point on the line! You can now substitute values for \(\ m\), \(\ x\), and \(\ y\) into the equation \(\ y=m x+b\) and find \(\ b\).

    Example

    Write the equation of the line that passes through the points (2, 1) and (-1, -5).

    Solution

    \(\ \frac{1-(-5)}{2-(-1)}=\frac{6}{3}=2\) Find the slope using the given points.
    \(\ y=2 x+b\) Substitute the slope \(\ (m)\) into \(\ y=m x+b\).
    \(\ 1=2(2)+b\) Substitute the coordinates of either point for \(\ x\) and \(\ y\)- this example uses \(\ (2,1)\).
    \(\ \begin{aligned}
    1&=4+b \\
    -3&=b
    \end{aligned}\)
    Solve for \(\ b\).
    \(\ \begin{aligned}
    y&=2 x+(-3), \text { or } \\
    y&=2 x-3
    \end{aligned}\)
    Rewrite \(\ y=m x+b\) with \(\ m=2\) and \(\ b=-3\).

    Notice that it doesn’t matter which point you use when you substitute and solve for \(\ b\)-you get the same result for \(\ b\) either way. In the example above, you substituted the coordinates of the point \(\ (2,1)\) in the equation \(\ y=2 x+b\). Let’s start with the same equation, \(\ y=2 x+b\), but substitute in \(\ (-1,-5)\):

    \(\ \begin{aligned}
    y&=2 x+b \\
    -5&=2(-1)+b \\
    -5&=-2+b \\
    -3&=b
    \end{aligned}\)

    The final equation is the same: \(\ y=2 x-3\).

    Advanced Example

    Write the equation of the line that passes through the points \(\ (-4.6,6.45)\) and \(\ (1.15,7.6)\).

    Solution

    \(\ \frac{7.6-6.45}{1.15-(-4.6)}=\frac{1.15}{5.75}=0.2\) Find the slope using the given points.
    \(\ y=0.2 x+b\) Substitute the slope \(\ (m)\) into \(\ y=m x+b\).
    \(\ \begin{aligned}
    7.6 &=0.2(1.15)+b \\
    7.6 &=0.23+b \\
    7.6-0.23 &=0.23-0.23+b \\
    7.37 &=b
    \end{aligned}\)
    Substitute either point for \(\ x\) and \(\ y\). This example uses \(\ (1.15,7.6)\). Then solve for \(\ b\).
    \(\ y=0.2 x+7.37\) Rewrite \(\ y=m x+b\) with \(\ m=0.2\) and \(\ b=7.37\).

    The equation of the line that passes through the points \(\ (-4.6,6.45)\) and \(\ (1.15,7.6)\) is \(\ y=0.2 x+7.37\).

    Exercise

    Write the slope-intercept form of the line that passes through \(\ (5,2)\) and \(\ (-1,-10)\).

    1. \(\ y=2 x+12\)
    2. \(\ y=\frac{1}{2} x-\frac{7}{2}\)
    3. \(\ y=2 x-8\)
    4. \(\ y=2 x+1\)
    Answer
    1. Incorrect. The slope \(\ (m=2)\) is correct, but check your algebra when you solved for \(\ b\). Substitute \(\ m=2\), \(\ x=5\), and \(\ y=2\) into the equation \(\ y=m x+b\) to find \(\ b\): \(\ 2=2(5)+b\), so \(\ 2=10+b\), so \(\ b=-8\). The correct answer is \(\ y=2 x-8\).
    2. Incorrect. It looks like you wrote the slope as \(\ \frac{\text { run }}{\text { rise }}\) instead of \(\ \frac{\text { rise }}{\text { run }}\). The correct answer is \(\ y=2 x-8\).
    3. Correct. Find the slope \(\ \frac{\text{rise}}{\text{run}}=\frac{-10-2}{-1-5}=\frac{-12}{-6}=2\). Then use the slope and one of the points to find the value of \(\ b\).
    4. Incorrect. Make sure that you substitute the x-coordinate of the point for the \(\ x\) variable and the y-coordinate for the \(\ y\) variable of \(\ y=m x+b\) when solving for \(\ b\). The correct answer is \(\ y=2 x-8\).
    Advanced Question

    Which of the following lines goes through the points \(\ \left(\frac{3}{2},-4\right)\) and \(\ \left(\frac{7}{4},-2\right)\)?

    1. \(\ y=\frac{1}{2} x-\frac{3}{4}\)
    2. \(\ y=8 x-16\)
    3. \(\ y=\frac{1}{2} x+16\)
    4. \(\ y=8 x-\frac{3}{4}\)
    Answer
    1. Incorrect. To find the slope of the line, use the formula \(\ m=\frac{y_{2}-y_{1}}{x_{2}-x_{1}}\). Then substitute the slope in for \(\ m\) in the equation \(\ y=m x+b\) and solve for \(\ b\). The answer is \(\ y=8 x-16\).
    2. Correct. The slope of the line that these points lie upon is 8, and substituting either of the points into the equation \(\ y=8 x+b\) yields \(\ b=-16\).
    3. Incorrect. Try calculating the slope again using the formula \(\ m=\frac{y_{2}-y_{1}}{x_{2}-x_{1}}\). When you find the slope, use it (and one of the given points) to find the value of \(\ b\). The correct answer is \(\ y=8 x-16\).
    4. Incorrect. You have found the correct slope, but the value of \(\ b\) is incorrect. Try substituting either \(\ \left(\frac{3}{2},-4\right)\) or \(\ \left(\frac{7}{4},-2\right)\) into the equation \(\ y=8 x+b\) to solve for \(\ b\). The correct answer is \(\ y=8 x-16\).

    Summary

    The slope-intercept form of a linear equation is written as \(\ y=m x+b\), where \(\ m\) is the slope and \(\ b\) is the value of \(\ y\) at the y-intercept, which can be written as \(\ (0, b)\). When you know the slope and the y-intercept of a line, you can use the slope-intercept form to immediately write the equation of that line. The slope-intercept form can also help you to write the equation of a line when you know the slope and a point on the line or when you know two points on the line.


    This page titled 13.2.2: Writing the Equation of a Line is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by The NROC Project via source content that was edited to the style and standards of the LibreTexts platform.