Slope Calculator

Enter two points to get the slope of the line through them, along with the rise, the run, the percent grade and the angle of incline.

Inputs

Point 1

Point 2

Try an example

Slope (m)

2/3

Positive slope: the line rises as x increases.

Rise (Δy)
4
Run (Δx)
6
Decimal
0.666667
Simplified fraction
2/3
Percent grade
66.6667%
Angle of incline
33.6901°
Type
Positive (rising)

−3−2−1012345−10123456run = 6rise = 4A (−2, 1)B (4, 5)

Step-by-step solution

  1. Start with the slope formula.

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

  2. Substitute the coordinates.

    m = (5 − 1) / (4 − (−2))

  3. Subtract to find the rise and the run.

    m = 4 / 6

  4. Reduce the fraction.

    m = 2/3

  5. Divide to get the decimal value.

    m = 0.666667

The slope formula

m = (y₂ − y₁) / (x₂ − x₁) rise divided by run

m = tan(θ) θ is the angle of incline

m
the slope of the line
(x₁, y₁)
the first point
(x₂, y₂)
the second point
θ
the angle between the line and the positive x-axis

Slope compares two changes: how far the line moves up or down (the rise, Δy = y₂ − y₁) and how far it moves across (the run, Δx = x₂ − x₁). A slope of 3 means the line climbs 3 units for every 1 unit it moves to the right. A slope of −½ means it falls half a unit for every unit across.

The rise and the run are the two legs of a right triangle that sits under the segment. The segment itself is the hypotenuse, so its length comes from the distance formula, and the angle at the base is the angle of incline.

Worked example

Find the slope of the line through (1, 7) and (5, −1).

Rise = −1 − 7 = −8

Run = 5 − 1 = 4

m = −8 / 4 = −2

The line falls 2 units for every 1 unit to the right. As a percent grade that is −200%, and the angle of incline is tan⁻¹(−2) ≈ −63.43°, measured from the x-axis. The negative sign means the line is pointing downhill.

Swap the points and nothing changes: (7 − (−1)) / (1 − 5) = 8 / −4 = −2. The "Falling line" example above loads these values so you can check the steps.

What the slope tells you

SlopeThe lineExample
PositiveRises from left to rightm = 2/3
NegativeFalls from left to rightm = −2
ZeroHorizontal: the rise is 0y = 4
UndefinedVertical: the run is 0x = 3

Steepness depends on the size of the slope, ignoring its sign. A slope of −5 is steeper than a slope of 2, even though it points the other way. When two lines have the same slope they are parallel, and when the slopes multiply to −1 the lines are perpendicular.

Slope as a grade and as an angle

Road signs and ramp specifications use percent grade, which is the slope multiplied by 100. A ramp that rises 1 unit for every 12 units of run has a slope of 1/12, a grade of about 8.33%, and an angle of about 4.76°.

Grade and angle are not interchangeable. The angle is tan⁻¹(m), so a 100% grade (slope 1) is 45°, not 90°. A line only reaches 90° when it is vertical, and then the grade is undefined. For small slopes the two numbers look similar, a 6% grade is about 3.43°, but they drift apart quickly as the line gets steeper.

If you also need the distance along the slope, enter the same points in the distance calculator. To write the line as an equation, continue to the line equation calculator.

Common slopes at a glance

A slope of 1 is a 45° line. Percent grade is the slope written as a percentage, so a road that rises 8 m for every 100 m of horizontal distance has a grade of 8%. Horizontal lines have slope 0, and vertical lines have no slope at all.

PointsSlopePercent gradeAngle of inclineType
(0, 0) to (1, 1)1100%45°Positive (rising)
(0, 0) to (2, 1)1/250%26.5651°Positive (rising)
(0, 0) to (1, 2)2200%63.4349°Positive (rising)
(0, 0) to (4, 3)3/475%36.8699°Positive (rising)
(1, 2) to (4, 8)2200%63.4349°Positive (rising)
(0, 0) to (1, −1)−1−100%−45°Negative (falling)
(0, 3) to (5, 3)00%0°Zero (horizontal)
(2, 1) to (2, 5)UndefinedUndefined90°Vertical line

Frequently asked questions

Does the order of the points matter?

Not as long as you subtract in the same order on the top and the bottom. Swapping the two points flips the sign of the rise and the sign of the run, and the two flips cancel. Mixing the order, such as y₂ − y₁ over x₁ − x₂, gives the wrong sign.

Why is the slope of a vertical line undefined?

On a vertical line both points share an x-coordinate, so the run is 0 and the formula asks for a division by zero. No number can stand in for that result, so the slope is undefined. Some textbooks say a vertical line has "no slope"; both phrases mean the same thing. It is not the same as a slope of zero, which belongs to a horizontal line.

What happens if both points are the same?

A single point does not define a line. Infinitely many lines pass through it, each with a different slope, so the calculator reports that a unique slope cannot be determined rather than inventing a value. Move one point to get a result.

Is slope the same as gradient?

For a straight line, yes. "Gradient" is the usual word in the UK, in geography and in road and rail engineering. In multivariable calculus the word gradient has a different meaning, a vector of partial derivatives, so the two should not be mixed up there.

How does the calculator find the simplified fraction?

With whole-number coordinates it divides the rise and the run by their greatest common divisor. With decimals it looks for a fraction with a denominator up to 10,000 that matches the slope to about ten significant digits. If none exists, it says the slope is not a simple fraction and you can use the decimal value.

How do I write the equation of the line?

Once you have the slope, use the line equation calculator to get y = mx + b and the other forms from the same two points. If you already know the slope and one point, the point-slope calculator is more direct.