Slope Calculator

Enter two points to get the slope, the equation of the line through them, the distance between them, the midpoint and the angle, with a small graph.

Point 1
Point 2

Example: Slope (m) of the line through (1, 2) and (5, 5)

3/4= 0.75

  1. m = (y₂ − y₁) ÷ (x₂ − x₁) = (5 − 2) ÷ (5 − 1) = 3 ÷ 4 = 3/4 = 0.75
  2. b = y₁ − m × x₁ = 2 − 0.75 × 1 = 1.25
  3. Distance = √(4² + 3²) = √25 = 5
  4. Midpoint = ((1 + 5) ÷ 2, (2 + 5) ÷ 2) = (3, 3.5)
Equation
y = (3/4)x + 5/4
With decimals
y = 0.75x + 1.25
Point-slope form
y − 2 = (3/4)(x − 1)
Standard form
3x − 4y = −5
y-intercept
5/4 (1.25)
x-intercept
−5/3 (−1.666666667)
Distance
5
Midpoint
(3, 3.5)
Angle of inclination
36.8699°
Grade
75%
Perpendicular slope
−4/3
(1, 2)(5, 5)

From the faint example points. Type your own to replace them.

Last reviewed:

The slope formula

Slope measures how steep a line is: how far it rises or falls for every step to the right. Pick any two points on the line, subtract their y values to get the rise and their x values to get the run, then divide. The letter m is the usual symbol for it.

m = (y₂ − y₁) ÷ (x₂ − x₁)
(x₁, y₁) and (x₂, y₂) = the two points
y₂ − y₁ = the rise
x₂ − x₁ = the run

Example: the slope through (1, 2) and (5, 5)

  1. Rise: 5 − 2 = 3
  2. Run: 5 − 1 = 4
  3. m = 3 ÷ 4 = 3/4 = 0.75

The line climbs 3 units for every 4 units to the right.

Keep the points in the same order on the top and the bottom. Subtracting the other way round, 2 − 5 over 1 − 5, gives −3 ÷ −4, which is still 3/4. Mixing the order, such as 5 − 2 over 1 − 5, flips the sign and gives a wrong answer of −3/4.

Finding the equation of a line from two points

Once you have the slope, the y-intercept b is where the line crosses the y-axis. Put either point into y = mx + b and solve for b. That gives the slope-intercept form, the version most textbooks ask for.

y = mx + b, where b = y₁ − m × x₁

Example: the line through (1, 2) and (5, 5)

  1. m = 3/4, found above
  2. b = 2 − 3/4 × 1 = 5/4 = 1.25
  3. Slope-intercept form: y = (3/4)x + 5/4
  4. Point-slope form: y − 2 = (3/4)(x − 1)
  5. Standard form: 3x − 4y = −5

Check with the other point: 3 × 5 − 4 × 5 = 15 − 20 = −5, so (5, 5) is on the line.

All three forms describe the same line. Slope-intercept form is best for graphing, point-slope form is the quickest to write straight from a point and a slope, and standard form, with whole-number coefficients, is handy for solving two equations together. The calculator keeps fractions exact, so you see 5/4 rather than a rounded decimal.

Positive, negative, zero and undefined slopes

PointsSlopeWhat the line doesEquation
(1, 2) and (5, 5)3/4Rises from left to righty = (3/4)x + 5/4
(−2, 4) and (4, 0)−2/3Falls from left to righty = (−2/3)x + 8/3
(−3, 2) and (5, 2)0Flat (horizontal)y = 2
(3, −1) and (3, 7)UndefinedStraight up and down (vertical)x = 3

A vertical line has a run of zero, and division by zero has no answer, so its slope is undefined rather than zero or infinity. It can't be written as y = mx + b at all. Instead its equation is x equals a constant, because every point on it shares the same x value. A horizontal line is the mirror case: every point shares the same y value, and its slope is exactly 0.

Distance and midpoint between two points

The rise and the run are the two short sides of a right triangle, and the segment joining the points is its longest side. The Pythagorean theorem gives that length. The midpoint is simply the average of the x values and the average of the y values.

d = √((x₂ − x₁)² + (y₂ − y₁)²)
Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)

Example: from (−2, 4) to (4, 0)

  1. Run: 4 − (−2) = 6, and rise: 0 − 4 = −4
  2. d = √(6² + (−4)²) = √(36 + 16) = √52
  3. √52 = √(4 × 13) = 2√13, about 7.211
  4. Midpoint: ((−2 + 4) ÷ 2, (4 + 0) ÷ 2) = (1, 2)

The points are 2√13, or about 7.211 units, apart, and halfway between them is (1, 2).

Points with a run of 4 and a rise of 3, like (1, 2) and (5, 5), are exactly 5 apart. That's the 3-4-5 triangle carpenters use to check that a corner is square.

Slope as an angle and a percent grade

Road signs, ramps and roofs often give steepness as a percent grade or an angle instead of a fraction. The grade is the slope times 100. The angle comes from the inverse tangent, angle = tan⁻¹(m), measured up from the horizontal.

SlopeGradeAngle
1/128.33%4.76°
1/1010%5.71°
1/250%26.57°
3/475%36.87°
1100%45°
2200%63.43°

A 100% grade is a 45 degree slope, not a vertical wall: it rises one unit for every unit forward. The 1:12 limit for wheelchair ramps in the ADA Standards works out to about 8.33%, under 5 degrees, which shows how gentle a usable ramp has to be. To find an angle by hand, use tan⁻¹ on the Scientific Calculator in degree mode.

Parallel and perpendicular lines

Parallel lines have the same slope, so they never meet. Perpendicular lines cross at a right angle, and their slopes are negative reciprocals of each other: flip the fraction and change the sign. Multiply the two slopes together and you always get −1.

Example: a line perpendicular to y = (3/4)x + 5/4

  1. Flip 3/4 to get 4/3
  2. Change the sign: −4/3
  3. Check: 3/4 × (−4/3) = −1

Any line with slope −4/3 meets the original at a right angle.

The rule only breaks down for horizontal and vertical lines. A horizontal line, with slope 0, is perpendicular to every vertical line, whose slope is undefined, since zero has no reciprocal. If your slope starts life as a ratio such as 1:12, the Ratio Calculator can simplify or scale it first, and the Fraction Calculator helps with the arithmetic.

Sources and further reading

How to use it

  1. 1Enter the x and y coordinates of the first point.
  2. 2Enter the x and y coordinates of the second point.
  3. 3Read the slope, the line's equation and the other results, each with its working.

Questions

What does an undefined slope mean?

The two points share the same x value, so the line is vertical. The run is zero and you can't divide by zero. The equation of the line is x = a number.

Does it matter which point I enter first?

No. Swapping the points flips the sign of both the rise and the run, so the slope, equation, distance and midpoint stay the same.

Is a slope of 0 the same as no slope?

A slope of 0 is a flat, horizontal line. People who say no slope usually mean an undefined slope, which is a vertical line, so it helps to say which one you mean.

Also handy: Length Converter, Grade Calculator, Unit Converter