What this calculator does
The gradient formula measures how steeply a line rises or falls between two points: gradient equals the change in y divided by the change in x, often written as "rise over run". Enter the coordinates of two points and the gradient comes out directly.
How to find the gradient of a line is the same calculation whether the two points come from a maths problem, a road's incline, or two readings on a graph: subtract the y-values, subtract the x-values, and divide one by the other.
The formula
Gradient (m) equals (y2 − y1) divided by (x2 − x1). Once the gradient is known, the full equation of the line, y = mx + c, follows by solving for c using either point: c = y1 − m × x1.
| Term | Meaning |
|---|---|
| Gradient (m) | The steepness of a line: the change in y divided by the change in x between two points. |
| y-intercept (c) | The y-value where the line crosses the y-axis, at x = 0. |
| Rise and run | The vertical change (rise) and horizontal change (run) between two points; gradient is rise ÷ run. |
The inputs explained
| Field | What to enter |
|---|---|
| x1 | The x-coordinate of the first point. |
| y1 | The y-coordinate of the first point. |
| x2 | The x-coordinate of the second point. |
| y2 | The y-coordinate of the second point. |
When to use it
Finding the gradient formula answer for a maths problem
A GCSE or introductory algebra question giving two coordinate points is answered directly here, with the full line equation shown alongside the gradient itself.
Working out the steepness of a real-world slope
Two survey points, a horizontal distance and a vertical rise, give a gradient in the same way as two points on a graph, useful for a road, ramp or roof pitch expressed as a ratio.
Checking whether two lines are parallel or perpendicular
Two lines are parallel if their gradients are equal, and perpendicular if one gradient is the negative reciprocal of the other; working out both gradients separately is the first step in either check.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
How does the gradient change as the second point moves further away?
A first point fixed at the origin, (0, 0), with the second point moved along a straight line through it.
Gradient and line equation for a range of point pairs
A selection of coordinate pairs producing positive, negative, zero and steep gradients.
| y2 (x2 fixed at 5) | Gradient (m) | Angle of incline |
|---|---|---|
| 0 | 0 | 0.00° |
| 5 | 1.000 | 45.00° |
| 10 | 2.000 | 63.43° |
| 15 | 3.000 | 71.57° |
| -10 | -2.000 | -63.43° |
| 25 | 5.000 | 78.69° |
Questions
What is the gradient formula?
Gradient (m) = (y2 − y1) ÷ (x2 − x1), the change in y divided by the change in x between any two points on a straight line.
How do I find the gradient of a line from two points?
Subtract the y-coordinates to get the rise, subtract the x-coordinates in the same order to get the run, then divide the rise by the run.
What does a negative gradient mean?
The line falls from left to right: as x increases, y decreases. A positive gradient means the line rises from left to right, and a gradient of zero means the line is perfectly horizontal.
Why is the gradient undefined for a vertical line?
A vertical line has the same x-coordinate for every point, so x2 − x1 is zero, and dividing by zero is undefined. Vertical lines are the one case a gradient calculation cannot produce a numerical answer for.
For distance and midpoint between the same two points as well as the gradient, see the distance, midpoint & slope calculator. For a physical ramp or roof slope expressed as a percentage grade, see the ramp slope & length calculator.