The Slope Formula, Explained with Examples
By ToolNimba Editorial Team June 20, 2026 5 min read
Quick answer
The slope formula is m = (y2 - y1) / (x2 - x1), which is rise over run. Pick any two points on a line, subtract the y values for the rise, subtract the x values for the run, then divide. A positive slope rises from left to right and a negative slope falls.
Slope is a single number that tells you how steep a line is and which way it tilts. Every straight line has one constant slope, so you can measure it using any two points that sit on the line. Once you know the slope, you can predict how much the line climbs or drops for each step you take to the right.
What the slope formula actually says
Given two points labeled (x1, y1) and (x2, y2), the slope is the change in y divided by the change in x. In symbols that is m = (y2 - y1) / (x2 - x1). The top of the fraction is the vertical change, often called the rise. The bottom is the horizontal change, often called the run. So slope is literally rise over run.
Think of it as a rate. A slope of 2 means the line goes up 2 units for every 1 unit you move right. A slope of 0.5 means it goes up half a unit for every unit right, a gentler climb. The bigger the absolute value, the steeper the line.
How to use the slope formula step by step
Suppose a line passes through the points (1, 2) and (4, 8). Here is how to find its slope.
- Label your points. Call (1, 2) point one, so x1 is 1 and y1 is 2. Call (4, 8) point two, so x2 is 4 and y2 is 8.
- Find the rise. Subtract the y values: y2 - y1 equals 8 - 2, which is 6.
- Find the run. Subtract the x values in the same order: x2 - x1 equals 4 - 1, which is 3.
- Divide rise by run. 6 divided by 3 equals 2.
- Read the result. The slope m is 2, a positive number, so the line rises and climbs 2 units for every 1 unit to the right.
The order does not matter as long as you stay consistent. If you start with point two on top, you must also start with point two on the bottom: (2 - 8) / (1 - 4) equals -6 / -3, which is still 2. What breaks the answer is mixing the order between the top and the bottom.
Reading positive, negative, zero, and undefined slopes
The sign and size of the slope tell a quick story about the line before you even graph it. Use this reference to translate a number into a picture.
What different slope values mean
| Slope value | What the line does | Example |
|---|---|---|
| Positive (m greater than 0) | Rises from left to right | m = 2 climbs steeply upward |
| Negative (m less than 0) | Falls from left to right | m = -1 drops at 45 degrees |
| Zero (m = 0) | Perfectly flat, horizontal | A level road, no rise |
| Undefined | Vertical line, run is 0 | Dividing by zero is undefined |
| Small fraction (near 0) | Gentle, nearly flat slope | m = 0.25 climbs slowly |
| Large value (far from 0) | Very steep line | m = 10 climbs sharply |
One special case trips people up. A vertical line has the same x value at every point, so the run (x2 - x1) is zero. Dividing by zero is not allowed, which is why a vertical line has an undefined slope rather than an infinite one. A horizontal line is the opposite: the rise is zero, so the slope is exactly zero.
Where slope shows up in real life
Slope is not just a classroom idea. It is the math behind any constant rate of change, which is why it appears all over everyday measurement.
- Roads and ramps. A road grade of 6 percent is a slope of 0.06, meaning 6 feet up for every 100 feet forward.
- Roofs and stairs. Builders describe roof pitch and stair rise over run using the exact same ratio.
- Wheelchair access. Accessibility codes cap ramp slope so the climb stays safe and gentle.
- Data and trends. On a chart of cost over time, the slope is the rate something grows or shrinks, the same idea behind average rate of change.
- Physics. On a distance versus time graph, the slope is speed, which links directly to the velocity formula.
Common mistakes to avoid
Most slope errors come from small slips in setup rather than hard math. Watch for these.
- Mixing the order. If y2 is on top of the fraction, x2 must lead the bottom. Subtracting the y values one way and the x values the other way flips the sign and gives a wrong answer.
- Putting run over rise. Slope is rise over run, not run over rise. If you divide x change by y change you get the reciprocal, a different line.
- Forgetting the sign. A line that falls has a negative slope. Dropping the minus sign turns a downhill line into an uphill one.
- Calling a vertical line slope zero. A flat horizontal line has slope zero. A vertical line has an undefined slope because the run is zero.
- Reading points off the graph carelessly. Use grid points where the line clearly crosses an intersection so your x and y values are exact.
Slope and the equation of a line
Once you have the slope, you can write the whole line. The slope intercept form is y = mx + b, where m is the slope you just found and b is the y value where the line crosses the vertical axis. From our worked example the slope was 2, so the line looks like y = 2x + b, and plugging in one known point solves for b.
Slope also pairs naturally with two related coordinate tools. The midpoint formula finds the point halfway between two coordinates, while the distance formula measures the straight line length between them. Together with slope, these three let you fully describe a segment on the plane.
Calculate slope instantly
Enter two points below and the slope calculator returns the slope, shows the rise and run, and tells you whether the line rises, falls, or is flat. You can also try the slope calculator directly for repeated checks.
๐ Try the free tool Slope Calculator Free slope calculator. Enter two points to find the slope (gradient), the line equation y = mx + b, the distance between the points, and the angle of incline.The slope formula rewards a calm, consistent setup: pick two points, find the rise, find the run, and divide. Keep the subtraction order matched between top and bottom, respect the sign, and remember that flat lines are zero while vertical lines are undefined. With those habits, slope becomes one of the most reliable tools in coordinate geometry.
Frequently asked questions
What is the slope formula?
The slope formula is m = (y2 - y1) / (x2 - x1), which is rise over run. You pick any two points on a line, subtract the y values to get the rise, subtract the x values to get the run, then divide. The result tells you how steeply the line tilts.
What does rise over run mean?
Rise over run means vertical change divided by horizontal change. The rise is how far the line goes up or down between two points, and the run is how far it moves sideways. Dividing rise by run gives the slope, a single number describing the line's steepness and direction.
What does a negative slope look like?
A negative slope means the line falls as you move from left to right, like going downhill. The steeper the descent, the larger the absolute value. For example, a slope of -2 drops 2 units for every unit to the right, while -0.5 falls gently.
Why is the slope of a vertical line undefined?
A vertical line has the same x value at every point, so the run (x2 - x1) equals zero. The slope formula would then divide by zero, which is not allowed in math. Because of that, a vertical line has an undefined slope rather than a numeric value.
Does it matter which point you call point one?
No, as long as you stay consistent. Whichever point you subtract first on the top of the fraction, subtract it first on the bottom too. If you keep the order matched, swapping the points gives the exact same slope. Mixing the order is what produces a wrong sign.
What is the difference between zero slope and undefined slope?
A zero slope is a flat horizontal line, where the rise is zero so the result is exactly 0. An undefined slope is a vertical line, where the run is zero so you cannot divide. One is perfectly level, the other points straight up and down.