SwiftTools

Equation of a Line Calculator

Give this equation of a line calculator two points, or one point plus a slope, and it returns the line in slope-intercept, point-slope, and standard form — with the slope and intercept math shown step by step. Vertical and horizontal lines are handled as special cases.

Your line
m = (y2 − y1) / (x2 − x1) · b = y1 − m·x1 · forms: y = mx + b, y − y1 = m(x − x1), Ax + By = C

Vertical lines (x1 = x2) have an undefined slope and are reported as x = constant. Numbers are rounded to 4 decimals in display.

How the equation of a line calculator works

Every non-vertical line can be written in three forms. Slope-intercept (y = mx + b) names the slope m and the y-intercept b directly. Point-slope (y − y1 = m(x − x1)) plugs a known point and the slope straight in — it is usually the first form you get from two points. Standard form (Ax + By = C, with integer A, B, C) is the convention textbooks use for systems of equations.

The slope comes from rise over run: m = (y2 − y1) / (x2 − x1). Once you have m and one point, the intercept is b = y1 − m·x1, and standard form is found by clearing denominators and reducing to smallest integers (with A kept positive).

Two special cases: a horizontal line (y1 = y2) has slope 0, so the equation is just y = the common y-value; a vertical line (x1 = x2) has undefined slope — no intercept exists — and the equation is x = the common x-value.

m = (y2 − y1) / (x2 − x1) · b = y1 − m·x1 · y = mx + b · y − y1 = m(x − x1) · Ax + By = C

Equation of a line calculator FAQ

What is slope-intercept form?

y = mx + b, where m is the slope (how steep the line is) and b is the y-intercept (where the line crosses the y-axis). It is the most readable form: for y = 2x + 1 the line climbs 2 units for every 1 unit it runs, starting at (0, 1).

How do you find the slope from two points?

Divide the change in y by the change in x: m = (y2 − y1) / (x2 − x1). For points (0, 0) and (2, 4): m = (4 − 0) / (2 − 0) = 4/2 = 2. Enter any two points above to see the steps.

What is the equation of a vertical line?

x = a constant — for example x = 3. A vertical line has an undefined slope (you would divide by zero), so it cannot be written in slope-intercept form; x is the same for every point on it. This calculator detects x1 = x2 and reports it automatically.

Point-slope vs slope-intercept — which to use?

Use point-slope (y − y1 = m(x − x1)) as the working form when you know a point and the slope — it writes itself. Convert to slope-intercept (y = mx + b) when you want to read the intercept off, or graph quickly. This calculator shows both.

What is standard form?

Ax + By = C, with A, B, and C integers (and A positive by convention) — for example 2x − y = 6. It is preferred for solving systems of equations by elimination. This calculator reduces A, B, C to the smallest integers automatically.