Distance & Slope: worked example
| x₁ | 0 |
|---|---|
| y₁ | 0 |
| x₂ | 4 |
| y₂ | 3 |
| Distance | 5 |
| Slope | 0.75 |
Distance & Slope: formula
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.
Distance & Slope: changing x₁
| x₁ | Distance | Slope |
|---|---|---|
| -2 | 6.7 | 0.5 |
| -1 | 5.8 | 0.6 |
| 0 (example) | 5 | 0.75 |
| 1 | 4.2 | 1 |
| 2 | 3.6 | 1.5 |
Distance & Slope: compare input ranges
| Input | Tested from | To | Distance: low input | Distance: high input | Swing |
|---|---|---|---|---|---|
| x₁ | -1 | 1 | 5.8 | 4.2 | 1.6 (32%) |
| x₂ | 3 | 5 | 4.2 | 5.8 | 1.6 (32%) |
| y₁ | -1 | 1 | 5.7 | 4.5 | 1.2 (24%) |
| y₂ | 2 | 4 | 4.5 | 5.7 | 1.2 (24%) |
Distance & Slope: individual input comparisons
| Input | Value | Distance | Slope |
|---|---|---|---|
| x₁ | -2 | 6.7 | 0.5 |
| -1 | 5.8 | 0.6 | |
| 0 | 5 | 0.75 | |
| 1 | 4.2 | 1 | |
| 2 | 3.6 | 1.5 | |
| y₁ | -2 | 6.4 | 1.3 |
| -1 | 5.7 | 1 | |
| 0 | 5 | 0.75 | |
| 1 | 4.5 | 0.5 | |
| 2 | 4.1 | 0.25 | |
| x₂ | 2 | 3.6 | 1.5 |
| 3 | 4.2 | 1 | |
| 4 | 5 | 0.75 | |
| 5 | 5.8 | 0.6 | |
| 6 | 6.7 | 0.5 | |
| y₂ | 1 | 4.1 | 0.25 |
| 2 | 4.5 | 0.5 | |
| 3 | 5 | 0.75 | |
| 4 | 5.7 | 1 | |
| 5 | 6.4 | 1.3 |
Distance & Slope: combined input changes
| x₁ / x₂ | 2 | 4 | 6 |
|---|---|---|---|
| -2 | 5 | 6.7 | 8.5 |
| -1 | 4.2 | 5.8 | 7.6 |
| 0 | 3.6 | 5 | 6.7 |
| 1 | 3.2 | 4.2 | 5.8 |
| 2 | 3 | 3.6 | 5 |
Distance & Slope: which assumptions move the result?
Distance & Slope: values and definitions
| Quantity and definition | Value used |
|---|---|
| x₁ | 0 |
| y₁ | 0 |
| x₂ | 4 |
| y₂ | 3 |
| Distance | 5 |
| Slope | 0.75 |
Common error: 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.
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.
Geometry calculators: Trapezoid Area Calculator, Parallelogram Area Calculator, Rectangular Prism Volume Calculator, Triangle Third Side Calculator, Arc Length and Sector Area Calculator, Ellipse Area Calculator.
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.
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.
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.
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.