Maths

Slope Calculator

Find the slope, equation, angle, distance and midpoint of the line through two points.

By Nitin Raturi · Last reviewed

Two points

How to use the Slope Calculator

Find the slope, equation, angle, distance and midpoint of the line through two points.

  1. Enter the first point (x₁, y₁).
  2. Enter the second point (x₂, y₂).
  3. Read the slope and the line’s equation.

Good to know

  • Points with the same x give a vertical line with an undefined slope.
  • Whole-number points give the slope as a fraction.

Enter the coordinates of two different points.

x₁

The x-coordinate (across) of the first point.

How to fill it in

  • Enter any number; use a minus sign for negatives.
  • Allowed range: −1,000,000,000 to 1,000,000,000.

Example

For (1, 2) and (4, 5), the slope is 1.

y₁

The y-coordinate (up) of the first point.

How to fill it in

  • Enter any number; use a minus sign for negatives.
  • Allowed range: −1,000,000,000 to 1,000,000,000.

x₂

The x-coordinate of the second point.

How to fill it in

  • Enter any number; use a minus sign for negatives.
  • Allowed range: −1,000,000,000 to 1,000,000,000.

Example

For (−2, −3) and (−7, 4), the slope is −7/5.

y₂

The y-coordinate of the second point.

How to fill it in

  • Enter any number; use a minus sign for negatives.
  • Allowed range: −1,000,000,000 to 1,000,000,000.

Tip: The order of the points does not change the slope.

Slope through (1, 2) and (4, 5)

m = 1

Rise 3 over run 3. The line is y = x + 1.

Equation
y = x + 1
Angle
45°
Distance between points
4.242641
Midpoint
(2.5, 3.5)

m = (y₂ − y₁) ÷ (x₂ − x₁). Decimals are rounded to six places for display; fractions are exact for whole-number points.

How this calculator works

  1. Step 1Risey₂ − y₁How far the line goes up (or down).
  2. Step 2Runx₂ − x₁How far it goes across.
  3. Step 3Sloperise ÷ runSteepness: up per unit across.

The slope of a line measures how steep it is: how far it rises for each step to the right. A negative slope falls from left to right.

From the slope and one point, the calculator also writes the line as y = mx + b and gives its angle, the distance between the points and their midpoint.

Worked example: (−2, −3) and (−7, 4)

Slope through (−2, −3) and (−7, 4)
Slope
m = (y₂ − y₁) ÷ (x₂ − x₁)
  1. Rise4 − (−3)7
  2. Run−7 − (−2)−5
  3. Slope7 ÷ −5−7/5

This is OpenStax’s Example 4.34. The line is y = −1.4x − 5.8. Example 4.33, through (1, 2) and (4, 5), has slope 1.

Horizontal and vertical lines

  • Horizontalm = 0Same y for both points: y = 3.
  • VerticalUndefinedSame x for both points: x = 2. The run is 0.

Read the result

The headline is the slope, as a fraction when the points are whole numbers; the table adds the equation, angle, distance and midpoint.

The angle is measured from the positive x-axis, between −90° and 90°. A slope of 1 is 45°.

Assumptions and limits

  • Two different pointsThe same point twice does not fix a line.
  • Cartesian planex across, y up, the same scale on both axes.
  • Six decimalsDecimal answers are rounded for display only.

Two points fix a line. Distances, midpoints and directions all follow from the same coordinates.

For distance in two or three dimensions, use the distance calculator. The vector calculator finds angles and products between directions, and the triangle calculator solves the shape the points make.

Common mistakes

  • Mistake: Dividing run by rise.

    Instead: Slope is rise over run: change in y divided by change in x.

  • Mistake: Mixing the order: y₂ − y₁ over x₁ − x₂.

    Instead: Subtract in the same order on top and bottom.

  • Mistake: Calling a vertical line’s slope zero.

    Instead: Zero is horizontal; vertical is undefined.

Checking the method

Every golden case is rechecked with exact fractions, and two OpenStax examples are reproduced.

An independent script finds the intercept from the second point rather than the first, and the angle with a two-argument arctangent.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

How do I find the slope from two points?

Divide the change in y by the change in x: m = (y₂ − y₁) ÷ (x₂ − x₁). Through (1, 2) and (4, 5) it is 1.

What does a negative slope mean?

The line falls from left to right. Through (−2, −3) and (−7, 4) the slope is −7/5.

What is the slope of a vertical line?

Undefined, because the run is 0. Points with the same x give a vertical line such as x = 2.

How do I get the equation of the line?

Use y = mx + b with b = y₁ − m·x₁. Through (1, 2) and (4, 5) the line is y = x + 1.

Does the order of the points matter?

No. Swapping them changes the sign of both rise and run, so the slope stays the same.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 3 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.