How to use the Slope Calculator
- Enter the x and y coordinates of the first point.
- Enter the coordinates of the second point.
- Read the slope and the equation of the line.
- Use the angle, distance and midpoint if you need them for the same pair of points.
Formula used
m = (y₂ − y₁) ÷ (x₂ − x₁). Line: y = mx + b with b = y₁ − m × x₁. Distance = √((x₂ − x₁)² + (y₂ − y₁)²). Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2).
Worked example
Here is the Slope Calculator worked through with the example values shown above, so you can check each step by hand.
| Inputs | |
|---|---|
| Point 1: x₁ | 1 |
| Point 1: y₁ | 2 |
| Point 2: x₂ | 4 |
| Point 2: y₂ | 11 |
| Result | |
| Slope (m) | 3 |
| Equation of the line | y = 3x − 1 |
| Angle with the x-axis, degrees | 71.565051 |
| Distance between the points | 9.486833 |
| Midpoint | (2.5, 6.5) |
The slope formula
Slope m = rise ÷ run = (y₂ − y₁) ÷ (x₂ − x₁). For the points (1, 2) and (4, 11) the rise is 9 and the run is 3, so the slope is 3. The line goes up 3 units for every 1 unit to the right.
The equation in slope-intercept form is y = mx + b. Using b = y₁ − m × x₁ = 2 − 3 = −1 gives y = 3x − 1. You can check by putting in the second point: 3 × 4 − 1 = 11.
Positive, negative, zero and undefined slopes
A positive slope rises left to right. A negative slope falls: for (0, 5) and (4, 1) the slope is -1 and the equation is y = -x + 5. A horizontal line, such as through (0, 3) and (6, 3), has slope 0 and the equation y = 3.
A vertical line has no defined slope, because the run is zero and division by zero is not allowed. Points (2, 0) and (2, 5) give undefined (vertical line) with the equation x = 2.
Angle, distance and midpoint
The angle with the x-axis is arctan(m). For a slope of 3 it is 71.57°. The distance between the points is √(run² + rise²) = √(9 + 81) = 9.4868, and the midpoint is the average of the coordinates, (2.5, 6.5).
The distance formula is the Pythagorean theorem applied to the right triangle whose legs are the run and the rise.
Slope in everyday use
Road gradients are slopes written as a percentage: a 6% grade rises 6 metres over 100 metres of horizontal distance. Accessibility ramps are often limited to a slope of 1 in 12 (about 8.3%) in building standards such as the US ADA guidelines. Roof pitch is another slope, often written as rise over 12.
In data work, the slope of a trend line shows the rate of change: how much a quantity goes up each month, year or unit of input. The sign tells you the direction and the size tells you the steepness.
Frequently asked questions
How do I find the slope between two points?
Subtract the y-values and divide by the difference in the x-values: m = (y₂ − y₁) ÷ (x₂ − x₁).
What is the slope of a horizontal line?
Zero, because the rise is zero.
What is the slope of a vertical line?
It is undefined, because the run is zero. The line’s equation is x = a constant.
Does the order of the points matter?
No. Swapping them changes the sign of both the rise and run, so the slope is the same.
How do I turn slope into a percentage?
Multiply by 100. A slope of 0.06 is a 6% grade.
How do I get the angle in degrees?
Take the inverse tangent of the slope. A slope of 1 is 45 degrees.
This calculator gives estimates for information only. Actual figures from a bank, employer, tax authority or doctor may differ. It is not financial, tax, legal or medical advice.