Slope Calculator

Find the slope through two points as a reduced fraction and a decimal, with y = mx + b, point-slope form, perpendicular slope and vertical or horizontal lines.

How we test our calculators
Slope (m) —
Rise over run —
y-intercept (b) —
Slope-intercept form —
Point-slope form —
Perpendicular and parallel lines —
Angle of inclination —°

What is a slope calculator?

The slope of a line measures how steep it is: how much y changes for every 1-unit change in x. It is often described as rise over run, the vertical change between two points divided by the horizontal change. A slope of 2 means the line climbs 2 units for every 1 unit to the right; a slope of −2/3 means it drops 2 units for every 3 units to the right.

This slope calculator takes two points, (x₁, y₁) and (x₂, y₂), and returns the Slope (m) as a decimal and the Rise over run as a fraction in lowest terms when all four coordinates are whole numbers. It also finds the y-intercept (b), writes the line in Slope-intercept form (y = mx + b) and Point-slope form, gives the slopes of Perpendicular and parallel lines, and reports the Angle of inclination in degrees. Vertical lines, which have no defined slope, and horizontal lines, with slope 0, are handled as special cases.

In the Common Core standards, Grade 8 students use similar triangles to explain why the slope is the same between any two points on a non-vertical line and derive y = mx + b (8.EE.B.6), and high school geometry uses the slope criteria for parallel and perpendicular lines (G-GPE.B.5). This tool checks each of those steps for a particular pair of points.

Formula

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

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

Subtract in the same order on the top and the bottom. Swapping both points gives the same slope, because the signs of the rise and the run both flip.

From the slope to the equation

  • y-intercept: substitute either point into y = mx + b and solve for b: b = y₁ − m × x₁.
  • Slope-intercept form: y = mx + b.
  • Point-slope form: y − y₁ = m(x − x₁). The calculator builds it from the first point you enter.
  • Parallel lines have the same slope. Perpendicular lines have slopes whose product is −1, so the perpendicular slope is the negative reciprocal, −1 ÷ m.
  • Angle of inclination: θ = arctan(m), in degrees.

What the sign of the slope tells you

SlopeLine from left to rightAngle shown
PositiveRisesBetween 0° and 90°
NegativeFallsBetween −90° and 0°
0Horizontal (y₁ = y₂)0°
UndefinedVertical (x₁ = x₂)90°

The reduced fraction

When all four coordinates are whole numbers, the calculator divides the rise and the run by their greatest common factor and moves any minus sign to the top, so −6 ÷ −4 becomes 3/2 and 4 ÷ −6 becomes −2/3. With decimal coordinates it shows the division as decimals, such as 1 ÷ 2.5 = 0.4. The decimal outputs are rounded to six decimal places, so a slope of −2/3 appears as −0.666667 in the equations.

Worked example

Example 1: a negative slope that is a fraction

Find the line through (−2, 5) and (4, 1).

  1. Rise = 1 − 5 = −4. Run = 4 − (−2) = 6.
  2. m = −4 ÷ 6. Rise over run reads rise ÷ run = −4 ÷ 6 = −2/3, and Slope (m) is −0.666667.
  3. b = 5 − (−2/3)(−2) = 5 − 4/3 = 11/3 ≈ 3.666667.
  4. The calculator gives y = −0.666667x + 3.666667 and y − 5 = −0.666667(x + 2). Written exactly, that is y = −(2/3)x + 11/3.
  5. Perpendicular slope: −1 ÷ (−2/3) = 1.5. The angle of inclination is about −33.6901°, negative because the line falls.

Example 2: the order of the points does not matter

Through (6, 4) and (2, −2): rise = −2 − 4 = −6 and run = 2 − 6 = −4, so rise ÷ run = −6 ÷ −4 = 3/2 and m = 1.5. The line is y = 1.5x − 5, and from the first point the point-slope form is y − 4 = 1.5(x − 6).

Enter the points the other way round, (2, −2) first, and the rise and run become 6 and 4. The slope (3/2), the intercept (−5) and the slope-intercept form stay the same; only the point-slope form changes, to y + 2 = 1.5(x − 2), because it is built from a different point. Both versions describe the same line. The angle is about 56.3099° either way.

Example 3: vertical and horizontal lines

  • (3, −1) and (3, 6): the run is 0, and division by 0 is undefined. The calculator shows Undefined (run = 0): rise 7 over run 0, the equation Vertical line: x = 3, an angle of 90°, and notes that a line perpendicular to it is Horizontal: slope 0. There is no y-intercept and no point-slope form.
  • (−4, 3) and (5, 3): the rise is 0, so rise ÷ run = 0 ÷ 9 = 0. The line is y = 3, with a y-intercept of 3, an angle of 0°, and perpendicular lines that are Vertical (undefined slope).

Example 4: slope as a percent

Through (0, 0) and (100, 5), the slope is 5 ÷ 100 = 1/20 = 0.05, and the angle is about 2.8624°. Multiplying the slope by 100 expresses it as a percent grade, 5%: a rise of 5 units for every 100 units of run.

How to use this calculator

  1. Enter the first point in the x₁ and y₁ boxes and the second point in x₂ and y₂. Negative numbers and decimals are fine.
  2. Read Slope (m) and Rise over run. For homework that asks for an exact answer, use the fraction.
  3. Copy the equation you need from Slope-intercept form or Point-slope form.
  4. For a line parallel or perpendicular to yours, take the slope from Perpendicular and parallel lines.
  5. If the two points have the same x-coordinate, read the vertical-line result instead; if they are the same point, enter a different second point.

Which output to use

  • Rise over run: exact slope, and the easiest form for graphing (up 3, right 2).
  • Slope-intercept form: shows where the line crosses the y-axis; the usual answer to "write the equation of the line".
  • Point-slope form: quickest to write from one point and a slope, and the usual starting point for a parallel or perpendicular line through a given point.
  • Angle of inclination: for problems about the angle a line, ramp or roof makes with the horizontal.

Common mistakes

  • Subtracting in different orders, such as (y₂ − y₁) ÷ (x₁ − x₂), which flips the sign.
  • Putting the run on top: slope is change in y over change in x.
  • Calling a horizontal line's slope undefined. It is 0; only vertical lines have undefined slope.
  • Forgetting that x − (−2) is x + 2 in point-slope form.

More on the three ways to write a line: slope-intercept, point-slope and standard form. To simplify a fractional slope by hand, try the fraction calculator. For the same two points, the distance formula calculator gives the length of the segment and the midpoint calculator gives its center.

Sources

Frequently asked questions

Why is the slope of a vertical line undefined?

On a vertical line every point has the same x-coordinate, so the run, x₂ − x₁, is 0, and the slope formula would divide by 0. No number works as the answer, so the slope is called undefined. The line is still easy to describe: its equation is x = a constant, such as x = 3. The calculator reports its angle of inclination as 90°.

Does it matter which point I enter first?

Not for the slope, the y-intercept or the slope-intercept form: as Example 2 shows, (6, 4) then (2, −2) and the reverse both give m = 3/2 and y = 1.5x − 5. The point-slope form changes, because the calculator writes it with the first point, but both versions are equations of the same line.

Why does the equation show −0.666667 instead of −2/3?

The equation outputs use decimals rounded to six places. When the slope or intercept is a repeating decimal, the equation is therefore a rounded version of the exact line. For exact work, take the slope from Rise over run (−2/3) and find b as a fraction by hand, as in Example 1, where b = 11/3. The reduced fraction appears only when all four coordinates are whole numbers.

How do I write the equation of a perpendicular line through a given point?

Take the perpendicular slope from the calculator and put it into point-slope form with your point. For a line perpendicular to y = 2x that passes through (4, 1), the perpendicular slope is −0.5, so y − 1 = −0.5(x − 4), which simplifies to y = −0.5x + 3. To check, enter (4, 1) and a second point on that line, such as (6, 0): the calculator returns y = −0.5x + 3 and a perpendicular slope of 2.

How do I use rise over run to graph the line?

Plot one point, then move by the run horizontally and the rise vertically to find another. For a slope of −2/3, go 3 units right and 2 units down: from (−2, 5) that lands on (1, 3), and one more step lands on (4, 1), the second point in Example 1. Draw the line through the points. A whole-number slope such as 2 is the fraction 2/1, so go 1 right and 2 up.

Why is the angle of inclination negative?

The calculator gives arctan(m), which runs from −90° to 90°. A negative angle means the line falls from left to right; −33.6901° is about 33.7° below the horizontal. If your course measures the inclination counterclockwise from the positive x-axis, between 0° and 180°, add 180° to a negative result: −33.6901° becomes 146.3099°. Positive angles are the same in both conventions.

What is the difference between slope and the y-intercept?

The slope is the rate of change, how much y changes per unit of x. The y-intercept is the value of y when x = 0, where the line crosses the y-axis. In y = 2x + 7, the line through (−2, 3) and (1, 9), the slope is 2 and the line crosses the y-axis at 7. In a real-world model, the slope is usually the rate and the intercept the starting amount.

Can the calculator find the slope of a curve?

No. It finds the slope of the straight line through two points. For a curve, that is the average rate of change between the two points, not the slope at a single point, which is a calculus question.