Slope tells you how steep a line is and in which direction it goes. In algebra it is the rise divided by the run, in construction it is the pitch of a roof or a ramp, and in data analysis it is the rate at which one quantity changes with another. The calculation needs only two points and a short formula. This guide explains the slope formula, walks through worked examples with positive, negative, zero and undefined slopes, shows how to convert slope to percent grade and angle, how to write the equation of a line and how to find slope in Excel.
Updated November 2026
In this guide
- What slope means
- The slope formula
- Step-by-step method
- Worked example 1: a positive slope
- Worked example 2: a negative slope
- Zero and undefined slopes
- Summary table of slope types
- The equation of a line from the slope
- Parallel and perpendicular lines
- Slope as percent grade, pitch and angle
- Calculate slope in Excel and Google Sheets
- Practice problems with answers
- Common mistakes
What slope means
The slope of a line measures how much the vertical value (y) changes for each unit of change in the horizontal value (x). A slope of 2 means that y rises 2 units whenever x increases by 1. A slope of minus 3 means y falls 3 units for every 1 unit that x increases. The letter m is the usual symbol for slope. Slope is constant along a straight line, which is why any two points on the line give the same answer. For a quick check, use our rate of change calculator.

The slope formula
For two points (x1, y1) and (x2, y2), the slope is m equals (y2 minus y1) divided by (x2 minus x1). The top is the rise, or vertical change, and the bottom is the run, or horizontal change. It does not matter which point you call first, as long as you use the same order on top and bottom. If you subtract in the order y2 minus y1 on top and x1 minus x2 on the bottom, the sign flips and the answer is wrong, which is the most common slip.
Step-by-step method
- Write down the two points and label them (x1, y1) and (x2, y2).
- Subtract the y-values: y2 minus y1.
- Subtract the x-values in the same order: x2 minus x1.
- Divide the rise by the run.
- Simplify the fraction or convert it to a decimal, and check the sign against the picture of the line.
Worked example 1: a positive slope
Find the slope through (2, 3) and (6, 11). The rise is 11 minus 3, which is 8. The run is 6 minus 2, which is 4. The slope is 8 divided by 4, which is 2. The line goes up as you move right, and each step right of 1 raises it by 2. Check with the points reversed: (6 minus 2) on the bottom and (3 minus 11) on top gives minus 8 divided by minus 4, which is also 2.
Worked example 2: a negative slope
Find the slope through (1, 9) and (5, 3). The rise is 3 minus 9, which is minus 6. The run is 5 minus 1, which is 4. The slope is minus 6 divided by 4, which is minus 1.5. The line falls as you move to the right, by 1.5 units for each unit of x. A negative slope appears in many real situations, such as a car losing value or a phone battery draining over time.
Zero and undefined slopes
A horizontal line has a rise of zero, so its slope is zero. For points (2, 5) and (9, 5), the rise is 5 minus 5, which is 0, the run is 7, and 0 divided by 7 is 0. A vertical line has a run of zero, so its slope is undefined, because you cannot divide by zero. For points (4, 1) and (4, 8), the run is 4 minus 4, which is 0, and the slope is 7 divided by 0, which is undefined. Do not call a vertical slope infinity in most math classes, say undefined.
Summary table of slope types
The table below summarizes the four cases.
| Slope | Direction of the line | Example points |
|---|---|---|
| Positive | Rises left to right | (2,3) and (6,11): m = 2 |
| Negative | Falls left to right | (1,9) and (5,3): m = -1.5 |
| Zero | Horizontal | (2,5) and (9,5): m = 0 |
| Undefined | Vertical | (4,1) and (4,8): no slope |
The equation of a line from the slope
Once you know the slope, you can write the equation y equals mx plus b, where b is the y-intercept. Using the first example, m is 2 and the line passes through (2, 3). Substitute: 3 equals 2 times 2 plus b, so b is 3 minus 4, which is minus 1. The equation is y equals 2x minus 1. Check with the second point: 2 times 6 minus 1 is 11, which matches. The point-slope form, y minus y1 equals m times (x minus x1), gives the same result without solving for b: y minus 3 equals 2 times (x minus 2), which simplifies to y equals 2x minus 1.
Parallel and perpendicular lines
Parallel lines have the same slope. A line with slope 2 is parallel to every other line with slope 2. Perpendicular lines have slopes that are negative reciprocals, meaning you flip the fraction and change the sign. If one line has slope 2, a perpendicular line has slope minus one half. If one line has slope minus 3 over 4, the perpendicular has slope 4 over 3. The product of perpendicular slopes is always minus 1, which gives a quick check: 2 times minus 0.5 is minus 1.
Slope as percent grade, pitch and angle
Percent grade is the slope times 100. A slope of 0.06 is a 6 percent grade, which means a rise of 6 feet for every 100 feet of horizontal distance. Roof pitch is stated as rise over 12 inches of run, so a 6/12 pitch has a slope of 0.5, which is a 50 percent grade. To find the angle of a line, use the arctangent: the angle equals the inverse tangent of the slope. A slope of 1 is 45 degrees. A slope of 2 is about 63.4 degrees, and a slope of 0.5 is about 26.6 degrees. Many accessibility guidelines use a ratio of 1 to 12, which is a slope of about 0.083 or 8.3 percent, for ramps. Always check local codes for exact limits.
Calculate slope in Excel and Google Sheets
With x-values in A2:A7 and y-values in B2:B7, use =SLOPE(B2:B7,A2:A7). Note the order: the y-values come first, then the x-values. For two points in cells, use =(D2-B2)/(C2-A2). To find the angle in degrees, use =DEGREES(ATAN(slope)). To get the intercept, use =INTERCEPT(B2:B7,A2:A7). SLOPE returns the slope of the best-fit line through many points, which is helpful for trends in sales or temperature data. For averages that go with trend lines, see Microsoft’s page on the AVERAGE function.
Practice problems with answers
Try these. Problem 1: points (1, 2) and (4, 11). Rise 9, run 3, slope 3. Problem 2: points (0, 8) and (4, 0). Rise minus 8, run 4, slope minus 2. Problem 3: points (3, 7) and (9, 7). Rise 0, slope 0. Problem 4: a ramp rises 2 feet over 24 feet. Slope is 2 divided by 24, which is 0.0833, or 8.33 percent. Problem 5: find the line through (0, 1) with slope 3. The equation is y equals 3x plus 1. Check each with the calculator once you have worked them by hand.
Common mistakes
The most common mistake is to mix up the order of subtraction on the top and bottom. Another is to divide run by rise instead of rise by run. A third is to forget the negative sign when the line goes down. A fourth is to treat a vertical line as slope zero, which is wrong because it is undefined. Finally, when you read slope from a graph, make sure the scales of the x and y axes are the same, since a different scale makes a line look steeper or flatter than it really is.
Frequently asked questions
What is the formula for slope?
Slope equals the change in y divided by the change in x, which is (y2 minus y1) divided by (x2 minus x1).
What is the slope of a horizontal line?
Zero.
What is the slope of a vertical line?
It is undefined because the run is zero.
How do I convert slope to percent?
Multiply the slope by 100. A slope of 0.08 is an 8 percent grade.
How do I find slope in Excel?
Use =SLOPE(known_y, known_x).
Related guides and free tools
- Rate of change calculator
- Unit rate calculator
- How to calculate percent change
- How many feet in a mile
- All free calculators
- All free calculators and templates
Sources: AVERAGE function, Microsoft Support


