Slope calculator — gradient and y = mx + b from two points

Give two points on a line and the calculator finds its slope, writes the equation in y = mx + b form, and lists the intercepts, angle and perpendicular slope.

Live demo · real result from this tool
Slope (m)3
Equation
y = 3x − 1
y-intercept (b)
-1
Angle of inclination
71.565051°
x-intercept
0.3333333333
Perpendicular slope
-0.3333333333

Working

m = (y₂ − y₁)/(x₂ − x₁) = (8 − 2)/(3 − 1) = 6/2 = 3b = y₁ − m·x₁ = 2 − (3)(1) = -1y = 3x − 1

Processed on your device — nothing is uploaded.

How to use the slope calculator

  1. Type the first point as x₁ and y₁.
  2. Type the second point as x₂ and y₂.
  3. Read Slope (m) and the Equation of the line.
  4. Check the extra results: y-intercept (b), Angle of inclination, x-intercept and Perpendicular slope. The Working box shows how m and b were found.

What it does and when to use it

Slope measures steepness: how much y changes for each step in x. It answers questions such as “how fast does the cost rise per item?” or “how steep is this ramp?”. In algebra classes you often need the equation of a line through two given points; this tool writes it out, so you can check your answer.

For distance and midpoint as well, use coordinate line properties. If you only need the midpoint or the distance, those tools show their own working.

How it works

  1. Slope: m = (y₂ − y₁)/(x₂ − x₁), rise over run.
  2. Intercept: put one point into y = mx + b and solve, b = y₁ − m·x₁.
  3. x-intercept: where y = 0, x = −b/m (not shown for a horizontal line).
  4. Angle of inclination: arctan(m), in degrees.
  5. Perpendicular slope: −1/m.

If x₁ = x₂ the tool reports a vertical line, x = x₁. If the two points are identical it says the slope is undefined, because any line passes through a single point.

Worked examples

Step by step. Points (2, 5) and (6, 13).

  1. Rise: 13 − 5 = 8. Run: 6 − 2 = 4.
  2. Slope: m = 8 ÷ 4 = 2.
  3. Intercept: b = 5 − 2 × 2 = 1.
  4. Write the line: y = 2x + 1.

The tool shows Equation: y = 2x + 1, an angle of inclination of 63.434949°, x-intercept −0.5 and perpendicular slope −0.5.

A falling line. Points (−1, 4) and (3, 2) give m = −2/4 = −0.5 and y = −0.5x + 3.5. The line crosses the x-axis at x-intercept: 7, and a perpendicular line would have slope 2.

A flat line. Points (1, 3) and (5, 3) give slope 0 and the equation y = 3. The tool reports Perpendicular slope: undefined (vertical), because a line at right angles to a flat line is vertical.

Limits and tips

  • Slopes appear as decimals (up to 10 significant figures), so 1/3 shows as 0.3333333333. Turn it back into a fraction with decimal to fraction if your teacher wants y = (1/3)x + 2.
  • The tool needs two points. It does not take a slope and one point, or an equation, as input.
  • Runs entirely in your browser.

Frequently asked questions

What does a negative slope mean?
The line goes down as you move right. A slope of −0.5 drops half a unit for every one unit across.
Why is the slope "undefined" for some lines?
If both points have the same x value, the line is vertical and the run Δx is 0. Dividing by zero has no answer, so the tool gives the equation as x = (that value) instead.
What is the perpendicular slope used for?
Two lines meet at a right angle when their slopes multiply to −1. The tool gives −1/m, which you need for perpendicular bisectors, normals and right-angle checks.
What is the angle of inclination?
The angle the line makes with the positive x-axis, found as arctan(m). Positive slopes give angles between 0° and 90°; negative slopes give negative angles.
Is "slope" the same as "gradient"?
Yes. Gradient is common in British and Indian textbooks, slope in American ones. Both mean rise over run.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close