Skip to content

Slope Calculator: Slope, Equation and Angle of a Line

Find the slope, line equation, angle, distance and midpoint between two points. Learn rise over run, y = mx + b and how to read positive and negative slopes.

4 min read

The slope of a line measures how steep it is: how far it rises or falls for every step to the right. It is one of the core ideas of algebra and shows up in everything from road gradients to rates of change in science and business. Our slope calculator takes two points and gives the slope, the equation of the line, its angle, the distance between the points and the midpoint. This guide explains each result.

How to use the calculator

Enter the coordinates of two points: (x₁, y₁) and (x₂, y₂). With the defaults, (1, 2) and (4, 8):

  • Slope m: 2
  • Equation: y = 2x + 0
  • Angle: 63.43°
  • Distance: 6.7082
  • Midpoint: (2.5, 5)

The slope formula

Slope is "rise over run": the change in y divided by the change in x.

For (1, 2) and (4, 8):

  1. Rise: 8 − 2 = 6.
  2. Run: 4 − 1 = 3.
  3. Slope: 6 ÷ 3 = 2.

So for every 1 step to the right, the line goes up 2. It does not matter which point you call first, as long as you use the same order on the top and bottom.

Reading the slope

SlopeLine
PositiveRises from left to right
NegativeFalls from left to right
ZeroHorizontal
UndefinedVertical (the run is zero)

The bigger the number, ignoring its sign, the steeper the line. A slope of 0.5 is gentle; a slope of 10 is very steep.

The equation of the line

Most lines can be written in slope-intercept form:

Here m is the slope and b is the y-intercept, where the line crosses the y-axis. To find b, put one point into the equation: 2 = 2 × 1 + b, so b = 0. The line is y = 2x, passing through the origin.

Another example: points (2, 5) and (6, 3). Slope = (3 − 5) ÷ (6 − 2) = −2 ÷ 4 = −0.5. Then 5 = −0.5 × 2 + b, so b = 6, and the line is y = −0.5x + 6.

Angle of the line

The angle the line makes with the positive x-axis comes from the inverse tangent of the slope:

For m = 2: θ = tan⁻¹(2) = 63.43°. A slope of 1 gives 45°, and a negative slope gives a negative angle, meaning the line points downward.

Distance and midpoint

The distance between the points uses the Pythagorean theorem, with the rise and run as the two legs:

√(3² + 6²) = √45 ≈ 6.7082. The distance calculator and Pythagorean theorem calculator use the same idea.

The midpoint is the average of the coordinates:

((1 + 4) ÷ 2, (2 + 8) ÷ 2) = (2.5, 5).

Parallel and perpendicular lines

  • Parallel lines have the same slope.
  • Perpendicular lines have slopes that multiply to −1. A line perpendicular to slope 2 has slope −1/2.

Slope in the real world

  • Roads and ramps: a 5% grade rises 5 m for every 100 m travelled, a slope of 0.05. Wheelchair ramps are often limited to about 1:12, a slope of 0.083. The stair calculator and roofing calculator work with rise and run too.
  • Roof pitch: a 6/12 pitch rises 6 inches per 12 inches across, a slope of 0.5, or about 26.6°.
  • Rates of change: on a graph of distance against time, the slope is the speed. On a graph of cost against units, it is the cost per unit. The speed calculator is a direct example.
  • Trends in data: the slope of a trend line shows how fast something is growing or shrinking. The statistics calculator helps summarise data.

Common mistakes

  • Subtracting the points in a different order on the top and bottom, which flips the sign.
  • Putting x on top: slope is change in y over change in x.
  • Treating a vertical line as having slope zero. A vertical line's slope is undefined; a horizontal line's is zero.

Frequently asked questions

What does a slope of zero mean?

The line is horizontal. The y-value stays the same however far you move along the x-axis.

Why is a vertical line's slope undefined?

Both points have the same x-value, so the run is zero, and dividing by zero is undefined.

How do I convert slope to a percentage grade?

Multiply the slope by 100. A slope of 0.08 is an 8% grade.

Can I use decimals or negative numbers?

Yes. Any real coordinates work, including negatives and decimals.

Share

Try it yourself

Run your own numbers with our free tool: Slope calculator. No sign-up, and it works on any device.

Open the calculator