Slope Calculator
The slope of a line measures its steepness and direction, defined as the ratio of vertical change (rise) to horizontal change (run) between any two points. Given two points (x₁, y₁) and (x₂, y₂), the slope m = (y₂ − y₁) / (x₂ − x₁) tells you how many units the line rises or falls for each unit moved horizontally.
This calculator also derives the full equation of the line in slope-intercept form (y = mx + b), the angle of inclination in degrees, the y-intercept, and the straight-line distance between the two points. Vertical lines (x₁ = x₂) are handled as a special case with undefined slope.
How it works
m = (y₂ − y₁) / (x₂ − x₁); b = y₁ − m·x₁; angle θ = arctan(m) in degrees; distance = √((x₂−x₁)² + (y₂−y₁)²). For vertical lines (x₁ = x₂), slope is undefined and the equation is x = x₁.
Use cases
- Finding the gradient of a road, ramp, or roof pitch in civil engineering
- Determining the equation of a line through two points in algebra class
- Calculating the angle of a ski slope or hiking trail
- Analyzing trends in data by fitting a line through two reference points
- Computing the distance between two coordinates on a map or grid
Frequently asked questions
How do you calculate the slope between two points?
Use the formula m = (y₂ − y₁) / (x₂ − x₁), which is the change in y divided by the change in x, often called rise over run. For example, the slope between (1, 2) and (4, 8) is (8 − 2) / (4 − 1) = 6 / 3 = 2. A positive slope rises to the right and a negative slope falls.
What does a slope of zero mean?
A slope of zero means the line is perfectly horizontal — the y-value never changes as x increases, so there is no rise. Its equation has the form y = b. This is different from an undefined slope, which occurs on a vertical line where the run is zero.
Why is the slope of a vertical line undefined?
On a vertical line the two points share the same x-value, so x₂ − x₁ = 0, and dividing by zero is undefined. That is why the slope cannot be a number for vertical lines. This calculator handles that case by reporting the equation as x = x₁ instead.
How do you find the equation of a line from two points?
First find the slope m = (y₂ − y₁) / (x₂ − x₁), then find the y-intercept with b = y₁ − m·x₁. The line is then written in slope-intercept form as y = mx + b. This calculator computes both m and b and outputs the full equation automatically.
How do you convert slope to an angle in degrees?
Take the arctangent of the slope: angle θ = arctan(m), then convert from radians to degrees. For example, a slope of 1 corresponds to 45°, and a slope of 0 corresponds to 0°. This is useful for expressing road gradients or ramps as an incline angle.