Skip to content

Slope Calculator: Slope of a Line Through Two Points

Slope, angle, grade, intercept and equation of the line through two points.

Your details

Results update as you type

Slope m

2

Equation of the line
y = 2x + 1
Angle with the x-axis
63.4349 °
Grade (percent slope)
200%
y-intercept b
1
Standard form Ax + By = C
2x − y = −1
Distance between the points
8.94427191
Midpoint
(3, 7)

Positive slope: the line rises from left to right.

Step-by-step solution
  1. Rise and run: Δy = 11 − 3 = 8, Δx = 5 − 1 = 4
  2. Slope: m = Δy / Δx = 8 / 4 = 2
  3. y-intercept: b = y₁ − m·x₁ = 3 − 2 × 1 = 1
  4. y = 2x + 1
  5. Angle: θ = arctan(2) = 63.4349°
  6. Distance: d = √(Δx² + Δy²) = √(4² + 8²) = 8.94427191

The slope of a line measures how steep it is: how much it rises (or falls) for each unit you move to the right. Give this slope calculator two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) and it returns the slope mm, the same slope as an exact fraction, the angle the line makes with the x-axis, the percent grade, the y-intercept bb and the equation of the line in slope-intercept form y=mx+by = mx + b and in standard form.

As a bonus you also get the distance between the two points and the midpoint of the segment that joins them. Each result comes with the working, so you can check homework, prepare a lesson or verify a design drawing line by line.

Two points on the same vertical line are handled properly: the slope is reported as undefined and the equation is given as x=constantx = \text{constant}, instead of an error or a meaningless huge number.

How to use this calculator

  1. Enter the coordinates of the first point, x1x_1 and y1y_1.
  2. Enter the coordinates of the second point, x2x_2 and y2y_2. Order does not matter: swapping the points gives the same slope.
  3. Read the slope and the equation of the line. With whole-number coordinates the slope is also shown as a reduced fraction, and the equation uses exact fractions.
  4. Use the angle or the grade for ramps, roofs, roads and terrain; use the standard form for systems of equations.
  5. Open the steps to see each subtraction and division.

The formula

The slope is the rise over the run:

m=ΔyΔx=y2−y1x2−x1(x2≠x1)m = \frac{\Delta y}{\Delta x} = \frac{y_2 - y_1}{x_2 - x_1} \qquad (x_2 \neq x_1)

The y-intercept follows from either point: b=y1−m x1b = y_1 - m\,x_1, which gives the slope-intercept form y=mx+by = mx + b. Multiplying through by the run gives the integer standard form (y2−y1) x−(x2−x1) y=C(y_2 - y_1)\,x - (x_2 - x_1)\,y = C.

The angle of inclination is θ=arctan⁡(m)\theta = \arctan(m), and the grade is the slope as a percentage, 100×m100 \times m %. The distance between the points comes from Pythagoras, d=Δx2+Δy2d = \sqrt{\Delta x^2 + \Delta y^2}, and the midpoint is (x1+x22,y1+y22)\left(\frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2}\right).

If x1=x2x_1 = x_2 the run is zero, the line is vertical and the slope is undefined; its equation is x=x1x = x_1.

Worked example

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

  • Rise and run: Δy=4−1=3\Delta y = 4 - 1 = 3 and Δx=4−(−2)=6\Delta x = 4 - (-2) = 6.
  • Slope: m=36=1/2=0.5m = \frac{3}{6} = 1/2 = 0.5.
  • Intercept: b=1−0.5×(−2)=2b = 1 - 0.5 \times (-2) = 2, so the line is y = (1/2)x + 2, or in standard form x − 2y = −4.
  • Angle: arctan⁡(0.5)≈26.57°\arctan(0.5) \approx 26.57°; grade: 50%.
  • Distance: 62+32=45≈6.708\sqrt{6^2 + 3^2} = \sqrt{45} \approx 6.708.

A road that climbs 8 m over 100 m of horizontal distance has slope 0.08, a grade of 8% and an angle of only 4.57°.

Reading a slope

Slope mm Line Angle
m>0m > 0 Rises from left to right Between 0° and 90°
m=0m = 0 Horizontal 0°
m<0m < 0 Falls from left to right Between 0° and −90°
Undefined Vertical 90°

Two non-vertical lines are parallel when their slopes are equal, and perpendicular when the product of their slopes is −1-1: a line of slope 2 is perpendicular to one of slope −12-\frac{1}{2}.

Slope as a percentage, an angle or a ratio

Engineers, builders and hikers express the same steepness in different ways. A grade of 100% is not vertical: it is a 45° slope, where the rise equals the run. Accessible ramps are often limited to a 1:12 ratio — about 8.33% or 4.76° — and roof pitches are quoted as rise per 12 units of run in the US. To convert, use grade=100tan⁡θ\text{grade} = 100 \tan\theta and θ=arctan⁡(grade/100)\theta = \arctan(\text{grade}/100).

In mathematics and physics, slope is also the rate of change: on a distance–time graph it is a speed, and on a cost–quantity graph it is the cost per unit. For curves rather than lines, see the quadratic formula calculator.

Frequently asked questions

How do you find the slope from two points?

Subtract the y-coordinates and the x-coordinates in the same order, then divide: m = (y₂ − y₁) / (x₂ − x₁). For (1, 3) and (5, 11), m = 8 / 4 = 2.

What is an undefined slope?

When both points have the same x-coordinate, the run is 0 and the division is impossible. The line is vertical, its equation is x = constant, and its slope is undefined — not zero and not infinite.

What is the difference between a zero slope and an undefined slope?

A zero slope means the line is horizontal (no rise at all), with an equation y = constant. An undefined slope means the line is vertical (no run), with an equation x = constant.

How do I convert a slope to degrees or percent?

Percent grade is the slope times 100. The angle in degrees is the arctangent of the slope. A slope of 0.5 is a 50% grade and about 26.57°; a slope of 1 is a 100% grade and exactly 45°.

Is "gradient" the same as slope?

Yes. In British and many international curricula the slope of a straight line is called its gradient. It is also written as rise over run, or Δy/Δx.

Sources

Last updated:

More Math calculators

People also use