Slope Calculator

First point (x₁, y₁)
Second point (x₂, y₂)
Math Updated 30 Oct 2026

Finds the slope (gradient) of the straight line through two points, m = (y₂ − y₁) ÷ (x₂ − x₁), along with the equation of the line in slope-intercept form y = mx + b. You also get the y-intercept, the angle the line makes with the x-axis in degrees, the slope as a percentage grade, the rise and run between the points and the distance between them. Vertical and horizontal lines are handled correctly.

  • Points are in an ordinary Cartesian plane with equal scales on both axes.

Formula

m = (y₂ − y₁) ÷ (x₂ − x₁); b = y₁ − m × x₁; θ = arctan(m); grade = m × 100%
  • A positive slope rises from left to right, a negative slope falls, 0 is horizontal and a vertical line has an undefined slope.
  • Distance between the points = √((x₂ − x₁)² + (y₂ − y₁)²).
  • Results are shown to up to 6 decimal places; the angle to 4.

Points (1, 2) and (5, 8)

Inputs
  • x₁: 1
  • y₁: 2
  • x₂: 5
  • y₂: 8

Δy = 8 − 2 = 6 and Δx = 5 − 1 = 4, so m = 6 ÷ 4 = 1.5. b = 2 − 1.5 × 1 = 0.5, giving y = 1.5x + 0.5. The angle is arctan 1.5 = 56.3099°, a grade of 150%, and the points are √(16 + 36) = 7.211103 apart.

Sources & references

Frequently asked questions

How do I find the slope from two points?
Subtract the y-values and divide by the difference of the x-values, in the same order: m = (y₂ − y₁) ÷ (x₂ − x₁). It does not matter which point you call first.
What is the slope of a vertical line?
Undefined, because the run Δx is zero and you cannot divide by zero. Its equation is x = constant.
How is slope related to angle and grade?
The slope is the tangent of the angle with the x-axis, and the grade is the slope as a percentage. A 10% road grade is a slope of 0.1, an angle of about 5.71°.

Related calculators

Pythagorean Theorem Calculator Solves a right triangle with the Pythagorean theorem, a² + b² = c². Give any two of the two legs, the hypotenuse, the area and the perimeter, and it finds the missing sides, then adds the area, perimeter, both acute angles and the height dropped onto the hypotenuse. Lengths can be in metric or imperial units, from millimetres to nautical miles, and the area in anything from square millimetres to acres. Handy for checking that a corner is square, sizing a ladder or ramp, or finding a diagonal. Quadratic Formula Calculator Solves any quadratic equation with the quadratic formula, x = (−b ± √(b² − 4ac)) ÷ 2a. Enter the equation in standard, vertex or factored form and get both roots as decimals and in exact simplified radical form, the discriminant and what it says about the roots, the vertex, the axis of symmetry, the y-intercept and the equation rewritten in all three forms. Switch on complex roots to solve equations with a negative discriminant, and show the working step by step. Area Calculator Finds the area of 2D shapes: rectangle, square, triangle (from base and height, three sides, two sides and the angle between them, or two angles and the side between them), circle, semicircle, circular sector, ellipse, trapezoid, parallelogram (three ways), rhombus (three ways), kite (two ways), regular pentagon, hexagon and octagon, annulus (ring), any quadrilateral from its diagonals and any regular polygon. Pick the shape, enter its dimensions in any length unit (angles in degrees or radians), and you get the area in that unit squared, plus square metres and square feet, and the perimeter where the inputs fix it. Handy for working out the area of a room, a garden bed or a patio before buying flooring, mulch or bricks.