Skip to content
NumberCalculator365

Slope Calculator

How to Find Slope From Two Points

Published 2026-11-03

Slope calculator searches are algebra homework: two ordered pairs and a request for m. Slope is rise over run. Through (1, 2) and (4, 8), rise 6 and run 3 give m = 2 and the line y = 2x.

Use the free tool

Run these formulas with your own numbers. Math stays in your browser.

Open Slope Calculator →

Our slope calculator also prints intercept, angle with the +x axis, distance and midpoint. A vertical line (same x, different y) has undefined slope. The same two points twice is an error, not 0/0. This is not roof pitch as percent grade and not the triangle calculator.

Open the slope calculator

Enter x₁, y₁, x₂, y₂. The default points should show m = 2 and y = 2x. Swap both points and m stays the same.

The formula

Keep the order: both differences use point 2 minus point 1. Then b = y₁ − m x₁ for slope-intercept form.

m = (y₂ − y₁) / (x₂ − x₁)
y = mx + b,  b = y₁ − m x₁

Four pictures of slope

Positive rises left to right. Negative falls. Zero is horizontal. Undefined is vertical.

Two-point slope
PointsmEquation
(1, 2), (4, 8)2y = 2x
(0, 4), (2, 0)−2y = −2x + 4
(3, 5), (10, 5)0y = 5
(3, 1), (3, 5)undefinedx = 3

Angle, distance and triangles

The angle is arctan(m) in degrees, not a compass bearing. Distance is the segment length. If you have side lengths instead of coordinates, use the triangle calculator (SSS, SAS, ASA, AAS, SSA). Percent grade is 100 × rise/run — you can form it from the rise and run items, but the headline result is m.

  1. Subtract y, subtract x, divide.
  2. If run is 0 and rise is not, the line is vertical.
  3. If both differences are 0, the points are the same — no line.

Point-slope, intercept and a negative example

From (0, 4) to (2, 0), rise = −4 and run = 2, so m = −2. Then b = 4 − (−2)×0 = 4, and the line is y = −2x + 4. Point-slope form y − 4 = −2(x − 0) is the same line; the slope calculator prints slope-intercept because that is what most US algebra keys want. A horizontal line through (3, 5) and (10, 5) is y = 5 with m = 0. A vertical line through (3, 1) and (3, 5) cannot be written as y = mx + b — the tool says undefined and x = 3. Distance √(0² + 4²) = 4 is the segment length, extra information that is not required to report slope. Roof pitch as “4:12” is a ratio of rise to run, not this Cartesian m; use the ratio calculator if you only need to simplify 4:12.

Use the free tool

Run these formulas with your own numbers. Math stays in your browser.

Open Slope Calculator →

Frequently Asked Questions

What if the points are identical?

The tool errors. Slope is undefined.

What does undefined mean?

Zero run: a vertical line, written x = x₁.

Is the angle a heading?

No. Arctangent of m from the positive x-axis.

Decimals allowed?

Yes.

Does this solve a triangle?

No. Two Cartesian points only.

Related calculators

More guides