What this slope calculator does
This tool computes the slope of the straight line passing through two given points. It detects the three possible cases — a normal slope, a horizontal line (slope zero), and a vertical line (undefined slope) — and reports the equation of the line in the appropriate form. It also renders a small graph showing the two points and the line joining them, so you can see the result visually. The result comes with the full step-by-step working, including the rise-over-run computation, the y-intercept calculation, and the substitution check.
Formulas
Variable definitions
- (x₁, y₁) — coordinates of the first point.
- (x₂, y₂) — coordinates of the second point.
- m — the slope (gradient) of the line.
- b — the y-intercept, where the line crosses the y-axis.
Worked examples
Example 1: Slope through (2, 3) and (5, 11)
- Identify: x₁ = 2, y₁ = 3, x₂ = 5, y₂ = 11.
- Rise: y₂ − y₁ = 11 − 3 = 8.
- Run: x₂ − x₁ = 5 − 2 = 3.
- Slope m = 8 / 3 ≈ 2.6667.
- Result: m = 8/3, line rises steeply to the right.
Example 2: Horizontal line through (1, 5) and (7, 5)
- Rise: y₂ − y₁ = 5 − 5 = 0.
- Run: x₂ − x₁ = 7 − 1 = 6.
- Slope m = 0 / 6 = 0.
- Result: m = 0, equation y = 5. The line is horizontal.
Example 3: Vertical line through (4, 1) and (4, 9)
- Run: x₂ − x₁ = 4 − 4 = 0.
- Slope m = (y₂ − y₁) / 0 → undefined because division by zero is not allowed.
- The line is vertical, with equation x = 4.
- Result: slope undefined; equation x = 4.
Example 4: Negative slope through (−2, 5) and (3, 0)
- Rise: 0 − 5 = −5.
- Run: 3 − (−2) = 5.
- Slope m = −5 / 5 = −1.
- Line makes a 45° angle falling to the right.
- Result: m = −1. Equation: y = −x + 3.
Example 5: Slope 1 (45° line) through (0, 0) and (4, 4)
- Rise: 4 − 0 = 4.
- Run: 4 − 0 = 4.
- Slope m = 4 / 4 = 1.
- Result: m = 1. Line passes through origin, so b = 0, equation y = x.
Interpreting the slope
- Positive slope — the line rises as it goes right. Larger positive values are steeper.
- Negative slope — the line falls as it goes right. Larger negative magnitudes are steeper descents.
- Slope zero — horizontal line. The y-value stays constant.
- Undefined slope — vertical line. The x-value stays constant.
- Slope of 1 — line at 45° rising. Slope of −1 — line at 45° falling.
- Slope as a rate — in physics, slope represents a rate of change. On a distance-time graph, slope = speed. On a velocity-time graph, slope = acceleration.
Common mistakes to avoid
- Subtracting in the wrong order. If you compute y₂ − y₁ in the numerator, you must also compute x₂ − x₁ in the denominator. Mixing orders (e.g. y₂ − y₁ over x₁ − x₂) flips the sign of the slope.
- Forgetting the sign of negative coordinates. Subtracting a negative number becomes addition. For example, 3 − (−2) = 5, not 1.
- Calling a vertical line "slope = 0". Slope zero means horizontal. Vertical lines have undefined slope because the run is zero and division by zero is not defined.
- Writing the slope as a whole number when it's a fraction. 8/3 is the exact slope; 2.6667 is an approximation. Use the fraction in exact answers.
- Using the slope-intercept form for vertical lines. A vertical line cannot be written as y = mx + b because m is undefined. Use x = c instead.
- Forgetting the sign of b. If the equation is y = 2x − 3, then b = −3, not 3. The y-intercept is below the origin.
FAQ
What is the slope of a line?
The slope (or gradient) of a line measures how steep it is. It is defined as the change in y divided by the change in x between any two points on the line: m = (y₂ − y₁) / (x₂ − x₁). A positive slope rises from left to right; a negative slope falls.
What is the slope of a vertical line?
A vertical line has undefined slope because the change in x is zero and division by zero is undefined. The equation of a vertical line is x = c, where c is the common x-coordinate of all points on the line.
What is the slope of a horizontal line?
A horizontal line has slope zero because the change in y is zero. The equation is y = c, where c is the common y-coordinate of all points on the line.
What is slope-intercept form?
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). It is the most convenient form for graphing a line.
How do I find the slope from a graph?
Pick any two points on the line and count the rise (vertical change) and run (horizontal change) between them. The slope is rise divided by run. A steeper line has a larger absolute slope.
What does a slope of 1 mean?
A slope of 1 means the line rises one unit for every one unit moved right. The line makes a 45-degree angle with the horizontal. In general, the slope equals the tangent of the angle the line makes with the positive x-axis.
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.