Slope Calculator

Enter two points and get the slope of the line through them, whether it rises or falls, the full working, and the equation of the line. Slopes are kept as exact fractions rather than rounded decimals.

Point 1
Point 2

The slope formula

Slope is how much the line rises for each step it takes to the right: the change in y divided by the change in x between any two points on the line.

m = (y₂ − y₁) ÷ (x₂ − x₁)

The top of the fraction is called the rise and the bottom the run, which is where “rise over run” comes from. Taking the points in the other order gives the same slope, because both the rise and the run change sign and the two cancel.

The same two points can also be used to find the distance between them or their midpoint.

What the slope tells you

  • Positive — the line rises from left to right.
  • Negative — the line falls from left to right.
  • Zero — the line is horizontal. A slope of 0 is a perfectly ordinary number.
  • Undefined — the line is vertical. This is not the same as zero, and not the same as infinity.

Why a vertical line has no slope

If both points share the same x-value, the run is zero, and the formula asks you to divide by zero. That has no answer — so the slope is undefined, which is a different statement from “the slope is infinite”.

A vertical line also has no slope-intercept form. There is no y = mx + b for it, because y is not a function of x: one x-value corresponds to every y. Its equation is written x = 3 instead, and this calculator gives that form when the line is vertical rather than reporting an error or a huge number.

Why the answer is a fraction

The slope between (1, 2) and (4, 3) is exactly 1/3. A finite decimal such as 0.333333 is only an approximation; the repeating decimal 0.333333… represents exactly the same value as 1/3.

This calculator keeps the slope as a fraction in lowest terms and shows the decimal alongside, marked with ≈ when it doesn’t terminate. That matters for the equation too: a y-intercept of 5/3 is exact, while 1.67 is a rounding of it.

Finding the equation of the line

Once you have the slope, you can find the y-intercept and write the line in slope-intercept form:

b = y₁ − m × x₁

For (1, 2) and (4, 3): the slope is 1/3, so b = 2 − (1/3)(1) = 5/3, giving y = (1/3)x + 5/3. Using the second point instead gives the same answer, which is a useful check if you are doing it by hand.

Related line and coordinate calculators

Use these tools for other calculations involving points, distance, slope, and equations of lines.

Related: the equation of the line

To go from two points to the equation of the line through them, the equation of the line through them does it in one step, with the slope and intercept worked out separately.

Frequently asked questions

How do I find the slope between two points?

Subtract the y-values, subtract the x-values in the same order, and divide the first by the second: m = (y₂ − y₁) ÷ (x₂ − x₁). The order of the two points doesn't matter as long as it's consistent on the top and bottom.

What is the slope of a vertical line?

Undefined. The run is zero and division by zero has no answer. It is not infinity, and it is not zero — a slope of zero belongs to a horizontal line, which is the opposite case.

What is the slope of a horizontal line?

Exactly 0. The rise is zero, so the whole fraction is zero, and the equation is simply y = c. Unlike the vertical case, there is nothing undefined about it.

Does the order of the two points matter?

No, as long as you keep the order the same on top and bottom. Swapping the points negates both the rise and the run, and those two sign changes cancel out.

Can I enter decimals or negative coordinates?

Yes, both. Decimals are converted to exact fractions before anything is calculated, so a point like (2.5, −0.5) gives an exact answer rather than a floating-point approximation.

What is the difference between slope-intercept form and point-slope form?

Slope-intercept form is y = mx + b, where m is the slope and b is the y-intercept. Point-slope form is y − y₁ = m(x − x₁), where you know the slope and one point on the line. Both forms describe the same straight line and can be converted into each other.