ThisCalculator

Everyday

Gradient and Y-Intercept Calculator: Find Slope & Intercept

Updated · Standard formula, shown below

Gradient (slope) 2.00
Y-intercept
0.00
Result
x�
1
You entered
y�
2
You entered

Gradient and Y-Intercept Calculator: Find Slope & Intercept

This calculator finds the gradient (slope) and y-intercept of a straight line from two points you enter. Type in the x and y coordinates of two points on the line, and you get back the equation in the form y = mx + b, with the gradient m and the y-intercept b shown clearly.

Formula

The gradient (often called slope) of a straight line measures how steep it is. Given two points on the line, (x�, y�) and (x₂, y₂), the gradient m is calculated as:

m = (y₂ − y�) / (x₂ − x�)

where:

  • m = gradient (slope), a dimensionless number
  • (x�, y�) = coordinates of the first point
  • (x₂, y₂) = coordinates of the second point

The y-intercept b is the value of y where the line crosses the y-axis (i.e., where x = 0). Once you have m, use either point to find b:

b = y� − m · x�

The equation of the line is then y = m·x + b.

Worked Example

Using the default values from the calculator: Point 1 = (1, 2) and Point 2 = (4, 8).

  1. Calculate the gradient: m = (8 − 2) / (4 − 1) = 6 / 3 = 2
  2. Find the y-intercept using Point 1: b = 2 − 2 × 1 = 0
  3. Line equation: y = 2x + 0, which simplifies to y = 2x

The calculator shows m = 2.00 and b = 0.00, matching the manual calculation.

When to Use This Calculator

Use this tool whenever you have two points on a straight line and need the line’s equation. Common situations include:

  • Plotting a line on a graph from two data points
  • Finding the rate of change in physics (e.g., velocity from a distance-time graph)
  • Economics: finding the slope of a demand or supply curve
  • Statistics: understanding the trend in a scatter plot
  • Algebra homework: converting two points into slope-intercept form

The gradient tells you how much y changes for a one-unit increase in x. A positive gradient means the line goes upward from left to right; a negative gradient means it goes downward. A gradient of zero is a horizontal line.

How to Read the Results

The output gives you two numbers:

  • Gradient (m): The steepness. For example, m = 2 means for every 1 unit you move right, the line rises 2 units. A larger absolute value means steeper.
  • Y-intercept (b): The point where the line crosses the y-axis. If b = 3, the line passes through (0, 3).

With these, you can write the full equation y = m·x + b. For instance, if m = −0.5 and b = 4, the equation is y = −0.5x + 4. You can then use that equation to predict y for any x, or to draw the line on a graph.

Common Mistakes and Pitfalls

Several errors are easy to make when calculating gradient and intercept manually:

  • Reversing the subtraction: Always subtract the first point’s coordinates from the second point’s coordinates in both numerator and denominator. If you mix them up, you get the wrong sign.
  • Dividing by zero: If x� = x₂, the line is vertical and the gradient is undefined. The calculator will show an error or infinity. A vertical line cannot be written in y = mx + b form.
  • Unit mix-ups: If your x and y values have units (e.g., time in seconds, distance in meters), the gradient will have those units (m/s). The y-intercept will have the same units as y. Keep units consistent.
  • Rounding too early: If you round m to two decimals before computing b, you may get a slightly different b. Use the full precision until the final step.

Limitations of the Formula

The y = mx + b form only works for non-vertical straight lines. Vertical lines have an undefined slope and cannot be expressed this way; they are written as x = constant. Also, the formula assumes the relationship between x and y is perfectly linear. If your data is not exactly on a line (e.g., from real-world measurements), this calculator gives the line through two points, but it won’t be a

Related

Formula used
in x1 | x� | - | 1 | 0
in y1 | y� | - | 2 | 0
in x2 | x₂ | - | 4 | 0
in y2 | y₂ | - | 8 | 0
out m | Gradient (slope) | - | (y2 - y1) / (x2 - x1) | 2
out b | Y-intercept | - | y1 - m * x1 | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.