In the examples we have seen so far, we have had the slope provided for us. However, we often need to calculate the slope given input and output values. Given two values for the input, [latex]{x}_{1}[/latex] and [latex]{x}_{2}[/latex], and two corresponding values for the output, [latex]{y}_{1}[/latex] and [latex]{y}_{2}[/latex] which can be represented by a set of points, [latex]\left({x}_{1}\text{, }{y}_{1}\right)[/latex] and [latex]\left({x}_{2}\text{, }{y}_{2}\right)[/latex], we can calculate the slope [latex]m[/latex], as follows:
[latex]m=\dfrac{\text{change in output (rise)}}{\text{change in input (run)}}=\dfrac{\Delta y}{\Delta x}=\dfrac{{y}_{2}-{y}_{1}}{{x}_{2}-{x}_{1}}[/latex]
where [latex]\Delta y[/latex] is the change in output and [latex]\Delta x[/latex] is the change in input. In function notation, [latex]{y}_{1}=f\left({x}_{1}\right)[/latex] and [latex]{y}_{2}=f\left({x}_{2}\right)[/latex] so we could write:
The graph below indicates how the slope of the line between the points, [latex]\left({x}_{1,}{y}_{1}\right)[/latex] and [latex]\left({x}_{2,}{y}_{2}\right)[/latex], is calculated. Recall that the slope measures steepness. The greater the absolute value of the slope, the steeper the line is.
The slope of a function is calculated by the change in [latex]y[/latex] divided by the change in [latex]x[/latex].
It does not matter which coordinate is used as the [latex]\left({x}_{2,\text{ }}{y}_{2}\right)[/latex] and which is the [latex]\left({x}_{1},\text{ }{y}_{1}\right)[/latex],
as long as each calculation is started with the elements from the same coordinate pair.
You’ve just learned that slope is calculated as the change in the vertical distance (rise) divided by the change in the horizontal distance (run). A quick way to remember this is the phrase “Rise Over Run.”
When you’re looking at a graph, you can quickly identify two points and use “Rise Over Run” to calculate the slope right there. To do so pick two points on the line. Count how much you have to go up or down to get from one point to the other—that’s your rise. Then count how much you have to go left or right—that’s your run. The slope is simply the rise divided by the run.
If you go down instead of up, the rise will be negative. If you go left instead of right, the run will be negative. A negative slope means the line is going downhill as you read from left to right.
calculating slope
The slope, or rate of change, [latex]m[/latex], of a function can be calculated according to the following:
[latex]m=\dfrac{\text{change in output (rise)}}{\text{change in input (run)}}=\dfrac{\Delta y}{\Delta x}=\dfrac{{y}_{2}-{y}_{1}}{{x}_{2}-{x}_{1}} \Rightarrow \dfrac{f(x_2)-f(x_1)}{x_2 - x_1}[/latex]
where [latex]{x_1}[/latex] and [latex]x_2[/latex] are input values and [latex]{f(x_1)}[/latex] and [latex]f(x_2)[/latex] are output values.
How To: Given two points from a linear function, calculate and interpret the slope.
Determine the units for output and input values.
Calculate the change of output values and change of input values.
Interpret the slope as the change in output values per unit of the input value.
If [latex]f\left(x\right)[/latex] is a linear function and [latex]\left(3,-2\right)[/latex] and [latex]\left(8,1\right)[/latex] are points on the line, find the slope. Is this function increasing or decreasing?
The coordinate pairs are [latex]\left(3,-2\right)[/latex] and [latex]\left(8,1\right)[/latex]. To find the rate of change, we divide the change in output by the change in input.
[latex]m=\frac{\text{change in output}}{\text{change in input}}=\frac{1-\left(-2\right)}{8 - 3}=\frac{3}{5}[/latex]
We could also write the slope as [latex]m=0.6[/latex]. The function is increasing because [latex]m>0[/latex].
Analysis of the Solution
As noted earlier, the order in which we write the points does not matter when we compute the slope of the line as long as the first output value or [latex]y[/latex]-coordinate used corresponds with the first input value or [latex]x[/latex]-coordinate used.
When interpreting slope as an average rate of change, it is customary to express the calculation as change in output per unit of input. Ex. A vehicle traveled from mile marker [latex]57[/latex] to mile marker [latex]180[/latex] between 4:15 pm and 6:21 pm. Can you use the formula for slope to find the vehicle’s average rate of change in distance as a function of the time it traveled?
Time is usually considered the input variable. We say that distance traveled depends on the amount of time spent traveling at a constant rate. But we can calculate an average rate traveled over the entire time traveled using the formula for slope. The average rate of speed will be calculated by the total distance over the total time traveled.
[latex]\dfrac{\text{change in distance}}{\text{change in time}} = \dfrac{180\text{ miles}-57\text{ miles}}{6.35\text{ hours} - 4.15\text{ hours}} = \dfrac{123\text{ miles}}{2.1\text{ hours}} = \dfrac{123}{2.1}\text{ miles per hour} \approx 58.6 \text{ mph}[/latex]
Q&A
Are the units for slope always [latex]\frac{\text{units for the output}}{\text{units for the input}}[/latex] ?
Yes. Think of the units as the change of output value for each unit of change in input value. An example of slope could be miles per hour or dollars per day. Notice the units appear as a ratio of units for the output per units for the input.
The population of a city increased from [latex]23,400[/latex] to [latex]27,800[/latex] between 2008 and 2012. Find the change in population per year if we assume the change was constant from 2008 to 2012.
The rate of change relates the change in population to the change in time. The population increased by [latex]27,800-23,400=4400[/latex] people over the four-year time interval. To find the rate of change, divide the change in the number of people by the number of years.
So the population increased by [latex]1,100[/latex] people per year.
Analysis of the Solution
Because we are told that the population increased, we would expect the slope to be positive. This positive slope we calculated is therefore reasonable.