Home / Slope Calculator

Slope Calculator

Enter two points and the calculator returns the slope, the y-intercept, the equation of the line, and the distance between the points, with each step shown.

Two points

Point 1 is (x1, y1); point 2 is (x2, y2).

Results

Slope (m)--
Y-intercept (b)--
Equation--
Distance--
Enter two points to see the steps.

How It's Calculated

Slope tracks how steep a line runs: the change in y for every unit of change in x, a ratio most people learn as rise over run. Two points are all the algebra needs to pin it down.

m = (y₂ - y₁) / (x₂ - x₁)

Once the slope is known, the rest of the line follows from it. The y-intercept comes from b = y₁ - m x₁, which then plugs into slope-intercept form, y = mx + b. The straight-line distance between the same two points uses the distance formula, which is really the Pythagorean theorem measured on a coordinate grid instead of a triangle.

Worked Example: (1, 2) and (4, 8)

Step 1. Slope m = (8 - 2) / (4 - 1) = 6 / 3 = 2.
Step 2. Y-intercept b = 2 - (2)(1) = 0.
Step 3. Equation: y = 2x + 0, or simply y = 2x.
Step 4. Distance = sqrt((4-1)² + (8-2)²) = sqrt(9 + 36) = sqrt(45), about 6.708.

Common Mistakes to Avoid

The most frequent slip is mixing up which point is "first" partway through the subtraction, so the x and y values no longer line up the same way in the numerator and denominator. A close second: treating a vertical line as having zero slope. A vertical line, where x₁ equals x₂, has an undefined slope because the run is zero and division by zero has no answer. Zero slope belongs only to a flat, horizontal line. If your answer comes out with the wrong sign, redo the subtraction in a consistent order rather than guessing which term to flip.

For a deeper look at the algebra behind lines, see Wolfram MathWorld's entry on the line.

Keep going with algebra

Need the roots of a quadratic next, or want to check a square root by hand?

Quick answers

Slope calculator: common questions

What is the slope formula?

Slope m = (y2 - y1) / (x2 - x1). It is the change in y divided by the change in x between two points on the line.

How do you find the y-intercept?

Once you have the slope m, use b = y1 - m times x1. The intercept b is where the line crosses the y-axis.

What does a slope of zero mean?

A slope of zero is a flat, horizontal line. An undefined slope, where x1 equals x2, is a vertical line.

How is the distance between two points found?

With the distance formula, sqrt((x2 - x1)^2 + (y2 - y1)^2), which comes straight from the Pythagorean theorem.

Marcus Vance
About the author
Marcus Vance
Contributing Writer, Technology & Data, Encore Editorial

Marcus Vance spent a decade building data pipelines and testing calculation logic before he started writing about the math behind the tools. On MathCalcTools he checks every formula against the source math, then writes out the steps so a reader can follow the same path a calculator takes.