Line Equation Calculator

Find the equation of a line from two points, or from a slope and one point, in all three common forms.

Inputs

What do you know?
Point 1

Point 2

Try an example

Equation of the line

y = 2x + 1

The same line written in three standard forms is below.

Slope-intercept form
y = 2x + 1
Point-slope form
y − 3 = 2(x − 1)
Standard form (Ax + By = C)
2x − y = −1
Slope (m)
2
y-intercept
1
x-intercept
−0.5

−6−4−2024680246810(0, 1)(−0.5, 0)A (1, 3)B (4, 9)

Step-by-step solution

  1. Find the slope from the two points.

    m = (9 − 3) / (4 − 1) = 6 / 3 = 2

  2. Write the point-slope form using the point and the slope.

    y − 3 = 2(x − 1)

  3. Find the y-intercept b from b = y₁ − m·x₁.

    b = 3 − (2)·1 = 1

  4. Write the slope-intercept form y = mx + b.

    y = 2x + 1

  5. Rearrange to standard form Ax + By = C using whole-number coefficients.

    2x − y = −1

Three forms of the same line

y = mx + b slope-intercept form

y − y₁ = m(x − x₁) point-slope form

Ax + By = C standard form

m
the slope, rise over run
b
the y-intercept, where the line crosses the y-axis
x₁, y₁
a known point on the line
A, B, C
whole numbers, with A not negative

Each form answers a different question quickly. Slope-intercept form shows the slope and where to start drawing. Point-slope form is how you write a line when you know one point and the slope. Standard form has no fractions, which makes intercepts and systems of equations easier to handle.

A vertical line is the exception. It has no slope, so it is written x = c and only standard form can express it (as 1x + 0y = c).

How the equation is built

  1. With two points, find the slope: m = (y₂ − y₁) / (x₂ − x₁). In slope mode you already have it. If the x-values match, stop: the line is vertical.
  2. Write point-slope form with either point.
  3. Find the y-intercept from b = y₁ − m·x₁ and write y = mx + b.
  4. For standard form, move the x term to the left and scale so that A, B and C are the smallest whole numbers with the same ratio.
  5. For the x-intercept, set y = 0 and solve: x = −b / m.

Worked examples

Line through (2, −1) and (6, 7).

m = (7 − (−1)) / (6 − 2) = 8/4 = 2

b = −1 − 2·2 = −5

y = 2x − 5

2x − y = 5

x-intercept: 0 = 2x − 5, x = 2.5

Slope −3/4 through (4, 1).

y − 1 = −0.75(x − 4)

b = 1 − (−0.75)·4 = 4

y = −0.75x + 4

Multiply by 4: 4y = −3x + 16

3x + 4y = 16

In the first example the second point confirms the result: 2(6) − 5 = 7. The graph above marks both intercepts when they are close enough to the points to fit comfortably in view.

Equations of common lines

Most lines have an equation in all three forms. The two exceptions are worth knowing. A horizontal line never crosses the x-axis, so it has no x-intercept, and a vertical line has no slope, so it can only be written as x = a number.

ThroughEquationStandard formy-interceptx-intercept
(0, 0) and (1, 1)y = xx − y = 000
(0, 1) and (2, 5)y = 2x + 12x − y = −11−0.5
(1, 2) and (3, 8)y = 3x − 13x − y = 1−11/3
(−1, 4) and (2, −2)y = −2x + 22x + y = 221
(−2, 4) and (5, 4)y = 4y = 44None (horizontal line)
(3, 1) and (3, 8)x = 3x = 3None (vertical line)3

Frequently asked questions

Which form of the equation should I use?

Use slope-intercept form, y = mx + b, to graph a line or to read its slope and y-intercept. Use point-slope form when a problem hands you a point and a slope. Use standard form, Ax + By = C, when you need whole-number coefficients, want the intercepts quickly, or are solving a system of equations. All three describe the same line.

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

Because it has no slope to put in for m. Every point on a vertical line has the same x-value and y can be anything, so no single function y = f(x) describes it. It is written x = c, where c is the shared x-coordinate. The calculator reports this and marks the slope as undefined.

What if I enter the same point twice?

Then there is no unique line. Infinitely many lines pass through one point, so the calculator asks for two different points. If you do know the slope, switch to "Slope and a point" and the line is fully determined.

Why are the standard form coefficients whole numbers?

The usual convention writes A, B and C as the smallest integers with the same ratio, with A positive. So y = −0.75x + 4 becomes 3x + 4y = 16. When an input is a decimal that cannot be scaled to reasonable integers, the calculator shows the coefficients as decimals instead.

Does the line have an x-intercept?

Every line has one except a horizontal line that is not the x-axis. A horizontal line at y = 2 never reaches y = 0. A line that is exactly the x-axis, y = 0, touches it everywhere, and the calculator says so.

Can I enter a fractional slope?

Yes, in "Slope and a point" mode. Type a fraction such as -3/4, a decimal or a whole number.