How to Find the Slope of a Line: Examples
This guide shows how to find the slope of a line in three ways: from two points with the slope formula, from a graph using rise over run, and from an equation in y = mx + b form. Clear worked examples cover positive, negative, zero and undefined slopes, so you can check your homework. The Derivative Calculator can also help you differentiate a function step by step.
Slope tells you how steep a line is: how much it goes up or down for every step to the right. In algebra class it's the m in y = mx + b. In real life it's a roof pitch, a wheelchair ramp, a driveway, or the grade on a highway sign. This guide shows you how to find slope from two points, from a graph and from an equation, what positive, negative, zero and undefined slopes mean, and how to turn slope into a percent grade or an angle for real U.S. projects.
The slope formula
Slope is rise over run: the change in y divided by the change in x.
m = (y₂ − y₁) ÷ (x₂ − x₁)
The order doesn't matter as long as you subtract both coordinates in the same order. If you start with y₂ on top, start with x₂ on the bottom.
How to find slope from two points (step by step)
- Label the points. Take (2, 3) and (6, 11). So x₁ = 2, y₁ = 3, x₂ = 6, y₂ = 11.
- Find the rise: y₂ − y₁ = 11 − 3 = 8.
- Find the run: x₂ − x₁ = 6 − 2 = 4.
- Divide: m = 8 ÷ 4 = 2. The line climbs 2 units for every 1 unit to the right.
Another example with a negative slope: (2, 7) and (5, 1) give m = (1 − 7) ÷ (5 − 2) = −6 ÷ 3 = −2. The line falls 2 units for every step to the right.
Finding the full equation of the line
Once you know the slope, find the y-intercept b by plugging one point into y = mx + b. For the first example, 3 = 2 × 2 + b, so b = −1 and the line is y = 2x − 1. To check, plug in the other point: 2 × 6 − 1 = 11. ✓
You can also write it in point-slope form: y − y₁ = m(x − x₁), which is y − 3 = 2(x − 2).
How to find slope from a graph
- Pick two points where the line crosses grid corners exactly, so you don't have to estimate.
- Count how many units you move up (positive) or down (negative) to get from the left point to the right point. That's the rise.
- Count how many units you move right. That's the run.
- Divide rise by run.
To see a line drawn from an equation, try the Graphing Calculator.
How to find slope from an equation
- Slope-intercept form, y = mx + b: the slope is the number in front of x. In y = −4x + 7, m = −4.
- Standard form, Ax + By = C: the slope is −A ÷ B. For 3x + 2y = 8, m = −3 ÷ 2 = −1.5. (Solve for y to check: y = −1.5x + 4.)
- Horizontal line, y = 5: slope 0.
- Vertical line, x = 4: slope undefined.
The four types of slope
| Type | What it looks like | Example |
|---|---|---|
| Positive | rises from left to right | m = 2 |
| Negative | falls from left to right | m = −2 |
| Zero | perfectly flat (horizontal) | y = 5 |
| Undefined | straight up and down (vertical); the run is 0, and you can't divide by 0 | x = 4 |
Parallel and perpendicular lines
Parallel lines have the same slope. Perpendicular lines have slopes that are negative reciprocals: flip the fraction and change the sign. A line perpendicular to one with slope 2/3 has slope −3/2. Multiply the two slopes and you always get −1 (except for horizontal and vertical lines).
Slope in the real world: grade, pitch and angle
Outside math class, slope is usually written in one of three ways:
- Percent grade = slope × 100. A driveway that drops 2 ft over 40 ft has a slope of 0.05, or a 5% grade. Highway signs use this format; a 6% grade is a steep stretch for trucks.
- Pitch (rise per 12 inches of run): roofers in the U.S. say a "6/12 roof," which means it rises 6 inches for every 12 inches across. That's a slope of 0.5 and an angle of about 26.6°. A 4/12 roof is about 18.4°, and 12/12 is 45°. The Roof Pitch Calculator converts between pitch, angle and rafter length.
- Angle in degrees = arctan(slope). Use the tan⁻¹ key on a scientific calculator. A slope of 1 is 45°.
Real U.S. examples
- Wheelchair ramps: the ADA Standards set a maximum running slope of 1:12 for ramps, which is about 8.33% or 4.8°. A ramp that rises 30 inches needs at least 30 × 12 = 360 inches (30 ft) of run, and 30 inches is also the most rise allowed before a level landing.
- Stairs: a common residential stair with a 7-inch rise and an 11-inch tread has a slope of about 0.64, around 32.5°. Plan risers and treads with the Stair Calculator.
- Drainage: patios and walkways are usually sloped slightly away from the house so water runs off. Ask your contractor or local code office for the exact minimum.
Slope, distance and midpoint
The same two points also give you the distance between them, √((x₂ − x₁)² + (y₂ − y₁)²), and the midpoint, ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). For (2, 3) and (6, 11), the distance is √80 ≈ 8.94 and the midpoint is (4, 7). See the Distance Calculator and Midpoint Calculator. For a best-fit line through many data points, use the Linear Regression Calculator.
Practice problems (answers below)
- Find the slope through (−1, 4) and (3, −4).
- Find the slope of the line 5x − y = 2.
- A ramp rises 18 inches over 20 feet of run. What is its percent grade, and does it meet the 1:12 ramp limit?
Answers: (1) (−4 − 4) ÷ (3 − (−1)) = −8 ÷ 4 = −2. (2) Rewrite as y = 5x − 2, so m = 5. (3) 20 ft = 240 in, so the slope is 18 ÷ 240 = 0.075, a 7.5% grade. That is less steep than 1:12 (8.33%), so it meets that limit.
Common mistakes
- Flipping rise and run: y goes on top, x on the bottom.
- Mixing the order: (y₂ − y₁) ÷ (x₁ − x₂) gives the wrong sign.
- Dropping negative signs when subtracting negative coordinates: 3 − (−2) = 5.
- Calling a vertical line "zero slope": vertical is undefined; horizontal is zero.
Tools used
- Slope Calculator
- Graphing Calculator
- Roof Pitch Calculator
- Stair Calculator
- Distance Calculator
- Midpoint Calculator
- Linear Regression Calculator
Toolverse is a free collection of online tools in one place: calculators, converters, PDF, image, text and developer tools. No signup required.
Frequently asked questions
How do you find the slope between two points?
Subtract the y-values and divide by the difference of the x-values: m = (y₂ − y₁) ÷ (x₂ − x₁). For (2, 3) and (6, 11), m = 8 ÷ 4 = 2.
What does a slope of 0 mean?
A slope of 0 means the line is horizontal. y stays the same no matter what x is, as in y = 5.
What is an undefined slope?
A vertical line has an undefined slope because the run (change in x) is 0, and division by zero is undefined. Its equation looks like x = 4.
How do you find the slope from an equation?
In y = mx + b, the slope is m. In standard form Ax + By = C, the slope is −A ÷ B.
How do I convert slope to a percent grade?
Multiply the slope by 100. A rise of 2 ft over 40 ft is a slope of 0.05, which is a 5% grade.
What slope is a 6/12 roof pitch?
A 6/12 pitch rises 6 inches per 12 inches of run, a slope of 0.5. That's an angle of about 26.6 degrees.
Find slope three ways
How to use it
- Pick two points on the line, (x₁, y₁) and (x₂, y₂).
- Subtract the y values to get the rise.
- Subtract the x values in the same order to get the run.
- Divide rise by run to get the slope m.
More questions
What is the slope of a horizontal line?
Zero, because the rise is 0.
What is the slope of a vertical line?
It is undefined, because the run is 0 and you cannot divide by zero.
How do I find slope from y = mx + b?
The number in front of x is the slope. In y = 3x + 2, the slope is 3.
Related tools: Slope Calculator, Graphing Calculator, Midpoint Calculator.