ToolNimba
๐Ÿ”ข Math & Numbers

The Slope Formula, Explained with Examples

Shihab Mia By Shihab Mia June 20, 2026 8 min read

A line on a coordinate grid showing rise over run between two points

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.

Right triangle showing vertical rise and horizontal run between two points on a line
Slope is the rise (vertical change) divided by the run (horizontal change) between two points.

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.

  1. 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.
  2. Find the rise. Subtract the y values: y2 - y1 equals 8 - 2, which is 6.
  3. Find the run. Subtract the x values in the same order: x2 - x1 equals 4 - 1, which is 3.
  4. Divide rise by run. 6 divided by 3 equals 2.
  5. 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.

Now try a line that falls. Suppose it passes through (0, 5) and (4, 1). The rise is y2 - y1, which is 1 - 5, or -4. The run is x2 - x1, which is 4 - 0, or 4. Dividing gives -4 / 4, so m = -1. The negative sign confirms the line drops, and the value of 1 tells you it falls exactly 1 unit for every unit you move right. When your points include a fraction, keep them as fractions rather than rounding early, because rounding the rise or run first can throw off the final slope.

Slope formula at a glance

m = (y2 - y1) / (x2 - x1). Rise is the top (change in y). Run is the bottom (change in x). Subtract in the same order on top and bottom. A rising line is positive, a falling line is negative, a flat line is zero, and a vertical line is undefined.

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 valueWhat the line doesExample
Positive (m greater than 0)Rises from left to rightm = 2 climbs steeply upward
Negative (m less than 0)Falls from left to rightm = -1 drops at 45 degrees
Zero (m = 0)Perfectly flat, horizontalA level road, no rise
UndefinedVertical line, run is 0Dividing by zero is undefined
Small fraction (near 0)Gentle, nearly flat slopem = 0.25 climbs slowly
Large value (far from 0)Very steep linem = 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. You can turn a rise and run into a grade with the ramp calculator.
  • Roofs and stairs. Builders describe roof pitch and stair rise over run using the exact same ratio, often written as a number like 4 in 12.
  • Wheelchair access. Accessibility codes cap ramp slope so the climb stays safe and gentle, commonly at 1 unit of rise for every 12 units of run, a slope of about 0.083.
  • 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.
  • Finance and pricing. A cost line that charges a flat fee plus a rate per unit has a slope equal to the per unit rate, which is why slope is the backbone of many pricing and budgeting formulas.

Good to know: parallel and perpendicular slopes

Slope also tells you how two lines relate. Parallel lines have equal slopes, and perpendicular lines have slopes that are negative reciprocals, meaning they multiply to -1. These two rules let you compare lines without graphing them, which is handy in geometry proofs and design work.

  • Parallel lines. Two lines are parallel when they share the same slope. A line with slope 3 is parallel to any other line with slope 3, no matter where each one crosses the axis.
  • Perpendicular lines. Flip the slope and change its sign to get the perpendicular slope. A line with slope 2 is perpendicular to a line with slope -1/2, since 2 times -1/2 equals -1.
  • Horizontal and vertical. A horizontal line (slope 0) and a vertical line (undefined slope) are perpendicular to each other, the one pair the reciprocal rule cannot cover because you cannot divide by zero.

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.

Here is that final step in full. We know the line has slope 2 and passes through (1, 2). Substitute those numbers into y = 2x + b to get 2 = 2 times 1 plus b, which is 2 = 2 + b. Subtract 2 from both sides and b = 0, so the equation is y = 2x. Now you can find the y value for any x without graphing. If a question instead gives you the slope and one point directly, the point slope form y - y1 = m(x - x1) skips straight to the equation using the same two ingredients.

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.

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.

How do you find slope from an equation like y = mx + b?

In slope intercept form, y = mx + b, the slope is simply the number m in front of x. For example, in y = 3x + 4 the slope is 3, and in y = -2x + 1 the slope is -2. The value b only sets where the line crosses the y axis, not its steepness.

How do you find slope with only one point?

You cannot find slope from a single point alone, because slope measures change between two locations. You need either a second point, the line's equation, or a stated rate such as a grade or rise over run. With any one of those, the slope becomes fixed and calculable.

Can slope be a decimal or fraction?

Yes. Slope is just rise divided by run, so it can be a whole number, a fraction, or a decimal. A slope of 1/2 or 0.5 means the line climbs half a unit for every unit right. Fractions are often more exact than rounded decimals, so keep them as fractions when precision matters.

Tools used in this guide

Keep reading