Slope Calculator

Inputs stay on your device

Slope Calculator

Slope = (y2 - y1) / (x2 - x1), the rise over the run between two points.

Your result will appear here. Enter values and calculate.

Drop in two points

A line is pinned down by any two points on it, so the calculator asks for four numbers: the x and y of the first point and the x and y of the second. Keep each point together, its own x paired with its own y, and the order of the two points does not matter.

Those two points are enough to recover everything about the line, which is why a single screen can return the slope, the equation, the angle and the distance without asking for anything more.

Four answers from two points

The headline is the slope, but the result also writes out the equation of the line, the angle it makes with the horizontal, and the straight-line distance between your two points.

Bundling them is deliberate. The same two points that give the slope also give the distance and the intercept, so calculating them separately would just be repeating work the calculator has already done.

Rise over run, then the equation

Slope is the rise divided by the run: the change in y from one point to the other, over the change in x. A slope of 2 means the line climbs two units for every one it moves right.

From that slope and either point, the calculator finds where the line crosses the y-axis and writes it in the familiar y equals m x plus b form. The distance, meanwhile, comes from the Pythagorean theorem applied to the horizontal and vertical gaps.

A worked example

From the point (1, 2) to the point (4, 8), the run is 4 minus 1, which is 3, and the rise is 8 minus 2, which is 6. Six over three is a slope of 2.

Putting the point (1, 2) back into y equals 2x plus b shows that b is 0, so the line is simply y equals 2x. The distance between the two points works out to the square root of 9 plus 36, about 6.71.

Vertical and horizontal special cases

A vertical line has the same x at both points, so the run is zero. Dividing by zero has no value, which is why the calculator reports an undefined slope rather than a huge number or an error.

A horizontal line is the mirror case. The rise is zero, so the slope is exactly zero, and the line equation collapses to y equals a constant. Both cases are real lines, just ones the rise-over-run shorthand has to describe carefully.

Where slope shows up

Outside the coordinate plane, slope is the grade of a road, the pitch of a roof and the steepness of a wheelchair ramp, where building codes cap how steep the line is allowed to be.

In data work it is the rate of change between two readings, the same idea wearing a different name. The angle output is handy whenever the slope needs to become a degree measurement for a tool or a drawing.

Slope Calculator FAQ

How do I calculate slope from two points?

Subtract the two y values to get the rise, subtract the two x values in the same order to get the run, then divide the rise by the run.

From (1, 2) to (4, 8) that is 6 over 3, a slope of 2.

What does a negative slope mean?

The line falls from left to right. A positive slope rises, and a slope of zero is a flat horizontal line.

The steeper the number, in either direction, the steeper the line.

Why is a vertical line slope undefined?

Both points share the same x, so the run is zero, and you cannot divide by zero.

That is why a vertical line is said to have an undefined slope rather than an infinite one.

How do I find the equation of the line?

Take the slope, put one of your points into y equals m x plus b, and solve for b, the y-intercept.

The calculator does this and hands back the finished equation.

What is the angle of the slope?

It is the inverse tangent of the slope, measured up from the horizontal.

A slope of 1 makes a 45 degree line, and steeper slopes give larger angles.