Slope calculator
The slope of a line is its rise divided by its run: how far it goes up for each unit it goes across. Enter two points, a rise and a run, an angle or a percent grade, and the calculator gives the slope, the percent slope, the angle in degrees, the 1-in-n ratio and, from two points, the equation y = mx + b.
Show the working, step by step
Find the rise and the run.
rise = y₂ − y₁ = 4 − 1 = 3 run = x₂ − x₁ = 6 − 2 = 4
Divide rise by run.
m = 3 ÷ 4 = 3/4
Percent grade is the slope times 100; the angle is the inverse tangent of the slope.
grade = 3/4 × 100 = 75% θ = arctan(3/4) = 36.8699°
Put the slope and one point in y = mx + b to find b.
b = y₁ − m·x₁ = 1 − 3/4 × 2 = −1/2 y = 0.75x − 0.5
The slope formula: rise over run
m = rise ÷ run = (y₂ − y₁) ÷ (x₂ − x₁)
The run is the horizontal change between two points and the rise is the vertical change. The same number can be written four ways, and the calculator converts between them:
| Form | Formula | Example for m = 3/4 |
|---|---|---|
| Gradient | m = rise ÷ run | 0.75 |
| Percent slope | m × 100 | 75% |
| Angle | θ = arctan(m) | 36.8699° |
| Ratio | 1 in 1/m | 1 in 1.3333 |
Worked example: two points
The calculator starts with the points (2, 1) and (6, 4).
- Rise: y₂ − y₁ = 4 − 1 = 3. Run: x₂ − x₁ = 6 − 2 = 4.
- Slope: m = 3 ÷ 4 = 0.75.
- Percent slope: 0.75 × 100 = 75%.
- Angle: arctan(0.75) = 36.8699°.
- Intercept: b = y₁ − m·x₁ = 1 − 0.75 × 2 = −0.5, so the line is y = 0.75x − 0.5.
Check with the second point: 0.75 × 6 − 0.5 = 4, which is y₂. For the full menu of line forms (point-slope, general, intercept) use the straight line equation calculator.
How to calculate percent of slope
Percent slope, also called percent grade, is the rise per 100 units of run. A ramp that rises 30 cm over a 360 cm run has a slope of 30 ÷ 360 = 1/12, a percent grade of 8.33333% and an angle of 4.76364°. A road that rises 4 m over 50 m of horizontal distance is 4 ÷ 50 × 100 = 8%. In the other direction, the rise for a given run is rise = grade ÷ 100 × run, so 8% over 50 m is 4 m.
Percent slope and angle are not proportional. 45° is a 100% grade, and 60° is already a 173% grade; the percent keeps climbing without limit as the line approaches vertical, while the angle tops out at 90°.
Slope and angle
m = tan θ θ = arctan(m)
The angle is measured from the horizontal. A negative slope gives a negative angle, for example (0, 3) to (3, 0) has slope −1 and angle −45° (the line falls). For the right triangle behind this, with sides and hypotenuse, see the tangent calculator.
Common mistakes
- Subtracting in different orders. y₂ − y₁ over x₁ − x₂ gives the wrong sign. Keep the order the same on top and bottom.
- Run over rise. Slope is rise ÷ run. Run ÷ rise is its reciprocal.
- Mixed units. Percent grade needs rise and run in the same unit (metres and metres, not centimetres and metres).
- Treating a vertical line as having slope 0. A horizontal line has slope 0; a vertical line has an undefined slope.
- Reading 100% as vertical. A 100% grade is 45°.
For a curve rather than a straight line, the slope changes from point to point; the linear approximation calculator finds the slope at one point and uses it to estimate nearby values.
Common questions
How do you calculate the slope of a line from two points?
Subtract the coordinates and divide: m = (y₂ − y₁) ÷ (x₂ − x₁). For (2, 1) and (6, 4)
the rise is 4 − 1 = 3 and the run is 6 − 2 = 4, so m = 3/4 = 0.75. Subtract in the same order on top and
bottom: swapping only one of the two flips the sign.
How do you find rise and run on a graph?
Pick two points where the line crosses grid corners. The run is how many squares you move right to get from the first to the second, and the rise is how many you then move up (down counts as negative). Their ratio, rise ÷ run, is the slope. If the line goes up as you move right the rise is positive; if it goes down the rise is negative.
How do you calculate percent slope (percent grade)?
Divide the rise by the run and multiply by 100: grade % = rise ÷ run × 100. A road that
climbs 4 m over a horizontal distance of 50 m has a grade of 4 ÷ 50 × 100 = 8%. To go the other way, divide the
percent by 100: an 8% slope is m = 0.08. Both rise and run must be in the same unit.
How do you convert a slope to an angle in degrees?
Take the inverse tangent of the slope: θ = arctan(m). A slope of 3/4 gives
arctan(0.75) = 36.87°, and a slope of 1 gives 45°. Going back, m = tan θ. A 100% grade is a
45° angle, not a vertical wall: a vertical line would need an infinite grade.
Why is the slope of a vertical line undefined?
On a vertical line both points have the same x, so the run is 0 and the slope formula divides by zero. The line is written x = a, not y = mx + b, and it makes a 90° angle with the horizontal. A horizontal line is different: its rise is 0, so its slope is 0.
Related calculators
-
Straight line equation calculator
The equation of a line in slope-intercept, point-slope and general form.
-
Line calculator
Where two lines meet, the angle between them and point-to-line distance.
-
Distance and midpoint calculator
Distance, midpoint and slope between two points.
-
Tangent calculator
The angle of a slope or ramp, and tan θ, with the right triangle.
-
Linear regression calculator
The best-fit slope through many points, not just two.
-
Linear approximation calculator
The slope of a curve at a point, used as a tangent-line estimate.