Slope Calculator

Slope — the gradient, the steepness, the rise over the run — is how quickly a line climbs as you move right, and it is the one number that defines a straight line's tilt. Roof pitches, ramp codes, hill grades and trend lines all reduce to it. Give this calculator two points and it returns the slope, the angle it makes with the horizontal, where the line crosses the y-axis, and the equation written out ready to plot.

Enter values

Two identical x values mean a vertical line — the slope is then undefined

Results update as you type.

Results

Slope (m)
2.00
Angle with the x-axis
63.4°
Y-intercept (c)
0.00
Line equation
y = 2x

How is the Slope calculated?

Enter the x and y coordinates of two points on the line. The calculator divides the change in y by the change in x, converts the result to an angle with the arctangent function, and works out the y-intercept from c = y₁ − m × x₁. If both points share the same x value the line is vertical, so instead of dividing by zero the page says the slope is undefined and shows the line's equation as x equals that value.

Formula

m = (y₂ − y₁) ÷ (x₂ − x₁) is the slope: the rise divided by the run. The angle against the x-axis is θ = arctan(m) × 180 ÷ π, and the line's equation is y = mx + c with the intercept c = y₁ − m × x₁. m, x and y carry the coordinates you entered; a positive m climbs to the right, a negative m falls, and m equal to 0 is a flat horizontal line.

Example

Take the points (1, 2) and (3, 6). The rise is 6 − 2 = 4 and the run is 3 − 1 = 2, so the slope m = 4 ÷ 2 = 2. That gradient tilts the line 63.4° above the horizontal, and the intercept is c = 2 − 2×1 = 0, giving the clean equation y = 2x. Now use (0, 4) and (2, −2): the slope falls to (−2 − 4) ÷ 2 = −3 at an angle of −71.6°, and with c = 4 the line reads y = −3x + 4.

Things to remember

One slope number carries the direction of a line: double it and the line steepens, negate it and it leans the other way, zero flattens it. The angle row is the same fact in degrees, which is what carpenters quote, and the equation row lets you continue in algebra. Vertical lines are the honest exception.

Frequently Asked Questions

How do you calculate the slope between two points?

Subtract the y coordinates, subtract the x coordinates, and divide the first difference by the second. Between (1, 2) and (3, 6) that is (6 − 2) ÷ (3 − 1) = 2. Order never matters as long as you stay consistent: swapping both points changes both signs and leaves the slope untouched.

Why is the slope of a vertical line undefined?

Because every point on it shares one x value, so the run is zero and the formula divides by nothing. The calculator reports that honestly and gives the line's equation as x equals the shared value — a vertical line is perfectly describeable, just not as a slope number.

What does a negative slope tell you?

That the line falls as it moves right — for every step across, it drops m steps down. The line through (0, 4) and (2, −2) has slope −3 and an angle of −71.6°, so the gradient and the angle carry the same direction information in different units.

How do you turn a slope into the line's equation?

Keep the slope as m and find the intercept with c = y₁ − m × x₁, then write y = mx + c. With slope 2 through the point (1, 2) the intercept is 0, so the line is simply y = 2x — a slope of 2 means the y value climbs two units for every one unit across.