DoubleCheckCalc

All tools

Slope calculator

Slope from two points: rise over run, the line's equation and its angle

Type the x and y of two points. The example uses (1, 2) and (4, 8).

–

Equation of the line
–
Angle with the x-axis
–
As a percent grade
–
Distance between the points
–

Working, step by step

    How slope is worked out

    Slope measures how steep a line is: how far it goes up (the rise) for each step across (the run). With two points (x₁, y₁) and (x₂, y₂), slope m = (y₂ − y₁) ÷ (x₂ − x₁). For (1, 2) and (4, 8): the rise is 8 − 2 = 6, the run is 4 − 1 = 3, so the slope is 6 ÷ 3 = 2. In the UK and India slope is often called the gradient.

    Reading the answer

    A positive slope goes up from left to right; a negative slope goes down; a slope of 0 is flat. If both points have the same x, the line is vertical, the run is zero, and the slope is undefined because you cannot divide by zero. It does not matter which point you call the first: swapping them changes the sign of both rise and run, and the slope stays the same.

    The equation of the line

    Every non-vertical line can be written y = mx + b, where b is the point where the line crosses the y-axis. Once m is known, b = y₁ − m × x₁. For the example, b = 2 − 2 × 1 = 0, so the line is y = 2x. Fractions are kept exact, so a slope of 1/3 is not turned into 0.333.

    Angle, grade and distance

    The angle with the x-axis is the inverse tangent of the slope. The percent grade, used for roads, ramps and roofs, is the slope × 100: a slope of 0.05 is a 5% grade. The distance between the points comes from Pythagoras: √(run² + rise²).

    Formula and sources

    Related tools