Slope Calculator
Find the slope, equation, angle and intercepts of a line from two points.
What Is the Slope Calculator?
Slope is rise over run, and almost everything in coordinate geometry follows from it. Give this calculator any two points on a line and it returns the slope, the equation of the line, the angle of inclination, both intercepts, the perpendicular slope and the midpoint between the points, all from a single calculation. The definition is short enough to memorise and rich enough to derive everything else from, which is why the formula appears in every algebra course and in fields as far apart as surveying, machine learning and screen design. Two cases get particular attention here because they are where calculators usually break. A vertical line has no slope at all, since it has no run, and this explains why rather than returning infinity or a blank. A horizontal line has a perpendicular that is itself vertical, which is reported as an undefined perpendicular slope rather than an error.
Key Statistics
-
45°
The angle of inclination of a slope of 1. A slope of 1 rises one unit for every unit across, so the line sits at 45 degrees. Slopes are frequently quoted as percentages on roads, where a 6 percent grade is a slope of about 0.06 and an angle of roughly 3.4 degrees.
Source: Slope, Wikipedia
-
−1
The product of the slopes of two perpendicular lines. Two lines are perpendicular exactly when their slopes multiply to minus one, which is why the perpendicular slope is always the negative reciprocal rather than simply the opposite.
Source: Perpendicular lines, Wikipedia
-
nought point six
The maximum gradient for a main road under UK design standards, which works out to roughly a 6 percent grade or a slope of 0.06. Steeper gradients need crawler lanes for heavy goods vehicles, which is one reason the slope of a road matters in civil engineering.
Source: Highway Code, gradient of a road
The Formula
Slope equals the change in y divided by the change in x, which is (y2 minus y1) divided by (x2 minus x1). The equation of the line is y equals slope times x plus the y intercept, where the y intercept is y1 minus slope times x1. The angle of inclination is the arctangent of the slope. The perpendicular slope is minus one divided by the slope.
Worked Examples
For the points 0,0 and 4,8 the rise is 8 minus 0, which is 8, and the run is 4 minus 0, which is 4. The slope is 8 divided by 4, which is 2. The line is y equals 2x, the angle of inclination is 63.435 degrees, and the perpendicular slope is minus one half.
Slope of a line through two points
- Take the points 0,0 and 4,8.
- Find the rise: 8 minus 0 equals 8.
- Find the run: 4 minus 0 equals 4.
- Divide: 8 divided by 4 equals 2.
Slope: 2
Finding the equation of the line
- Use the points 0,1 and 1,3, which have a slope of 3 minus 1 over 1 minus 0, so 2.
- Find the y intercept by substituting the point 0,1: 1 equals 2 times 0 plus b, so b is 1.
- The equation is y equals 2x plus 1.
- Check with the second point: 2 times 1 plus 1 is 3, which matches.
y = 2x + 1
A vertical line
- Take the points 4,1 and 4,9.
- The x values are identical, so the run is 4 minus 4, which is 0.
- Dividing by zero leaves the slope undefined.
- The line is written x equals 4 and has no y intercept.
Vertical line, slope undefined
Perpendicular slope
- Take a line with slope 2.
- The perpendicular slope is minus one divided by 2.
- That is minus one half, so minus 0.5.
- Check: 2 multiplied by minus 0.5 is minus 1, which is the perpendicular condition.
Perpendicular slope: −0.5
Real World Use Cases
Engineering and surveying
Road gradients, roof pitches, drainage falls and ramp angles are all slopes expressed in different units. A 6 percent road gradient is a slope of 0.06, and misreading the conversion is how ramps end up too steep.
Machine learning and data analysis
A fitted regression line's slope tells you how strongly one variable responds to another. Changing the units of either axis changes the numerical slope without changing the underlying relationship, which is why slopes should always be quoted with their units.
Screen and interface design
Interface designers reason about gradients to convey direction and depth to users. A shallow gradient reads as a level surface and a steep one reads as a change of level, so the slope carries meaning independently of the numbers.
Everyday measurement
Checking whether a roof falls the right way for drainage, whether a ramp is too steep for a wheelchair, or how steep a hill is on a cycle computer are all slope calculations in practical clothing.
Expert Tips
- ✓ Always state the units of both axes. A slope of 0.5 metres per kilometre and a slope of 0.5 are the same number and completely different gradients.
- ✓ Convert percentage grades properly. A 6 percent grade is a slope of 0.06, not 6, and treating it as 6 overstates the gradient by a factor of 100.
- ✓ A slope is unaffected by swapping the two points, since both the rise and the run change sign together. Use whichever ordering makes the subtraction easier.
- ✓ Use the product equals minus one test to check for perpendicular lines rather than comparing slopes directly.
- ✓ A slope of zero means a horizontal line, which has no perpendicular slope in the finite sense, since the perpendicular is vertical.
Frequently Asked Questions
How do I calculate the slope of a line? ▼
Divide the change in y by the change in x. For the points 0,0 and 4,8 that is 8 minus 0 over 4 minus 0, which is 8 divided by 4, giving a slope of 2.
What is the formula for slope? ▼
Slope equals (y2 minus y1) divided by (x2 minus x1). It is sometimes written as rise over run, where rise is the vertical change and run is the horizontal change.
How do I find the equation of a line from two points? ▼
Find the slope first, then substitute one point into y equals slope times x plus b to get b. For 0,1 and 1,3 the slope is 2 and substituting gives b equals 1, so the line is y equals 2x plus 1.
What is the angle of inclination? ▼
The angle the line makes with the positive x axis, measured anticlockwise. It is the arctangent of the slope, so a slope of 1 gives 45 degrees and a slope of 2 gives about 63.4 degrees.
What is the perpendicular slope? ▼
The negative reciprocal of the slope, which is minus one divided by the slope. Two lines are perpendicular exactly when their slopes multiply to minus one, and this is why the perpendicular is a reciprocal rather than simply the opposite.
What happens with a vertical line? ▼
The slope is undefined because a vertical line has no run, and dividing by zero is not defined. The line is instead written as x equals a constant, and its perpendicular is horizontal with a slope of zero.
How do I convert a road gradient percentage into a slope? ▼
Divide by 100. A 6 percent gradient is a slope of 0.06, and its angle of inclination is the arctangent of 0.06, which is roughly 3.4 degrees.
What does a slope of 0.5 mean in practice? ▼
The line rises 0.5 units vertically for every 1 unit horizontally. With metres on both axes that is a gradient of 0.5, or 50 percent, and an angle of inclination of about 26.6 degrees. In different axis units the same number means a different physical gradient.
Is a positive slope always an upward line? ▼
No. A positive slope means y increases as x increases, which is a rise when read left to right on a conventional graph. If the axes are reversed, flipped in a screen design, or measured differently, the same positive slope can appear to fall.
Can two points give the same line regardless of order? ▼
Yes. Swapping the two points changes the sign of both the rise and the run, and a fraction with both signs flipped has the same value. The line, slope, intercepts and angle are all unchanged.
Common Mistakes to Avoid
- ⚠ Inverting the ratio and dividing the run by the rise, which gives the reciprocal rather than the slope.
- ⚠ Forgetting to convert a percentage grade into a decimal slope, so 6 percent becomes 6 rather than 0.06.
- ⚠ Mixing units between the two points, such as feet for one and metres for the other, which produces a meaningless number.
- ⚠ Expecting a slope for a vertical line, where dividing by a run of zero leaves it undefined.
- ⚠ Assuming a positive slope means the line goes up, which is only true when reading left to right with y increasing upward.
Related Tools & Comparisons
Last updated: · by CalculatorPro Tools