Transparent method
The formula
Worked example
Example inputs
How to interpret the result
A vertical line has no defined slope at all, not a slope of zero, and the two get treated as interchangeable more often than they should. Zero slope describes a flat horizontal line; an undefined slope describes a line running straight up and down, where the rise-over-run formula divides by a run of zero and simply has no answer.
Before you rely on it
What to check
Check whether the two points share the same x-coordinate before reading a slope value. If they do, the line is vertical and slope is undefined, not zero.
The common error
Where people go wrong with distance & slope calculator
Reporting a vertical line's slope as zero because the calculation returned nothing usable. Zero and undefined describe opposite geometries, one flat and one vertical, and mixing them up inverts the picture entirely.
Step by step
The worked example, input by input
| Input | Value used |
|---|---|
| x₁ | 0 |
| y₁ | 0 |
| x₂ | 4 |
| y₂ | 3 |
| Distance | 5 |
| Slope | 0.75 |
Where the inputs come from
Enter the x and y coordinates of two points. The distance is the square root of the sum of the squared differences, from the Pythagorean theorem, and the slope is the change in y over the change in x. If the x values are equal the line is vertical and the slope is undefined. Use consistent units on both axes, since a slope mixes them.
When the result stops applying
A vertical line has an undefined slope, and the calculator reports it as such. Slope depends on the scale of the axes, so two graphs with different scales look different. Straight-line distance ignores paths and terrain. For latitude and longitude, plane formulas give inaccurate distances.
What to compare it with
See the midpoint calculator, the Pythagorean theorem and right triangle pages, and the trigonometry calculator to convert slope to an angle. The drain slope and roof calculators in the trades category use slope in practice. The percentage change page expresses rates of change.
People also ask
Frequently asked questions
How do I calculate the slope between two points?
Subtract the y values and divide by the difference of the x values. Rise over run.
What does a slope of zero mean?
The line is horizontal, so y does not change as x changes, and the equation of the line is simply y equals a constant.
How is the distance formula related to the Pythagorean theorem?
The horizontal and vertical differences form the legs of a right triangle, and the distance is its hypotenuse.