Advanced maths

Equation of a line calculator

Find slope, intercept and the line through two distinct points.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Try it, understand it

Explore the result

Distinct points may define a sloping, horizontal or vertical line.

Worked example comparison
ExampleOutputWhat to notice
A sloping lineSlope2The default points have slope two and y-intercept one.
A horizontal lineSlope0Equal y coordinates give slope zero.
A vertical lineSlopeUndefined (vertical)Equal x coordinates give no finite slope.

Check your understanding

Do coincident points determine one line?

No. Infinitely many lines pass through that one point.

Does every vertical line have a y-intercept?

No. A vertical line away from the y-axis does not meet it; the y-axis itself has every point as an intersection.

Behind the numbers

How this calculation works

Two distinct points determine a line. For a nonvertical line, slope is rise divided by run, and substitution gives the intercept. When x coordinates match, the equation is vertical and has no finite slope.

THE FORMULAm = (y₂ − y₁)/(x₂ − x₁); b = y₁ − m x₁

A worked example

The points (0, 1) and (2, 5) give slope 2, intercept 1 and equation y = 2x + 1.

Good to know

An estimate under the stated inputs and model. Displayed decimals are rounded; verify assumptions before relying on the result.

A little curiosity

A vertical line has no finite slope

The linear equation solver finds where two linear expressions have equal values, while the linear inequality solver identifies which side of their equality boundary satisfies a comparison.

Points (3, 1) and (3, 8) lie on x = 3. Their rise is seven, but their run is zero. Division by zero does not produce a usable slope, so the tool reports a vertical equation instead of pretending it has a very large finite slope.

Two identical points create another special case: infinitely many lines pass through that single location. They cannot determine a unique line, so the tool asks for distinct points.

Cartesian distance measures the separation of the same two points. It is independent of whether the line has a finite slope or is vertical.

Slope depends on the coordinate scales

Slope is change in y divided by change in x. If y is money and x is time, the slope has money-per-time units. A line’s apparent steepness on a chart also depends on how its axes are scaled.

The intercept is the y value at x = 0. It need not lie within the segment between the two points. The equation describes the whole mathematical line, not only the measured interval.

A vertical line has no finite slope

Distinct points with equal x coordinates determine a vertical line x = constant. The rise-over-run denominator is zero, so no finite slope or y = mx + b form exists. A vertical line away from the y-axis has no y-intercept, while the y-axis itself meets every point on that axis.

The plotted segment is only the displayed part of the line through the two points. Coincident points do not determine one unique line and are rejected. The angle type identifier addresses an already supplied planar angle rather than inferring slope or intercept from a drawing.

A few questions, answered

Does swapping the two points change the line?

No. Both the numerator and denominator of the slope reverse signs, leaving the same line.

Can the intercept be negative?

Yes. The line can cross the y axis below zero.

Find your calculator

Start typing to explore the library.