Slope Calculator

Slope calculator that gives you the whole line, m included

Enter two points and get the slope as an exact fraction where one exists, plus the y-intercept, the equation in slope-intercept form, the midpoint and the distance between them, because if you needed the slope you usually need at least one of those as well.

Part of SolveStep's algebra solver. To see the line drawn, use the graphing calculator.

Gives the slope, the y-intercept, the equation of the line, the midpoint and the distance between the two points.

What it covers

Rise over run, and everything that follows

Slope is the answer to one question: when you move to the right, how far up or down do you go? That is rise / run, the change in y divided by the change in x. Everything else about a straight line follows from that number plus a single point on the line.

The two places this goes wrong are subtraction order and vertical lines. Subtract the coordinates in the same order on the top and the bottom. If you take y₂ − y₁ you must take x₂ − x₁, not the other way round, or the sign flips. And when both points share an x value, the run is zero: the slope is undefined, not infinity.

Positive slope

m = 3

The line rises left to right. A slope of 3 means three units up for every one across.

Negative slope

m = −1/2

The line falls left to right. Exact fractions are kept rather than rounded to −0.5.

Horizontal line

m = 0

No rise at all. The equation is just y = a constant.

Vertical line

undefined

The run is zero, so the division is impossible. It comes back as undefined, with the equation x = a constant, not as infinity, which would be a different and wrong claim.

Worked examples

Two lines, worked through

Slope and the full equation

(1, 2) and (3, 8)
  1. Rise: y₂ − y₁ = 8 − 2 = 6.
  2. Run: x₂ − x₁ = 3 − 1 = 2. Note the same order on both.
  3. Slope: m = 6 / 2 = 3.
  4. Find b using either point: b = y₁ − m·x₁ = 2 − 3(1) = −1.
  5. Write it out: y = 3x − 1. Check with the other point: 3(3) − 1 = 8
m = 3, y = 3x − 1

A vertical line

(4, 1) and (4, 9)
  1. Rise: 9 − 1 = 8.
  2. Run: 4 − 4 = 0.
  3. Dividing by zero is not possible, so the slope is undefined. Not infinity, and not zero.
  4. Both points share the same x, so the line is vertical: x = 4.
undefined (x = 4)

Try your own →

Common questions

Slope calculator FAQ

Does the order of the two points matter?

Not to the final answer, as long as you are consistent. Taking point 2 minus point 1 on both the top and the bottom gives the same slope as doing it the other way round, because both signs flip. Mixing the order between numerator and denominator is what produces a wrong sign.

What is the slope of a vertical line?

Undefined. The run is zero and you cannot divide by zero. It is not infinity either. Infinity would imply a value the slope approaches, and a vertical line simply has no slope in that sense. The calculator says undefined and gives the line as x = a constant.

What is the slope of a horizontal line?

Zero. There is no rise, so the numerator is 0, and 0 divided by anything non-zero is 0. That is a genuine value, unlike the vertical case.

Will it give me a fraction or a decimal?

A fraction in lowest terms when the slope is rational, so you get −1/2 rather than −0.5. Whole-number slopes are shown as whole numbers.

How do I get the equation of the line from two points?

Find the slope first, then substitute one point into b = y − mx to get the intercept. Both steps are shown, so the equation comes out automatically.

What are the midpoint and distance for?

They come from the same two points and are almost always needed in the same questions. Midpoint is the average of the coordinates; distance is the Pythagorean theorem applied to the rise and run. Since both are free once you have the rise and run, they are included.