Geometry · Formula v1.0

Distance & Slope Calculator

Calculate the distance and slope between two points on a plane.

An undefined slope means the two points share the same x-coordinate. At the worked-example inputs, the distance is 5. Distance is the straight-line length between the points, and slope is the steepness of the line joining them. On the example, points 0, 0 and 4, 3 are 5 apart with a slope of 0.75, so the line rises 3 for every 4 across. A positive slope goes up to the right, a negative one goes down and zero is horizontal. Use it in graphs, roof pitch, road grades and any rate of change: slope is the rate at which y changes per unit of x. It returns distance, slope.

FreeNo sign-upInputs stay in-browserCSV exportReviewed August 28, 2026
LAST REVIEWEDAugust 28, 2026Inputs stay in your browser
Live calculation

Enter your numbers

Calculated result
Distance5
Slope0.75
Sensitivity check

What if x₁ changes?

-10% input5.8
0% input5
+10% input4.2

Transparent method

The formula

Distance = √((x₂−x₁)² + (y₂−y₁)²); slope = (y₂−y₁) ÷ (x₂−x₁)

Worked example

Distance5
Slope0.75

Example inputs

x₁0
y₁0
x₂4
y₂3

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

Worked-example inputs and the results they produce for the distance & slope calculator.
InputValue used
x₁0
y₁0
x₂4
y₂3
Distance5
Slope0.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.

Common geometry questions

Sources and evidence

Background reading

Guides that use this calculator

Definitions

Terms used on this page