Slope Calculator

Enter the coordinates of two points and the calculator finds the slope of the line through them, together with its angle, the distance and midpoint between the points, the intercepts and the equation of the line.

Results update as you type.

Result

Slope (m)
2
Equation of the line
y = 2x
Angle of incline
63.43°
Distance between points
6.7082
Midpoint
(2.5, 5)
Y-intercept
0
X-intercept
0
Perpendicular slope
-0.5
Rise over run (Δy / Δx)
6 / 3
Percent grade
200%

What is slope?

Slope measures how steep a straight line is and which way it leans. It is the ratio of the vertical change (the rise) to the horizontal change (the run) between any two points on the line, and it is usually written as m. A slope of 2 means the line climbs 2 units for every 1 unit it moves to the right. The same number appears as the m in the equation y = mx + b, as the gradient of a road or roof, and as the rate of change on any graph: the slope of a distance–time graph is speed, and the slope of a cost line is the price per unit.

Slope formula (rise over run)

m = (y₂ − y₁) ÷ (x₂ − x₁) = rise ÷ run

Worked example: for the points (1, 2) and (4, 8), the rise is 8 − 2 = 6 and the run is 4 − 1 = 3, so m = 6 ÷ 3 = 2. The line climbs 6 units while moving 3 units to the right. Its angle of incline is tan⁻¹(2) ≈ 63.43°. It does not matter which point you call point 1 as long as you subtract in the same order for both coordinates: (2 − 8) ÷ (1 − 4) = −6 ÷ −3 = 2 again.

Slope-intercept form

Every non-vertical line can be written as y = mx + b, where b is the y-intercept, the point where the line crosses the vertical axis. To find b, substitute either point into the equation: b = y₁ − m × x₁ = 2 − 2 × 1 = 0. The line in the example is therefore y = 2x. The x-intercept, where y = 0, is −b ÷ m = 0, so this line passes through the origin. In point-slope form the same line is y − 2 = 2(x − 1). Any line parallel to it also has slope 2; any line perpendicular to it has the negative reciprocal slope, −1 ÷ 2 = −0.5.

Distance and midpoint

The straight-line distance between the two points comes from the distance formula, d = √[(x₂ − x₁)² + (y₂ − y₁)²], which is the Pythagorean theorem with the run and rise as the two legs of a right triangle. For the example: √(3² + 6²) = √(9 + 36) = √45 ≈ 6.7082.

The midpoint is simply the average of the coordinates: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2) = ((1 + 4) ÷ 2, (2 + 8) ÷ 2) = (2.5, 5).

Interpreting the slope

SlopeWhat the line doesExample
PositiveRises from left to righty = 2x
NegativeFalls from left to righty = −x + 4
ZeroHorizontal (rise is 0)y = 3
UndefinedVertical (run is 0)x = 2

The size of the slope tells you the steepness: a slope of magnitude 1 makes a 45° angle, anything larger is steeper than 45° and anything smaller is flatter. Fractions and decimals are both fine; a slope of ¾ and a slope of 0.75 describe the same line.

How to use this calculator

  1. Enter the x and y coordinates of the first point. Decimals and negative numbers are allowed.
  2. Enter the second point. The results update as you type.
  3. Read the slope, the equation of the line and the other values. If both x values are equal the line is vertical and the slope is shown as undefined; if the two points are identical no line is defined.

Slope in the real world: percent grade

Engineers and road builders quote slope as a percentage: grade = slope × 100. A 6% highway grade rises 6 meters for every 100 meters of horizontal distance, an angle of only 3.4°. Accessibility codes limit wheelchair ramps to 1:12, which is 8.33% or 4.8°. Railways rarely exceed 2–3%, a 4:12 roof pitch is a 33% grade (18.4°), and most stairs sit around 30–37°. Remember that 100% grade means a 45° angle, not a vertical wall. The example line, with its 200% grade, is far steeper than any road.

Common mistakes

  • Mixing the order of subtraction: (y₂ − y₁) over (x₁ − x₂) flips the sign of the slope.
  • Dividing run by rise: slope is always vertical change over horizontal change.
  • Calling a vertical line's slope zero: zero slope is horizontal; vertical is undefined.
  • Confusing percent and degrees: 50% grade is 26.57°, not 50°. Use the inverse tangent to convert.
  • Reading slope off a graph with unequal axis scales: the line may look steeper or flatter than its true slope. Use the coordinates, not the picture.

Frequently asked questions

What is the slope of a vertical line?

It is undefined. The run (x₂ − x₁) is zero, and dividing the rise by zero has no value. The line has the equation x = c, where c is the shared x-coordinate, and the calculator reports the slope as "Undefined" with an angle of 90°.

How do I find the slope from an equation?

Rearrange it into y = mx + b; the coefficient of x is the slope. For 2x + 3y = 6, subtract 2x and divide by 3 to get y = −⅔x + 2, so the slope is −⅔ and the y-intercept is 2. Alternatively, pick any two x values, compute the matching y values and enter the two points here.

What is the difference between slope, gradient and grade?

They describe the same ratio of rise to run. "Gradient" is the usual word in British English and engineering, while "grade" normally means the slope expressed as a percentage (slope × 100) or as a ratio such as 1:12. A 10% grade, a gradient of 0.1 and a slope of 1/10 are identical.

How do I convert a slope to an angle?

Take the inverse tangent: angle = tan⁻¹(slope). A slope of 1 is 45°, a slope of 2 is 63.43° and a slope of 0.5 is 26.57°. Note that a 100% grade is 45°, not 90°; the angle approaches 90° only as the slope grows without limit.

How are parallel and perpendicular slopes related?

Parallel lines have exactly the same slope. Perpendicular lines have slopes that are negative reciprocals of each other, so their product is −1: a line with slope 2 is perpendicular to any line with slope −½. The only exception is the horizontal–vertical pair, where one slope is 0 and the other is undefined.

Related calculators