Home›Math & Stats›Slope Calculator
Slope Calculator
Your line
A vertical line has an undefined slope — the calculator says so instead of dividing by zero. A horizontal line has a slope of 0.
Example: points (1, 2) and (4, 8) → slope 2, y-intercept 0, line y = 2x.
Behind the numbers
How the slope is calculated
The slope of a line is the change in y divided by the change in x between two points on the line. Once you know the slope m and one point, the y-intercept is b = y1 − m × x1, which gives the line in slope-intercept form, y = mx + b. The angle the line makes with the x-axis is the inverse tangent of the slope.
Worked example — points (1, 2) and (4, 8): m = (8 − 2) ÷ (4 − 1) = 6 ÷ 3 = 2. The y-intercept is b = 2 − 2 × 1 = 0, so the line is y = 2x. Its angle is tan−1(2) = 63.43°. In point-slope form, the same line through (1, 2) is y − 2 = 2(x − 1).
Examples
Example slopes
| Points | Slope (m) | Y-intercept (b) | Equation |
|---|---|---|---|
| (1, 2) and (4, 8) | 2 | 0 | y = 2x |
| (2, 3) and (5, 9) | 2 | −1 | y = 2x − 1 |
| (0, 5) and (4, 5) | 0 | 5 | y = 5 |
| (3, 1) and (3, 7) | Undefined | — | x = 3 |
| (−1, 4) and (2, −2) | −2 | 2 | y = −2x + 2 |
Tips before you use it
A positive slope rises left to right; a negative slope falls left to right. The bigger the absolute value, the steeper the line.
Two points with the same x value make a vertical line — there is no slope and no y-intercept to find.
Two points with the same y value make a horizontal line with slope 0 and the equation y = that value.
Check your answer with the y-intercept: the point (0, b) must sit on the line, so plugging x = 0 into y = mx + b should give y = b.
Good to know
Frequently asked questions
What is the slope of a line?
The slope measures how steep a line is: how much y changes for each step in x. It is the rise over the run, m = (y2 − y1) ÷ (x2 − x1). A slope of 2 means y rises 2 units for every 1 unit x moves right.
What does an undefined slope mean?
An undefined slope means the line is vertical: both points have the same x value, so x2 − x1 is 0 and division by zero is not possible. A vertical line has an equation like x = 3 and no y-intercept.
What does a slope of 0 mean?
A slope of 0 means the line is horizontal: y never changes, so the equation is y = b, where b is the y value of every point on the line.
What is the difference between the two-point form and point-slope form?
The two-point form finds the slope from two points on the line. Point-slope form starts with one point and a known slope and uses y − y1 = m(x − x1). Both give the same slope-intercept equation, y = mx + b.