How quickly does a quantity change? A graph can answer that question more precisely than simply saying that it rises or falls: it can tell you how many miles, dollars, or items change for each unit of time or input. This is the second lesson of five in Linear Graphs, Slope, and Intercepts, and you will learn to calculate that rate.
In the first lesson, you recognized linear relationships by their constant behavior. Here, you will give that behavior a number—slope—using two points or a graph, then explain its sign, magnitude, and units. The goal is to make a slope meaningful, not just correctly computed.
What Slope Measures
To make slope intuitive, picture a ramp. A ramp that rises 1 foot while moving 12 feet forward has a rise-to-run ratio of 121; a line on a coordinate plane uses the same idea. For a straight line, this ratio is constant, so any two distinct points on the same line produce the same slope.
Mathematicians use m for slope:
m=runrise=change in xchange in y=ΔxΔy
In this formula, Δ means “change in.” The slope is defined for a nonvertical line because its horizontal change, Δx, must not be zero.
Rise and Run
To calculate the ratio, separate the movement into two parts. The vertical change is called the rise, and the horizontal change is called the run.
Term
Meaning
Coordinate form
Rise
Change in the vertical value, or y
Δy=y2−y1
Run
Change in the horizontal value, or x
Δx=x2−x1
Both changes are signed. If y increases, the rise is positive; if y decreases, the rise is negative; and if y stays the same, the rise is zero. The run can also be negative when the chosen point order moves from right to left.
Keeping rise and run separate prevents the common mistake of dividing horizontal change by vertical change. Once you identify both changes, slope is simply rise divided by run.
Calculating Slope from Two Points
With rise and run defined, you can calculate slope from any two distinct points on a nonvertical line. Let the points be (x1,y1) and (x2,y2), and use the same point order for both coordinates.
m=x2−x1y2−y1
Use this process:
Label one point as the first point and the other as the second point.
Subtract the first y-coordinate from the second y-coordinate.
Subtract the first x-coordinate from the second x-coordinate.
Divide the vertical change by the horizontal change and simplify.
Using (2,3) as the first point and (6,11) as the second point gives:
Δy=11−3=8,Δx=6−2=4
Therefore,
m=ΔxΔy=48=2
The slope is 2, so y increases by 2 units for every increase of 1 unit in x.
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal
The coordinates come in pairs, so whichever point you call first must be used first in both differences. If you reverse both points, both differences change sign and the final quotient stays the same.
For the same two points, reversing the order gives:
m=2−63−11=−4−8=2
Reversing only one subtraction would produce the wrong sign, such as 6−23−11=−2. When working from a graph, choosing the left point first usually keeps the run positive and makes the direction of the slope easier to interpret.
The same formula works when the points are shown on a graph. Choose two points that lie exactly on the line, preferably grid intersections, and read their coordinate values from the axis labels rather than estimating the line’s visual angle.
Suppose a graph passes through (1,6) and (4,3):
Moving from (1,6) to (4,3), the run is 4−1=3 and the rise is 3−6=−3. Therefore,
m=4−13−6=3−3=−1
For each 1-unit increase in x, y decreases by 1 unit. If the axis labels skip numbers or use different scales, use the coordinate changes rather than simply counting grid squares.
Once you calculate the number, its sign tells you the direction of change as x increases. The graph and the context should agree with that sign.
Value of m
Direction from left to right
Meaning
Positive, m>0
The line rises
y increases as x increases.
Negative, m<0
The line falls
y decreases as x increases.
Zero, m=0
The line is horizontal
y stays constant as x increases.
A negative slope does not mean that the relationship is invalid or that the values are “bad.” It simply means that the output decreases as the input increases; for example, a slope of −4 means that y falls by 4 units for every 1-unit increase in x.
The sign tells direction, but the magnitude tells how much the output changes. For a slope m, its magnitude is its absolute value, written as ∣m∣.
magnitude of slope=∣m∣
Compare m=−4 and m=21. The first line changes by 4 vertical units for every horizontal unit, while the second changes by only 21 vertical unit, so −4 has the greater magnitude. The first line falls and the second rises, but the magnitude compares how quickly they change without considering direction.
On axes with the same scale, a larger ∣m∣ generally appears steeper. However, when the horizontal and vertical scales differ, the visual angle can be misleading, so compare the numerical rate instead.
A slope becomes most useful when you attach units to it. Because slope is vertical change divided by horizontal change, the output units belong in the numerator and the input units belong in the denominator.
Suppose a travel graph includes the points (2 hours,120 miles) and (5 hours,300 miles). Its slope is:
m=5 hours−2 hours300 miles−120 miles=3 hours180 miles=60 miles per hour
The slope means that distance increases by 60 miles for every additional hour. Since the graph represents a linear relationship, this rate remains constant between the points.
Context
Input and output
Possible slope units
Wages
Hours worked and earnings
Dollars per hour
Travel
Time and distance
Miles per hour
Recurring cost
Months and total cost or balance
Dollars per month
Production
Days and items produced
Items per day
A complete interpretation should include the direction, amount, and units. For example, a slope of negative 5 dollars per month means that the output decreases by 5 dollars for each additional month.
Two special cases help distinguish a rate of zero from a rate that cannot be calculated. Both follow directly from the rise-over-run formula.
A horizontal line has no rise. For example, using (1,4) and (6,4):
m=6−14−4=50=0
The output stays constant as the input increases. A vertical line has no run; using (3,1) and (3,7) would give:
m=3−37−1=06undefined
Division by zero is undefined, so a vertical line has undefined slope rather than zero slope. Zero slope means there is no vertical change; undefined slope means there is no horizontal change.
You can now combine calculation and interpretation. Use the following routine whether the points come from a graph, a table, or written coordinates.
Choose two distinct points and record their coordinates and units.
Label one point first and the other second.
Calculate Δy and Δx using the same order.
If Δx=0, identify a vertical line with undefined slope; otherwise, calculate m=ΔxΔy.
Check the sign against the graph or situation, then state how much the output changes per input unit.
Before you practice, review the errors that most often interfere with an accurate slope calculation.
Common mistake
Better approach
Dividing run by rise
Use runrise=ΔxΔy.
Reversing only one subtraction
Use the same point order for both coordinates.
Choosing points that are not exactly on the line
Use clear grid intersections or labeled points.
Counting grid squares without reading axis labels
Use actual coordinate changes, especially when scales differ.
Treating a negative or fractional slope as an error
Interpret its sign and magnitude as a valid rate.
Confusing zero and undefined slope
Zero is horizontal; undefined is vertical.
Reporting only a number
Include the direction, amount, and units.
Confusing a point’s height with slope
A point shows location; slope shows how the line changes.
Use the graph or context as a final reasonableness check. If a line falls from left to right but your calculation gives a positive slope, revisit the subtraction order or the coordinates.
Slope is the constant rate of change of a nonvertical line, calculated as m=ΔxΔy. Its sign tells whether the output rises, falls, or stays constant; its magnitude tells how much changes per input unit; and its units make the statement meaningful.
In the practice activities, you will identify rise and run on seeded graphs, calculate positive, negative, fractional, and zero slopes from points, and apply the formula without a graph. You will then explain a wage, travel, or recurring-cost rate using its direction, amount, and compound units. Keep the point order consistent, and let the graph or context confirm your final interpretation.