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.

Slope (m)
2
Two points (1, 2) and (4, 8)
Slope (m)2
Y-intercept (b)0
Line equationy = 2x
Angle with the x-axis63.43°
The calculation
m = (8 − 2) ÷ (4 − 1) =
2

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.

The formula
m = (y2 − y1) ÷ (x2 − x1)  ·  y = mx + b

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

PointsSlope (m)Y-intercept (b)Equation
(1, 2) and (4, 8)20y = 2x
(2, 3) and (5, 9)2−1y = 2x − 1
(0, 5) and (4, 5)05y = 5
(3, 1) and (3, 7)Undefined—x = 3
(−1, 4) and (2, −2)−22y = −2x + 2

Tips before you use it

01

A positive slope rises left to right; a negative slope falls left to right. The bigger the absolute value, the steeper the line.

02

Two points with the same x value make a vertical line — there is no slope and no y-intercept to find.

03

Two points with the same y value make a horizontal line with slope 0 and the equation y = that value.

04

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.