Equation of a Line Calculator

Find the equation of a line from two points or a point and slope: slope-intercept, point-slope and standard forms, both intercepts and the perpendicular slope.

Results

Slope-intercept form (y = mx + b)
y = 2x + 1
Slope (m)
2
Point-slope form
y − 3 = 2(x − 1)
Standard form (Ax + By = C)
2x − y = −1
y-intercept
(0, 1)
x-intercept
(−0.5, 0)
Perpendicular slope (−1 ÷ m)
-0.5

How it’s calculated

A straight line can be written three common ways. With slope m and y-intercept b, or through the point (x₁, y₁):

Slope-intercept: y = mx + b Point-slope: y − y₁ = m(x − x₁) Standard: Ax + By = C Slope from two points: m = (y₂ − y₁) ÷ (x₂ − x₁)

The y-intercept is b (where x = 0) and the x-intercept is −b ÷ m (where y = 0). A line perpendicular to this one has slope −1 ÷ m, and a parallel line has the same slope m.

Example: the points (1, 3) and (3, 7). The slope is (7 − 3) ÷ (3 − 1) = 2, so b = 3 − 2 × 1 = 1 and the line is y = 2x + 1. In point-slope form y − 3 = 2(x − 1); in standard form 2x − y = −1. The x-intercept is −1 ÷ 2 = −0.5 and the perpendicular slope is −0.5.

Special cases: a vertical line (equal x values) is x = constant and has no slope; a horizontal line (slope 0) is y = constant, and its perpendicular is vertical. Standard form is shown with whole-number coefficients (A > 0) when your inputs allow it.

Frequently asked questions

How do I find the equation of a line through two points?

Work out the slope m = (y₂ − y₁)/(x₂ − x₁), then use y − y₁ = m(x − x₁) and rearrange to y = mx + b.

What if the two points have the same x?

The line is vertical: x = that value. It has an undefined slope and no slope-intercept form, and the calculator shows it as x = constant.

How do I get the perpendicular slope?

Take the negative reciprocal of the slope: −1/m. Perpendicular lines have slopes that multiply to −1. A horizontal line has a vertical perpendicular, which has no slope.

What is standard form?

Ax + By = C, usually with whole-number A, B and C and A positive. It is handy for finding intercepts and for solving systems of equations.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator