Skip to content

Slope Calculator

Slope, line equation, distance and midpoint between two points.

Point 1
Point 2

Calculated on your device. Nothing you enter is sent anywhere.

Slope (m)

−7/5 = −1.4

The line has slope −1.4; the points are 8.6023253 apart, with midpoint (−4.5, 0.5).

Equation of the line
y = −1.4x − 5.8
Distance
√74 ≈ 8.60232527
Midpoint
(−4.5, 0.5)
Angle with the x-axis (°)
−54.462322

In short

The slope of a line is rise over run: the change in y divided by the change in x between two points, m = (y₂ − y₁) ÷ (x₂ − x₁). A horizontal line has slope 0 and a vertical line has an undefined slope. The distance between the points comes from the Pythagorean theorem, and the midpoint is the average of the coordinates.

How it works

Slope

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

Distance and midpoint

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

The equation is written in slope-intercept form, y = mx + b, where b = y₁ − m·x₁ is where the line crosses the y-axis. Swapping the two points does not change the slope, the distance or the midpoint.

Worked examples

Slope through (−2, −3) and (−7, 4)

m = (4 − (−3)) ÷ (−7 − (−2)) = 7 ÷ (−5) = −7/5 = −1.4, as in OpenStax Intermediate Algebra Example 3.14. The line is y = −1.4x − 5.8.

Open this example in the calculator

Distance from (10, −4) to (−1, 5)

d = √((−11)² + 9²) = √(121 + 81) = √202 ≈ 14.2126704. Example 11.3 gives √202 ≈ 14.2.

Open this example in the calculator

Midpoint of (7, −2) and (9, 5)

((7 + 9) ÷ 2, (−2 + 5) ÷ 2) = (8, 1.5), which OpenStax College Algebra Example 7 writes as (8, 3/2).

Open this example in the calculator

Using this calculator well

  • Keep the order consistent. Subtract in the same order on top and bottom: (y₂ − y₁) over (x₂ − x₁). Mixing the order flips the sign.
  • Read the sign. A positive slope rises from left to right, a negative one falls, and a bigger number means steeper.
  • Grades and pitches: a road grade of 6% is a slope of 0.06, and a roof pitch of 4 in 12 is a slope of 1/3.

Frequently asked questions

How do I find the slope between two points?

Subtract the y values and divide by the difference of the x values, in the same order. From (1, 2) to (4, 8), the slope is (8 − 2) ÷ (4 − 1) = 6 ÷ 3 = 2: the line rises 2 units for every 1 unit across.

What does an undefined slope mean?

The two points have the same x value, so the line is vertical and the run is zero. Division by zero is undefined, so the slope is undefined. The line’s equation is x = a constant. A horizontal line, by contrast, has a slope of exactly 0.

How do I find the distance between two points?

Square the difference in x and the difference in y, add them and take the square root. From (6, 4) to (2, 1) the differences are 4 and 3, so the distance is √(16 + 9) = 5, the hypotenuse of a 3, 4, 5 right triangle.

How do I write the equation of a line through two points?

Find the slope m, then the intercept b = y₁ − m·x₁, and write y = mx + b. Through (1, 2) and (4, 8), m = 2 and b = 2 − 2 × 1 = 0, so the line is y = 2x.

Sources and methodology

  1. Intermediate Algebra 2e, 3.2 Slope of a Line and 11.1 Distance and Midpoint Formulas; Circles, OpenStax, Rice University, m = (y₂ − y₁) ÷ (x₂ − x₁) (§3.2, Example 3.14: (−2, −3), (−7, 4) → −7/5; vertical lines undefined, horizontal 0); d = √((x₂ − x₁)² + (y₂ − y₁)²): Example 11.1 → 5, 11.2 → 13, 11.3 → √202 ≈ 14.2; Example 11.4: midpoint of (−5, −4), (7, 2) is (1, −1) (accessed November 24, 2026)
  2. College Algebra 2e, 2.1 The Rectangular Coordinate Systems and Graphs, OpenStax, Rice University, Example 5: (−3, −1), (2, 3) → √41; Example 6: (0, 0), (8, 7) → √113 ≈ 10.63; Example 7: midpoint of (7, −2), (9, 5) is (8, 3/2) (accessed November 24, 2026)

Rounding: Decimals are shown to 8 significant digits. With whole-number coordinates the slope is also a reduced fraction and the distance a simplified square root.

Review status: formulas verified against the cited sources by automated tests; editorial review pending. Version 1.0.0, content updated November 24, 2026.

Changelog
  • 1.0.0 · November 24, 2026: First published.

How we build and test calculators

Embed this calculator on your site

Paste this code into your page. The calculator runs in a frame, with no tracking and no cookies, and links back here for the formula and sources.

<iframe src="https://northcalculator.com/embed/en/slope" title="Slope Calculator" width="100%" height="760" style="border:0" loading="lazy"></iframe>