Resources · Education
Slope Formula
The slope formula tells you how steep a line is and which way it tilts. It is one of the most useful results in coordinate geometry, sitting alongside the distance and midpoint formulas as the third main thing you can ask about a pair of points. The formula is just a ratio: rise over run. For a fast computed answer on any two points, the slope calculator takes the four coordinates and returns the slope (or flags it as undefined) with a step-by-step breakdown.
7 min read
What is the slope formula?
The slope formula returns a number that describes the slant of the straight line through two given points (x₁, y₁) and (x₂, y₂). The result is usually written as m.
The slope tells you two things at once. The sign of m says which way the line tilts: positive rises, negative falls, zero is flat. The size of m says how steep it is: a slope of 5 means the line climbs 5 units of y for every 1 unit of x; a slope of 0.5 means it climbs only half as much.
When do you use the slope formula?
Use the slope formula whenever you have two points and want to know how the line through them behaves. Common situations:
- School algebra and coordinate-geometry problems.
- Drawing or analyzing a line on a graph.
- Finding the rate of change between two values (slope is the discrete version of a derivative).
- Engineering, physics, and economics: anywhere two values vary together and you want to describe the trend.
- Programming and graphics: line drawing, scrolling speed, physics simulations.
The slope formula
The formula is just a ratio: the change in y over the change in x. Both changes are signed, which is what makes slope able to tell direction as well as steepness.
The slope formula
m = (y₂ − y₁) / (x₂ − x₁)
The parts
- rise = y₂ − y₁
- run = x₂ − x₁
- slope = rise / run
The formula reads like a sentence: the slope is the rise divided by the run. When the run is zero (the two points share an x-coordinate), the formula is undefined and the line is vertical.
What x₁, y₁, x₂, and y₂ mean
The coordinates label the two points:
- x₁ and y₁ are the coordinates of the first point.
- x₂ and y₂ are the coordinates of the second point.
- (x₁, y₁) reads as “x sub 1, y sub 1.” The subscript just labels which point this is.
Order does not matter for the answer, as long as you are consistent on both axes. If you flip which point is point 1 and which is point 2, both the rise and the run flip signs, and the slope (a ratio of those two) comes out the same.
What matters is matching the order between rise and run. If you compute rise as y₂ − y₁ then you have to compute run as x₂ − x₁, not x₁ − x₂. Mixing the order would flip the sign of one but not the other.
Step by step slope formula example
Take the points (1, 2) and (3, 6).
- Identify the coordinates: x₁ = 1, y₁ = 2, x₂ = 3, y₂ = 6.
- Compute the rise: y₂ − y₁ = 6 − 2 = 4.
- Compute the run: x₂ − x₁ = 3 − 1 = 2.
- Divide rise by run: m = 4 / 2 = 2.
The slope is 2. The line climbs 2 units of y for every 1 unit of x as you move from left to right.
Positive slope example
Take the points (0, 0) and (4, 8).
- rise = 8 − 0 = 8
- run = 4 − 0 = 4
- m = 8 / 4 = 2
The slope is 2 (positive). The line rises from left to right.
Negative slope example
Take the points (1, 5) and (3, 1).
- rise = 1 − 5 = −4
- run = 3 − 1 = 2
- m = −4 / 2 = −2
The slope is −2 (negative). The line falls from left to right.
Zero slope example
Take the points (1, 5) and (4, 5).
- rise = 5 − 5 = 0
- run = 4 − 1 = 3
- m = 0 / 3 = 0
The slope is 0 (horizontal). The two points share a y-coordinate, so the line is perfectly flat.
Undefined slope example
Take the points (3, 1) and (3, 5).
- rise = 5 − 1 = 4
- run = 3 − 3 = 0
- m = 4 / 0 = undefined
The slope is undefined. The two points share an x-coordinate, so the run is zero, and the formula tries to divide by zero. The line is vertical. Vertical lines are sometimes described as having infinite slope, but in standard practice they simply have no defined slope.
Slope vs distance and midpoint
The slope, distance, and midpoint formulas all take the same two input points but answer different questions. They are the three main coordinate-geometry calculations on a single line segment, and learning them as a set is useful because they show up together so often.
- Slope tells you how steep the line is and which way it tilts. A single number (possibly negative or undefined). m = (y₂ − y₁) / (x₂ − x₁).
- Distance tells you how long the segment is. A single non-negative number. d = √((x₂ − x₁)² + (y₂ − y₁)²). See the distance formula calculator and the Distance Formula guide.
- Midpoint tells you the center point of the segment. An ordered pair. M = ((x₁ + x₂) / 2, (y₁ + y₂) / 2). See the midpoint formula calculator and the Midpoint Formula guide.
Same inputs, three different outputs. If you only need one of them, use the matching formula. If you are studying coordinate geometry, knowing all three together gives a full picture of any line segment.
Common slope formula mistakes
A few traps that catch people:
- Mixing the order between rise and run. If you compute y₂ − y₁ for the rise, you must use x₂ − x₁ for the run. Flipping one but not the other produces the wrong sign.
- Putting x in the numerator. Slope is rise over run, not run over rise. The y difference goes on top.
- Treating zero rise the same as zero run. Zero rise gives a slope of 0 (horizontal line). Zero run gives an undefined slope (vertical line). They are opposite cases.
- Sign errors with negative coordinates. 5 − (−3) = 8, not 2. Subtracting a negative is adding.
- Calling a steep line a high slope without noting the sign. A slope of −5 is just as steep as a slope of 5; the line just falls instead of rising.
Quick summary
- Formula: m = (y₂ − y₁) / (x₂ − x₁)
- Rise is the change in y; run is the change in x. Slope is rise divided by run.
- Positive slope: line rises from left to right.
- Negative slope: line falls from left to right.
- Zero slope: horizontal line (no rise).
- Undefined slope: vertical line (no run, division by zero).
- Slope, distance, and midpoint are the three main coordinate-geometry calculations on the same two points.
- The slope calculator runs the formula in one step and labels the result by type.
Run the numbers
The three coordinate-geometry calculators that work on the same two points: slope (steepness), distance (length), and midpoint (center).
Slope Calculator
Find the slope between two points with positive, negative, zero, and undefined cases handled.
Distance Formula Calculator
Find the distance between two points, with exact radical form when the answer is not a clean integer.
Midpoint Formula Calculator
Find the midpoint between two points with a step-by-step breakdown of the x and y averages.
Frequently asked questions
The slope formula is m = (y₂ − y₁) / (x₂ − x₁). It returns the slope of the straight line through two points (x₁, y₁) and (x₂, y₂). The numerator is the rise (vertical change); the denominator is the run (horizontal change).
Subtract the y-coordinates to get the rise. Subtract the x-coordinates in the same order to get the run. Divide rise by run. The result is the slope, often written as m.
Slope describes how steep a line is and which direction it tilts. The sign tells you direction (positive rises, negative falls); the size tells you steepness (a slope of 5 is much steeper than a slope of 0.5).
A positive slope means the line rises from left to right. As x increases, y increases. The formula gives a positive number when y₂ > y₁ and x₂ > x₁ (or both differences are negative; either way the ratio is positive).
A negative slope means the line falls from left to right. As x increases, y decreases. The formula gives a negative number when the rise and run have opposite signs.
When the two points share the same x-coordinate, the run (x₂ − x₁) is zero. The slope formula tries to divide by zero, which is undefined. The line is vertical, and vertical lines are described as having undefined or infinite slope.
All three use the same two points but answer different questions. Slope tells you steepness (a single number, possibly negative or undefined). Distance tells you length (a non-negative number). Midpoint tells you the center point (an ordered pair). They are the three main coordinate-geometry calculations on a single line segment.
Yes. The slope formula calculator on this site takes the four coordinates, computes the slope in one step, and labels the result by type (positive, negative, zero, or undefined). It also reports the rise and run separately so you can see how the slope was constructed.