Skip to content
Press Equals

How to find the slope of a line

Find slope from two points, an equation or a graph, with worked examples, zero and undefined slopes, and slope as a grade or angle.

Open the Slope calculator

Slope is rise over run: how much a line goes up or down for every step to the right. You can find it from two points, from an equation, or from a graph, and each way gives the same number for the same line.

The slope formula

For two points (x₁, y₁) and (x₂, y₂):

m = (y₂ − y₁) ÷ (x₂ − x₁)

The top is the rise (the change in y) and the bottom is the run (the change in x). Which point you call "first" doesn't matter, as long as you subtract in the same order on the top and the bottom.

Finding slope from two points

Take the points (2, 3) and (6, 11).

  1. Rise: 11 − 3 = 8.
  2. Run: 6 − 2 = 4.
  3. Slope: 8 ÷ 4 = 2.

The line climbs 2 units for every 1 unit to the right. Its equation is y = 2x - 1: put x = 2 into it and you get 3, which confirms the first point is on the line.

Negative numbers work the same way. From (−1, 4) to (3, −4), the rise is −4 − 4 = −8 and the run is 3 − (−1) = 4, so the slope is -2. A negative slope means the line falls as you move right. This line crosses the y-axis at 2.

The slope calculator does these steps for any two points and also gives the equation, both intercepts, the angle and the distance between the points.

Finding slope from an equation

Slope-intercept form: y = mx + b

The slope is the number in front of x. In y = 4x + 7 the slope is 4; in y = −x + 2 it's −1; in y = x/3 − 5 it's 1/3. If there's no x term at all, as in y = 6, the slope is 0.

Standard form: Ax + By = C

Solve for y first, or use the shortcut m = −A ÷ B.

For 3x + 4y = 12:

  • Shortcut: m = −3 ÷ 4.
  • Check with two points: when x = 0, y = 3, and when y = 0, x = 4. The points (0, 3) and (4, 0) give a slope of -0.75, which is -3/4 as a fraction.

Picking the two intercepts like this is the quickest way to get points from a standard-form equation.

Point-slope form: y − y₁ = m(x − x₁)

The slope is the number multiplying the bracket. In y − 5 = −2(x + 1), the slope is −2 and the line passes through (−1, 5).

Finding slope from a graph

  1. Pick two points where the line crosses grid corners exactly, so you're reading whole numbers.
  2. Count the squares up (positive) or down (negative) from the left point to the right point. That's the rise.
  3. Count the squares to the right. That's the run.
  4. Divide rise by run.

Points far apart give a more accurate answer than points close together, because a small misreading matters less.

Finding slope from a table

Choose any two rows and use them as your two points. If the table is a straight line, every pair of rows gives the same slope. If different pairs give different slopes, the data isn't linear, and a linear regression calculator will find the line that fits best.

Special cases: zero and undefined slope

Horizontal lines have a slope of 0. From (1, 5) to (4, 5) the rise is 0, so the slope is 0 and the line is y = 5.

Vertical lines have an undefined slope. From (2, 1) to (2, 7) the run is 0, and you can't divide by zero. The slope is Undefined (vertical line), and the line is x = 2. Undefined is not the same as zero: a common test mistake is to swap them.

Parallel and perpendicular lines

  • Parallel lines have the same slope. Any line parallel to y = 2x − 1 also has slope 2.
  • Perpendicular lines have slopes that are negative reciprocals: flip the fraction and change the sign. Perpendicular to a slope of 2 is −1/2; perpendicular to −3/4 is 4/3. Multiply the two slopes and you always get −1.
  • A horizontal line (slope 0) is perpendicular to a vertical line (undefined slope).

Slope in the real world: grade and angle

Outside math class, slope is often written as a percent grade (rise ÷ run × 100) or as an angle.

A wheelchair ramp built to the US accessibility limit of 1 inch of rise for every 12 inches of run (2010 ADA Standards, section 405.2) has a slope of 1/12. That's a grade of 8.33% and an angle of about 4.76 degrees.

Grade and angle are not the same thing: a 100% grade is 45 degrees, not 90. For roofs, slope is usually given as rise per 12 inches of run (a "6/12 pitch"); the roof pitch calculator converts between pitch, angle and grade.

Common mistakes

  • Subtracting in different orders. (y₂ − y₁) on top must pair with (x₂ − x₁) on the bottom, not (x₁ − x₂). Mixing them flips the sign.
  • Putting run over rise. Slope is change in y over change in x. Remember "rise before you run".
  • Reading the slope from standard form directly. In 3x + 4y = 12 the slope is not 3 or 4; it's −3/4.
  • Calling a vertical line's slope 0. Vertical is undefined; horizontal is 0.

Check your answer

Work the problem by hand first, then enter your two points in the slope calculator to check the slope and the equation. To find the point halfway between two points, use the midpoint calculator, and for the straight-line distance between them, the distance calculator.

Updated

  • How lottery odds are calculated

    How combinations set lottery odds, Powerball and Mega Millions worked out, what more tickets really buy, and expected value.

  • How to calculate vote percentage

    Work out a share of the vote, tell a majority from a plurality, check a two-thirds threshold, and calculate margin of victory and turnout.

  • How to find the factors of a number

    List every factor of a number using factor pairs, stop at the square root, use divisibility shortcuts, and spot prime numbers.

  • How to find the interior angles of a polygon

    The (n − 2) × 180° rule, each angle of a regular polygon, exterior angles, and a table from triangles to dodecagons.

  • How to calculate percentages

    The three kinds of percentage question, percent change, percentage points, and converting between percents, decimals and fractions.

  • How to average fractions

    Add over a common denominator and divide by the count, with worked examples for two fractions, three fractions and mixed numbers.

  • How to calculate a point estimate

    Find a point estimate from counts or from a confidence interval, with the standard error, margin of error and adjusted estimates.

  • How to curve grades

    Three common grade curves, adding the gap to 100, the square root curve and scaling to the top score, each worked through.

  • How to calculate a test score

    Turn questions and wrong answers into a percentage, what each question is worth, and how many you can miss for the grade you want.

  • How the ACT composite score is calculated

    The average of English, math and reading, ACT's rounding rule, worked examples, and what changed when science left the composite.

All guides by topic