CalcKit CalcKit
My Calculators
Sign in Sign up

Slope Calculator

Point 1
Point 2
Slope
Line equation

Table of Contents

Slope definition

The slope of a line tells how steep it is and in which direction it goes. It is the change in height, the rise, divided by the change in horizontal position, the run, between any two points on the line. It is usually written m.

A straight line has the same slope everywhere, so any two of its points give the same answer. A slope of m = 2 means the line goes up 2 units for every 1 unit to the right; a slope of m = -0.5 means it goes down half a unit for every unit to the right.

Slope is the basis of the line equation y = m * x + b, and it appears everywhere a steepness is measured: roads and ramps (as a grade in percent), roofs, graphs of speed and growth, and the gradient of a hill. For the slope of a ramp, a roof or the ground, the slope gradient calculator works directly with rise, run and slope length.

The slope formula

The slope of the line through the points (x₁, y₁) and (x₂, y₂) is the rise divided by the run:

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

Example: find the slope of the line through (1, 2) and (4, 8).

  1. The rise. The difference of the y values:

    Δy = 8 - 2 = 6

  2. The run. The difference of the x values:

    Δx = 4 - 1 = 3

  3. Divide.

    m = 6 / 3 = 2

The line goes up 2 units for every unit to the right. It doesn't matter which point you call the first, as long as you subtract in the same order on the top and the bottom.

Parts of the slope calculator

Enter two points, and the calculator finds the slope, the angle, the grade, the rise and run, the distance between the points, and where the line crosses the axes. It also works the other way: enter one point with the slope, the angle or the grade, and one coordinate of the second point (or the distance), and it finds the second point.

The two points

The two points the line goes through, (x₁, y₁) and (x₂, y₂), each given by its x and y coordinates.

If you know the first point and the slope, the second point can be found from either of its coordinates:

  • If you know x₂:

    y₂ = y₁ + m * (x₂ - x₁)

  • If you know y₂:

    x₂ = x₁ + (y₂ - y₁) / m

Slope (m)

The slope is the rise divided by the run. It is positive when the line goes up from left to right, and negative when it goes down.

It can be found with the following formulas:

  • If you know both points:

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

  • If you know the angle:

    m = tan(θ)

  • If you know the grade:

    m = grade / 100

Angle (θ)

The angle is the angle between the line and the x-axis, in degrees. It goes from -90° to 90°: positive for a line that rises, negative for one that falls.

θ = arctan(m)

A vertical line has an angle of 90° and no slope.

Grade

The grade is the slope written as a percentage, as on road signs and ramps. A 10% grade rises 10 units over a run of 100.

grade = m * 100

Rise (Δy) and run (Δx)

The rise is the vertical change between the two points, and the run the horizontal change:

  • Δy = y₂ - y₁
  • Δx = x₂ - x₁

If you only know the rise and the run, the slope is simply m = Δy / Δx.

Distance (d)

The distance is the length of the line segment between the two points, found with the Pythagorean theorem:

d = √(Δx² + Δy²)

Together with the slope it also gives the run, Δx = d / √(1 + m²), which is how the calculator finds a second point at a given distance (to the right of the first).

Y-intercept (b) and x-intercept

The y-intercept (b) is where the line crosses the y-axis, and completes the slope-intercept form of the line, y = m * x + b:

b = y₁ - m * x₁

The x-intercept is where the line crosses the x-axis:

x = -b / m

A horizontal line (m = 0) never crosses the x-axis, unless it lies on it, so it has no x-intercept. A vertical line has no y-intercept, and crosses the x-axis at its own x value.

Types of slope

  • Positive slope: the line rises from left to right, such as m = 2.
  • Negative slope: the line falls from left to right, such as m = -0.5.
  • Zero slope: the line is horizontal, as y₂ = y₁, so the rise is 0.
  • Undefined slope: the line is vertical, as x₂ = x₁, so the run is 0 and the division has no answer.

Two lines are parallel when they have the same slope, and perpendicular when their slopes multiply to -1, such as 2 and -0.5.

Frequently asked questions

How do you find the slope between two points?

Subtract the y values, subtract the x values in the same order, and divide: m = (y₂ - y₁) / (x₂ - x₁). For (1, 2) and (4, 8), that is (8 - 2) / (4 - 1) = 2.

How do you find the equation of a line from two points?

Find the slope m first, then the y-intercept from either point: b = y₁ - m * x₁. For (1, 2) and (4, 8), m = 2 and b = 2 - 2 × 1 = 0, so the line is y = 2x.

How do you convert a slope to an angle or a percentage?

The angle is θ = arctan(m), and the percentage is m × 100. A slope of 1 is an angle of 45° and a grade of 100%; a slope of 0.1 is about 5.71° and 10%.

What is the slope of a vertical line?

It is undefined. Between two points of a vertical line the run is 0, and a number can't be divided by 0. Its angle is 90°.