What Is the Slope of a Line?
The slope (also called gradient) measures how steep a straight line is. It tells you how much the y-value changes for each unit the x-value increases. A positive slope rises from left to right; a negative slope falls. Slope is also a rate of change—in physics, the slope of a distance-time graph gives speed, and the slope of a velocity-time graph gives acceleration.
This calculator handles all four cases: positive, negative, zero (horizontal), and undefined (vertical). It also supports negative coordinates and shows the exact fraction when the slope is not a whole number.
Slope Formula
Given two points (x₁, y₁) and (x₂, y₂), the slope m is:
The numerator y₂ − y₁ is the rise (vertical change). The denominator x₂ − x₁ is the run (horizontal change). The order matters: if you subtract y₂ − y₁ on top, you must subtract x₂ − x₁ on the bottom. Mixing the order flips the sign of the slope.
When the slope is a fraction like a/b, the numerator a represents the vertical change and the denominator b represents the horizontal change. A slope of 3/4 means: go up 3, right 4.
How to Calculate Slope Step by Step
Follow these steps for any two points. The examples below mirror the types of questions students search for most often, including negative coordinates and special cases.
Example 1: Positive slope with negative coordinates
Find the slope of the line through (−9, −6) and (−4, 5).
- Identify: x₁ = −9, y₁ = −6, x₂ = −4, y₂ = 5.
- Rise: y₂ − y₁ = 5 − (−6) = 5 + 6 = 11.
- Run: x₂ − x₁ = −4 − (−9) = −4 + 9 = 5.
- Slope: m = 11 / 5 = 11/5 ≈ 2.2.
- The line rises steeply to the right.
Example 2: Negative slope with negative coordinates
Find the slope of the line through (0, −10) and (−4, −11).
- Rise: y₂ − y₁ = −11 − (−10) = −11 + 10 = −1.
- Run: x₂ − x₁ = −4 − 0 = −4.
- Slope: m = (−1) / (−4) = 1/4 = 0.25.
- Two negatives give a positive slope. The line rises gently.
Example 3: Vertical line (undefined slope)
Find the slope of the line through (0, −8) and (0, −10).
- Run: x₂ − x₁ = 0 − 0 = 0.
- Slope: m = (y₂ − y₁) / 0 → undefined.
- Division by zero is not defined. The line is vertical.
- Equation: x = 0 (the y-axis in this case).
Example 4: Horizontal line (zero slope)
Find the slope of the line through (1, 5) and (7, 5).
- Rise: y₂ − y₁ = 5 − 5 = 0.
- Run: x₂ − x₁ = 7 − 1 = 6.
- Slope: m = 0 / 6 = 0.
- Equation: y = 5. The line is horizontal.
Example 5: Fractional slope
Find the slope of the line through (2, 3) and (5, 11).
- Rise: 11 − 3 = 8.
- Run: 5 − 2 = 3.
- Slope: m = 8/3 ≈ 2.6667.
- Leave the answer as the fraction 8/3 for exactness.
Slope-Intercept Form
The slope-intercept form is \(y = mx + b\), where \(m\) is the slope and \(b\) is the y-intercept (the y-value where the line crosses the y-axis). This is the most convenient form for graphing: start at point (0, b), then use the slope to find the next point.
From Example 5 above, with m = 8/3 and point (2, 3): b = y − mx = 3 − (8/3)(2) = 3 − 16/3 = 9/3 − 16/3 = −7/3. The equation is \(y = \frac{8}{3}x - \frac{7}{3}\).
Point-Slope Form
The point-slope form is \(y - y_1 = m(x - x_1)\), where m is the slope and (x₁, y₁) is any point on the line. This form is useful when you know the slope and one point and need the equation quickly.
Using the points from Example 1: m = 11/5, point (−9, −6). The equation is:
Simplify: \(y + 6 = \frac{11}{5}(x + 9)\). To convert to slope-intercept form, solve for y: \(y = \frac{11}{5}x + \frac{99}{5} - \frac{30}{5} = \mathbf{y = \frac{11}{5}x + \frac{69}{5}}\).
Finding Slope from Standard Form (ax + by + c = 0)
When a line is given in standard form \(ax + by + c = 0\), solve for y to find the slope. Isolate y:
The coefficient of x is the slope: \(m = -\frac{a}{b}\), provided b ≠ 0. If b = 0, the line is vertical and the slope is undefined.
Example: For 3x + 4y − 12 = 0, a = 3, b = 4. Slope m = −3/4. This is negative, so the line falls from left to right.
Slope of a Vertical Line and Horizontal Line
Vertical line: All points have the same x-coordinate, so the run (x₂ − x₁) is zero. Since division by zero is undefined, the slope is undefined. The equation is \(x = c\).
Horizontal line: All points have the same y-coordinate, so the rise (y₂ − y₁) is zero. The slope is zero. The equation is \(y = c\).
Common mistake: calling a vertical line “slope = 0.” Slope zero means horizontal. Vertical lines have undefined slope.
How to Calculate Slope Ratio
Slope ratio expresses the slope as a relationship between vertical rise and horizontal run. If a ramp rises 1 unit for every 12 units of horizontal distance, the slope ratio is 1:12 (or “1 in 12”).
Percentage grade converts the ratio to a percentage: grade % = (rise / run) × 100. A slope of 1/12 = 0.0833 corresponds to an 8.33% grade.
Angle is another way to express steepness: angle = arctan(slope). A slope of 1 gives a 45° angle. A 100% grade is a 45° angle—not a 90° angle. This distinction matters for roads and ramps.
How to Calculate the Slope of a Hill
For a hill or ramp, use the same rise-over-run definition. Measure the vertical rise (height change) and the horizontal run (horizontal distance, not the length of the sloping surface). The slope ratio is rise / run. The grade percentage is (rise / run) × 100.
Example: A hill rises 15 meters over a horizontal distance of 120 meters. Slope = 15/120 = 1/8 = 0.125. Grade = 12.5%. The slope ratio is “1 in 8.”
Important: Do not use the length of the road surface as the run. The run is always horizontal distance. Using the surface length would understate the steepness.
Interpreting the Slope
- Positive slope — line rises left to right. Larger positive values are steeper.
- Negative slope — line falls left to right. Larger magnitudes are steeper descents.
- Slope zero — horizontal line. y is constant.
- Undefined slope — vertical line. x is constant.
- Slope of 1 — 45° rising. Slope of −1 — 45° falling.
- Fractional slope — common and exact. 3/4 is better than 0.75 in homework answers.
FAQ
How do you calculate the slope of a line?
Use \(m = \frac{y_2 - y_1}{x_2 - x_1}\). Subtract y-coordinates for the rise, x-coordinates for the run, then divide. The calculator above does this automatically with steps.
What is the formula for the slope of a line?
The slope formula is \(m = \frac{y_2 - y_1}{x_2 - x_1}\), also called rise over run. For standard form \(ax + by + c = 0\), the slope is \(m = -a/b\) (b ≠ 0).
What is the slope of a vertical line?
Undefined. The run is zero, and division by zero is not defined. Equation: \(x = c\).
What is the slope of a horizontal line?
Zero. The rise is zero. Equation: \(y = c\).
Can a slope be a fraction?
Yes. 8/3, 11/5, 1/4 are all valid slopes. Keep the fraction for exact answers; use the decimal for comparison.
How do you find slope from ax + by + c = 0?
Solve for y: \(y = -(a/b)x - c/b\). The slope is \(-a/b\). For example, \(3x + 4y - 12 = 0\) has slope \(-3/4\).
How do you calculate slope ratio?
Slope ratio = rise / run. Express as a fraction or as “1 in n.” Percentage grade = (rise / run) × 100.
How do you calculate the slope of a hill?
Use vertical rise divided by horizontal run. Grade percentage = (rise / run) × 100. Do not use the sloping surface length as the run.
Related tools
Related Hira Academy resources
Slope and the equation of a line are central to coordinate geometry in Class 9 and 10. Revise with our free Class 9 notes and Class 10 notes.