All guides

How to find the slope of a line from two points

Last updated:

Given any two points on a line, you can derive the slope, the full equation of the line, the angle it makes with the horizontal, and the straight-line distance between the two points — all from the same four numbers.

The slope formula

Slope (m) = (y₂ − y₁) ÷ (x₂ − x₁) — the change in y divided by the change in x, often described as "rise over run."

Worked example

For the points (1, 2) and (4, 8): slope = (8 − 2) ÷ (4 − 1) = 6 ÷ 3 = 2. The y-intercept works out to 0, giving the full line equation y = 2x. The angle of incline is 63.43°, and the straight-line distance between the two points is 6.708 units.

When is slope undefined?

If the two points share the same x-coordinate (a vertical line), the slope formula divides by zero — slope is undefined for vertical lines, not zero. A slope of exactly zero describes a horizontal line instead.

Common mistakes

  • Confusing "slope is zero" (a flat, horizontal line) with "slope is undefined" (a vertical line) — these are opposite cases, not the same thing.
  • Swapping which point is "first" and which is "second" inconsistently between the x and y differences — both differences must be taken in the same point order.

Enter any two points to get the slope, equation, angle and distance with the Slope Calculator.