StatGardenREF. DESK
Calculators/Maths/Equation of a line
Maths

Equation of a line calculator

Slope-intercept, point-slope and standard form of the line through two points.

Published 6 August 2026 · Updated 23 September 2026

What this calculator does

Three forms describe the same line, and each is convenient for something different. Slope-intercept shows the gradient and where the line crosses the y-axis; point-slope is what you write down first from two points; standard form handles vertical lines that slope-intercept cannot.

Everything follows from the slope. Two points at (1, 2) and (4, 11) give a slope of 3.000, which produces y = 3.000x − 1.000 and every other form from there.

The formula

Formulam = (y₂−y₁)/(x₂−x₁); y − y₁ = m(x − x₁); y = mx + b

The slope is the change in y over the change in x. Substituting one point gives the y-intercept, and rearranging produces the other forms.

TermMeaning
Slope-intercept formy = mx + b, showing gradient and y-intercept directly.
Point-slope formy − y₁ = m(x − x₁), the form that falls out of two points immediately.
Standard formAx + By = C, which can represent vertical lines.

The inputs explained

FieldWhat to enter
x₁x coordinate of the first point.
y₁y coordinate of the first point.
x₂x coordinate of the second point.
y₂y coordinate of the second point.

When to use it

Finding a line through two points

The most common line problem there is.

Converting between forms

Different contexts want different forms of the same line.

Finding where a line crosses the axes

Both intercepts follow from the equation.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How does the second point change the line?

The same first point with three different second points.

First point (1, 2), second point x = 4
Second point ySlope (m)Slope-intercept form
(4, 5)1.000y = 1.000x + 1.000
(4, 11)3.000y = 3.000x − 1.000
(4, 20)6.000y = 6.000x − 4.000
A second point at (4, 5) gives a slope of 1.000 and y = 1.000x + 1.000. Moving it to (4, 20) triples the rise across the same run, giving a slope of 6.000 and y = 6.000x − 4.000.

Questions

Why can a vertical line not be written as y = mx + b?

Because its slope is undefined: the run is zero, so the division fails. A vertical line is written x = constant, which the standard form Ax + By = C accommodates by setting B to zero.

What does a slope of zero mean?

A horizontal line. The y value never changes, so there is no x-intercept unless the line is the x-axis itself, in which case every point is an intercept.

Does the order of the points matter?

No. Swapping them negates both the numerator and the denominator of the slope, which cancels. The same line results either way.

How do I find a perpendicular line?

Take the negative reciprocal of the slope. A line with slope 3 has perpendiculars with slope −1/3, since the product of perpendicular slopes is always −1 for non-vertical lines.

For the distance from a point to a line, see the point to line distance calculator. For where a line meets a circle, see the circle line intersection calculator.