← All tools/Calculators/Math/Slope Calculator

Slope Calculator

Find the slope of a line from two points, plus its equation.

Slope

—

Slope
Y-intercept

How it works

Slope m = (y2 − y1) / (x2 − x1)
Line: y = mx + b, where b = y1 − m × x1

Slope is rise over run: m = (y2 − y1) ÷ (x2 − x1). It is the rate at which y changes as x changes. A positive slope means the line rises going right, a negative slope means it falls, and a slope of 0 means the line is flat — y never changes. The line itself is y = mx + b, where b is the y-intercept, the value of y where the line crosses the y-axis, worked out as b = y1 − m × x1. The formula needs two different points; if both points share the same x, the line is vertical and the slope is undefined, because the bottom of the fraction is zero and dividing by zero has no answer. If both points are identical, no line is defined at all. The same maths describes any steady rate of change — a road gradient, a roof pitch, a price rising over time.

Worked example: points (0, 0) and (4, 2) give slope (2 − 0) / (4 − 0) = 0.50, and the line is y = 0.50x.

Second example: the points (2, 3) and (6, 11). The slope is (11 − 3) ÷ (6 − 2) = 8 ÷ 4 = 2, so y rises by 2 for every 1 that x rises. The intercept is b = 3 − 2 × 2 = 3 − 4 = −1, so the line is y = 2x − 1. Check it at the second point: when x = 6, y = 2 × 6 − 1 = 11, which matches. The line crosses the y-axis at −1 and climbs steeply, twice as fast as the line y = x.

Frequently asked questions

What does a slope of 0 mean?

A flat, horizontal line: y never changes as x changes.

What if both points share the same x?

The line is vertical and the slope is undefined — dividing by zero has no answer. The page says so instead of showing a number.

What does a negative slope mean?

The line falls as x increases: y gets smaller going right.

What is the y-intercept, and why does it matter?

The y-intercept, b, is where the line crosses the y-axis — the value of y when x is 0. In y = 2x − 1 the intercept is −1, so the line crosses the axis one unit below the origin. It matters because the slope alone only tells you the steepness; the intercept pins the line to its actual position. Two lines can share a slope of 2 and never meet, because their intercepts differ.

Can I use slope for a road gradient or a roof pitch?

Yes — slope is the same idea as a gradient. A slope of 0.5 means the surface rises 1 unit for every 2 units across, which is a 1-in-2 gradient of about 26.6°. Roof pitch is often quoted the same way: a roof that rises 1 m over a 2 m run has a slope of 0.5. Steepness in degrees is a different number (tan⁻¹ of the slope), so do not mix the two — a slope of 1 is 45°, not 90°.

Common mistakes

Four mistakes trip people up. The first is subtracting in the wrong order: (y2 − y1) must pair with (x2 − x1), and mixing them — y2 − y1 over x1 − x2 — flips the sign of the slope, turning a rising line into a falling one. The second is calling a vertical line’s slope 0: it is undefined, because the bottom of the fraction is zero, and 0 is the slope of a flat line, the opposite case. The third is confusing the slope with the intercept: m is the steepness and b is the position, and swapping them gives a line that is neither steep nor in the right place. The fourth is entering the points in the wrong boxes — (x1, y1) and (x2, y2) must stay matched, or the line passes through two points you never intended. When the answer looks wrong, re-check which number is x and which is y first.

More tools

Tell us what you think

Loving this tool, or stuck on something? Tell us — it takes a minute.

We’ll only use your name and email to reply if needed. The tool and page are filled in for you.