How to Calculate Slope -- Formula, Worked Examples, and Real-World Meaning

Learn how to calculate slope using rise over run, understand positive, negative, zero, and undefined slopes, and see how slope applies to road grades, roof pitch, and accessibility ramps.

The Quick Answer

Slope measures the steepness and direction of a line, calculated as the ratio of vertical change (rise) to horizontal change (run) between two points.

m = (y2 - y1) / (x2 - x1)

Pick any two points on the line, subtract the y-coordinates (rise), divide by the difference in x-coordinates (run), and you have the slope. A positive result means the line goes up from left to right; negative means it goes down.

Use our slope calculator to compute slope, distance, and the line equation from any two points.

The Slope Formula in Detail

Given two points (x1, y1) and (x2, y2):

m = (y2 - y1) / (x2 - x1) = rise / run = vertical change / horizontal change

The Greek letter delta (meaning "change in") is sometimes used: m = delta-y / delta-x.

The variable m is the standard symbol for slope. Its origin is debated -- it may come from the French word "monter" (to climb) or may simply be an arbitrary convention that stuck (Khan Academy: Slope).

Key point: it does not matter which point you call (x1, y1) and which you call (x2, y2), as long as you are consistent. Swapping them changes the sign of both the numerator and denominator, so the result is the same.

Worked Example 1: Positive Slope

Find the slope of the line through (2, 3) and (6, 11).

m = (11 - 3) / (6 - 2) = 8 / 4 = 2

The line rises 2 units for every 1 unit it moves to the right. Between these two points, the line rises a total of 8 units over a horizontal distance of 4 units.

To verify: starting at (2, 3), move right 1 unit to x = 3, and up 2 units to y = 5. Then (3, 5) should also be on the line. Check: m = (5 - 3)/(3 - 2) = 2/1 = 2. Confirmed.

Worked Example 2: Negative Slope

Find the slope of the line through (-1, 5) and (3, 1).

m = (1 - 5) / (3 - (-1)) = -4 / 4 = -1

The line falls 1 unit for every 1 unit it moves to the right. A negative slope always means the line descends from left to right.

At slope -1, the line makes a 45-degree angle downward with the horizontal axis (since |rise| = |run|).

Worked Example 3: Zero and Undefined Slopes

Horizontal line through (2, 4) and (7, 4):

m = (4 - 4) / (7 - 2) = 0 / 5 = 0

The y-coordinates are identical, so there is no vertical change. A horizontal line has a slope of zero -- it is perfectly flat.

Vertical line through (3, 1) and (3, 5):

m = (5 - 1) / (3 - 3) = 4 / 0 = undefined

The x-coordinates are identical, so the denominator is zero. Division by zero is undefined, which means a vertical line has no defined slope. It is sometimes described as "infinite" slope, but the precise term is "undefined."

Four Types of Slope

Slope value Direction Example
Positive (m > 0) Rises from left to right Income over time (growing)
Negative (m < 0) Falls from left to right Altitude during descent
Zero (m = 0) Horizontal, no change Constant temperature
Undefined (run = 0) Vertical A wall, a cliff face

The steeper the line, the larger the absolute value of the slope. A slope of 5 is steeper than a slope of 2; a slope of -5 is steeper than a slope of -2.

Slope-Intercept Form: y = mx + b

The most common equation form for a line:

y = mx + b

  • m = slope
  • b = y-intercept (the point where the line crosses the y-axis, at x = 0)

If you know the slope and one point, you can find b by substituting:

Example: Slope = 2, passes through (2, 3).

3 = 2(2) + b --> 3 = 4 + b --> b = -1

Equation: y = 2x - 1

To extract slope from any linear equation, solve for y. For example:

3x - 2y = 6 --> -2y = -3x + 6 --> y = (3/2)x - 3

Slope is 3/2.

Point-Slope Form: y - y1 = m(x - x1)

When you know the slope and a specific point, point-slope form is often the most direct way to write the equation:

y - y1 = m(x - x1)

Example: Slope = -1, passes through (-1, 5).

y - 5 = -1(x - (-1)) --> y - 5 = -1(x + 1) --> y = -x + 4

Both forms -- slope-intercept and point-slope -- describe the same line. Use whichever is more convenient.

Parallel and Perpendicular Lines

Parallel lines have equal slopes. If line 1 has slope m = 3, any line parallel to it also has slope 3. They never intersect (assuming they are distinct lines).

Perpendicular lines have slopes that are negative reciprocals. Their product is -1:

m1 * m2 = -1

If one line has slope 2, the perpendicular line has slope -1/2. If one has slope -3/4, the perpendicular has slope 4/3.

Special cases:

  • A horizontal line (m = 0) is perpendicular to a vertical line (undefined slope).
  • Two vertical lines are parallel to each other.

Real-World Applications of Slope

Road grades

Road steepness is expressed as a percentage grade: the rise divided by the run, multiplied by 100. A 6% grade means the road rises 6 feet for every 100 feet of horizontal distance -- a slope of 0.06.

Common reference points:

  • 2% grade: typical highway cross-slope for water drainage
  • 6% grade: moderately steep, common on mountain highways
  • 8-10% grade: steep; requires lower gears for trucks
  • 15%+ grade: very steep; some San Francisco streets exceed 30%

Roof pitch

Roof pitch is expressed as rise over a 12-inch run. A "6/12 pitch" means the roof rises 6 inches for every 12 inches horizontally -- a slope of 0.5 or 50%. Common residential roofs range from 4/12 (moderate) to 12/12 (steep, 45-degree angle).

Wheelchair ramps

The Americans with Disabilities Act (ADA) requires a maximum slope of 1:12 for wheelchair ramps -- 1 inch of rise for every 12 inches of horizontal run (ADA Standards for Accessible Design, Section 405). That is a slope of 1/12 = 0.0833, or about 8.33%. A ramp serving a 30-inch-high entrance requires at least 30 * 12 = 360 inches (30 feet) of ramp length.

Rate of change in data

In any graph of data over time, slope represents the rate of change. If a company's revenue graph passes through (2020, $2M) and (2024, $6M):

m = (6 - 2) / (2024 - 2020) = 4 / 4 = $1M per year

Revenue grew at an average rate of $1 million per year.

Converting Between Slope Representations

Representation Formula Example (slope = 0.25)
Decimal m 0.25
Fraction rise/run 1/4
Percentage m * 100 25%
Ratio 1 : (1/m) 1:4
Angle (degrees) arctan(m) arctan(0.25) = 14.04 degrees

To convert a percentage grade to a slope: divide by 100. A 6% grade = 0.06 slope.

To convert slope to an angle: take the arctangent. A slope of 1 corresponds to 45 degrees. A slope of 0.5 corresponds to about 26.6 degrees.

Common Mistakes

1. Swapping rise and run. Slope is (y2 - y1) / (x2 - x1), not the other way around. The vertical change goes in the numerator.

2. Inconsistent point order. If you subtract y-values as y2 - y1, you must subtract x-values as x2 - x1 (same order). Mixing them flips the sign.

3. Confusing "no slope" with "zero slope." A horizontal line has zero slope (it exists and equals 0). A vertical line has undefined slope (it does not exist as a real number). "No slope" is ambiguous -- avoid it.

4. Forgetting that slope is constant on a line. You can pick any two points on the same line and get the same slope. If you get different values, the points are not on the same line.

Try It Yourself

Use the slope calculator to find the slope, distance, midpoint, and line equation for any two points. The distance formula calculator computes the straight-line distance between points, and the midpoint calculator finds the center point between two coordinates.

Frequently Asked Questions

What does a slope of 2 mean?

A slope of 2 means the line rises 2 units vertically for every 1 unit it moves horizontally to the right. It indicates a moderately steep upward-sloping line. Between any two points on the line, the vertical change is always twice the horizontal change.

Can slope be negative?

Yes. A negative slope means the line falls from left to right. For example, a slope of -3 means the line drops 3 units for every 1 unit it moves to the right. Temperature decreasing over time, altitude during a descent, or a stock price declining all produce negative slopes on a graph.

What is the slope of a horizontal line?

The slope of a horizontal line is 0. Since all points on a horizontal line have the same y-coordinate, the rise (y2 - y1) is always zero, making rise/run = 0/run = 0 for any run value.

What is the slope of a vertical line?

The slope of a vertical line is undefined. Since all points have the same x-coordinate, the run (x2 - x1) is always zero, and division by zero is undefined in mathematics.

How do I find slope from an equation?

Rewrite the equation in slope-intercept form y = mx + b. The coefficient m is the slope. For example, 4x + 2y = 10 rearranges to y = -2x + 5, so the slope is -2.

What is the difference between slope and rate of change?

For a straight line, slope and rate of change are identical -- both measure how much y changes per unit change in x. For curves, the rate of change varies from point to point and is given by the derivative (the slope of the tangent line at each point).

How do parallel and perpendicular slopes relate?

Parallel lines have equal slopes. Perpendicular lines have slopes that are negative reciprocals -- their product equals -1. If one line has slope 3, a perpendicular line has slope -1/3.

What is a 6% road grade?

A 6% grade means the road rises (or falls) 6 feet for every 100 feet of horizontal distance. This equals a slope of 0.06, or an angle of about 3.4 degrees. It is a moderately steep grade common on mountain highways.

How do I find the equation of a line from two points?

First calculate the slope: m = (y2 - y1) / (x2 - x1). Then use point-slope form: y - y1 = m(x - x1), substituting one of the known points. Simplify to slope-intercept form y = mx + b if desired.

What slope does a wheelchair ramp need?

The ADA requires a maximum slope of 1:12, meaning 1 inch of rise for every 12 inches of horizontal run. That is a slope of approximately 0.083, or about 8.33%. A 24-inch rise therefore requires a minimum ramp length of 24 * 12 = 288 inches (24 feet).

Related Tools