Formula

Slope formula

Also written: gradient formula · rise over run · slope between two points

m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}

The slope formula gives the steepness of the line through two points: the change in y divided by the change in x.

What each part means

mm
the slope
(x1,y1)(x_1, y_1)
the first point
(x2,y2)(x_2, y_2)
the second point

Slope calculator

Enter two points to find the slope of the line through them, using m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}. Whole numbers, decimals and fractions all work.

The steps below find the slope through the points (1, 2) and (4, 11). Turn on JavaScript to try your own points.

Worked example: through (1,2),(4,11)

The slope is 3.

Label the points

Call the first point (x1,y1) and the second (x2,y2).

(x1,y1)=(1,2)(x2,y2)=(4,11)

Substitute, subtract and simplify

Put the y-values on top and the x-values on the bottom, both starting from the same point.

m=y2−y1x2−x1=11−24−1=93=3

What it tells you

The slope is positive, so the line rises from left to right.

Runs on your device: nothing you type is sent or saved. Want to know why it works? Read the slope lesson, or see how to write the equation of the line.

When to use it

You know two points on a line and need its steepness, or a rate of change from two readings of the same quantity.

Reading it

The yy-values go on top and the xx-values on the bottom — rise over run, in that order.

Either point can be first, as long as you are consistent. Both differences must start from the same point, or the sign comes out backwards.

y2−y1x2−x1andy1−y2x1−x2\frac{y_2 - y_1}{x_2 - x_1} \qquad\text{and}\qquad \frac{y_1 - y_2}{x_1 - x_2}

Both give the same slope. Mixing them does not.

Why the formula does not depend on which two points you pick

Take any two points on the same straight line. The right triangles formed by their rise and run are similar, because the line makes the same angle with the horizontal everywhere along its length.

Similar triangles have proportional sides, so the ratio of rise to run is the same for every pair of points. That constant ratio is what the number mm names — see rate of change for the algebra.

Worked examples

Find the slope through (1,2)(1, 2) and (4,11)(4, 11).

m=11−24−1=93=3m = \frac{11 - 2}{4 - 1} = \frac{9}{3} = 3

Find the slope through (−2,5)(-2, 5) and (3,−5)(3, -5).

m=−5−53−(−2)=−105=−2m = \frac{-5 - 5}{3 - (-2)} = \frac{-10}{5} = -2

Negative, so the line falls left to right.

Two special cases

SituationDenominatorSlope
horizontal linenon-zero00
vertical linezeroundefined

A vertical line has no slope at all, because dividing by zero is not defined. That is the one line slope-intercept form cannot describe.

Lessons that teach this

Related