StatGardenREF. DESK
Calculators/Maths/Gradient (Slope) of a Line
Maths

Gradient (Slope) of a Line calculator

Gradient between two coordinate points, plus the equation of the line through them.

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

Formulam = (y2 − y1) ÷ (x2 − x1) · line equation: y = mx + c, where c = y1 − m·x1

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.

TermMeaning
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 runThe vertical change (rise) and horizontal change (run) between two points; gradient is rise ÷ run.

The inputs explained

FieldWhat to enter
x1The x-coordinate of the first point.
y1The y-coordinate of the first point.
x2The x-coordinate of the second point.
y2The 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.

First point fixed at (0, 0)
x2 (y2 fixed by the pattern below)Gradient (m)
114.000
27.000
34.667
43.500
52.800
101.400
This table holds y2 at its default value of 14 while x2 changes, so the gradient falls as x2 grows, since the same 14-unit rise is spread over a wider run each time.

Gradient and line equation for a range of point pairs

A selection of coordinate pairs producing positive, negative, zero and steep gradients.

Point pairs with a variety of gradients
y2 (x2 fixed at 5)Gradient (m)Angle of incline
000.00°
51.00045.00°
102.00063.43°
153.00071.57°
-10-2.000-63.43°
255.00078.69°
A y2 of 0 gives a horizontal line with a gradient of zero, and a negative y2 gives a negative gradient, a line that falls from left to right rather than rising.

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.