Slope Calculator
This slope calculator finds the slope of the line through any two points — and keeps it as an exact fraction, shows the rise and the run separately, and swaps the two points to prove the order makes no difference.
Type (2, 5) and (7, 14) and the answer is 9/5. Not 1.8, which is the same number written less usefully: 9 over 5 tells you the line climbs 9 for every 5 across, and that is what you need in order to draw it.
How to Calculate the Slope of a Line
Three steps, and the whole method fits in a line.
1. Find the rise. Subtract the two y values: y₂ − y₁. This is how far the line goes up.
2. Find the run. Subtract the two x values in the same order: x₂ − x₁. This is how far it goes across.
3. Divide. m = rise ÷ run.
Worked through with (2, 5) and (7, 14):
rise = 14 − 5 = 9
run = 7 − 2 = 5
m = 9 ÷ 5 = 9/5
That is it. The letter m is the standard symbol for slope, and you will also see slope called the gradient, which means the same thing.
What the Formula Is Really Saying
m = (y₂ − y₁) ÷ (x₂ − x₁)
Slope is steepness turned into a number: how far up for every step to the right. A slope of 3 means the line climbs 3 units for every 1 across. A slope of 1/2 means it climbs 1 for every 2 across — half as steep.
The most useful thing about it is that every pair of points on the same straight line gives the same answer. Pick two other points on that line and you will still get 9/5. That is what makes slope a property of the line itself rather than of the points you happened to choose, and it is the reason one number can describe a whole line.
The differences are often written Δy and Δx — "delta y" and "delta x", where delta just means "change in". So m = Δy / Δx is the same formula in shorter clothes.
Does It Matter Which Point You Use First?
This is the question almost everybody has, and the answer is no.
Take the same two points the other way round. The rise becomes 5 − 14 = −9 and the run becomes 2 − 7 = −5. Dividing: −9 ÷ −5 = 9/5. The same answer, because both differences changed sign and two sign changes cancel.
This calculator works it out both ways round every time and shows you the second one, rather than telling you to take it on trust.
What does matter is consistency. Subtract the y values and the x values in the same order. If you take y₂ − y₁ on top but x₁ − x₂ underneath, you get the right number with the wrong sign — and a line that should climb will appear to fall. That is the mistake this formula actually invites, and it is a sign error rather than an arithmetic one, which is why it slips past so easily.
Zero Slope and Undefined Slope Are Not the Same
Here is the part that causes the most trouble, and some otherwise reliable sources get it wrong in print.
| Horizontal line | The rise is 0. m = 0 — a real number. Equation: y = c |
| Vertical line | The run is 0. m is undefined — there is no answer. Equation: x = c |
A horizontal line has a slope, and that slope is zero. Zero is an ordinary number; you can put it into any formula and it behaves. The points (1, 3) and (6, 3) give a rise of 0 over a run of 5, and 0 ÷ 5 = 0.
A vertical line has no slope at all. The points (4, 1) and (4, 9) give a rise of 8 over a run of 0 — and nothing can be divided by zero, so there is simply no answer. "Undefined" does not mean very large or infinite; it means the question has no result.
So the phrase "a line with no slope" belongs to the vertical case, never the horizontal one. If you remember one thing from this page, make it that: zero is an answer, undefined is the absence of one.
There is a third case worth knowing, and most calculators handle it badly. If you give the same point twice — say (3, 7) and (3, 7) — the run is 0, so a calculator that only checks whether the x values match will report a vertical line. That is wrong. One point does not fix a line at all; infinitely many lines pass through it, at every slope there is. This page says so instead of guessing.
Reading the Number Back
Once you have m, it tells you two separate things: which way the line goes, and how steep it is.
| m > 0 | The line rises from left to right |
| m < 0 | The line falls from left to right |
| m = 0 | Horizontal — perfectly level |
| undefined | Vertical — straight up |
The sign gives the direction; the size gives the steepness, ignoring the sign. So −5 is steeper than 2, even though it is the smaller number, because 5 is bigger than 2. A slope of −1/10 is very nearly flat and heading gently downhill.
The angle of incline is the same information in degrees: θ = arctan(m). A slope of 1 is exactly 45°, which is the one everyone remembers. Most other slopes give an angle that has to be rounded — 9/5 works out at about 60.9° — so this page shows the angle but marks it as rounded, while the slope itself stays exact.
Slope Outside the Maths Classroom
Slope is not only a homework topic. The same number, under different names, decides how buildings and roads get built.
Roof pitch is slope with the run fixed at 12. A roof described as "4 in 12" rises 4 units for every 12 across, so its slope is 4/12 = 1/3. Builders keep the 12 because it makes different roofs instantly comparable.
Ramps are the strictest case. A wheelchair ramp is commonly required not to exceed 1 in 12 — a slope of 1/12, or about 8.3%. That is why a doorway 30 cm above the path needs at least 360 cm of ramp to reach it: 30 × 12. Getting this arithmetic wrong is not a marks problem, it is an access problem.
Road grade is slope written as a percentage: multiply m by 100. The road sign warning of a 6% grade is telling you the slope is 0.06, or 6 metres of drop for every 100 along. This calculator gives the grade alongside the fraction for exactly that reason.
In every one of these, the calculation is the one at the top of this page. Only the vocabulary changes. More tools for lines and equations are on the algebra calculators page.
How to Use This Slope Calculator
Four boxes, arranged as two points.
| x₁, y₁ | The first point. An empty box counts as 0 |
| x₂, y₂ | The second point |
| ← → ↑ ↓ | Move between the boxes |
| ± | Flips the sign, for a negative coordinate |
| ⁄ and . | Fraction bar and decimal point |
| ⌫ / AC | Delete one character, or clear everything |
| = | Works it out |
Fractions like 3/4 and decimals like 0.25 both work as coordinates, and either way the slope comes back exact. Open the working and you get the rise and the run separately, the division, the same sum done the other way round as a check, and the direction, angle and grade written out.
Two examples worth tapping: horizontal and vertical, side by side, which is the quickest way to see that zero and undefined really are different answers.
Slope Calculator FAQ
How do you calculate the slope of a line?
Does it matter which point you use first?
What is the difference between zero slope and undefined slope?
Is a horizontal line a line with no slope?
Should the slope be left as a fraction or written as a decimal?
What does a slope of 1/12 mean on a ramp?
Rise over run, kept as a fraction, with the two points swapped to prove the order never mattered — and zero and undefined kept firmly apart.