Skip to content
SmartDailyCalculator

Line Equation Calculator

Enter two points to calculate the slope and equation of the line through them.

Line equation

y = 2x

Slope (m)
2
Y-intercept (b)
0
Working
m = (6 − 2) ÷ (3 − 1) = 2; b = y₁ − mx₁ = 0
Point-slope form
y − 2 = 2(x − 1)

How to use the Line Equation Calculator

  1. Enter the x- and y-coordinates of each point.
  2. Read the line equation and the substituted calculations.
  3. For a vertical line, use its x-coordinate equation rather than a slope-intercept form.

Slope-intercept and point-slope equations

m=y2−y1x2−x1
b=y1−mx1
y=mx+b

Where:

m
= slope
b
= y-intercept
(x₁,y₁),(x₂,y₂)
= the two points
Show as plain text

m = (y₂ − y₁) ÷ (x₂ − x₁) b = y₁ − mx₁ y = mx + b

Subtract coordinates in the same order to find slope. Substitute either point into y = mx + b to find the intercept.

When both x-coordinates match but y-coordinates differ, the line is vertical and is written x = constant. Identical points do not determine a unique line.

Assumptions and limitations

  • Coordinates are finite values from −1,000,000,000,000 through 1,000,000,000,000.
  • Displayed values are rounded to eight decimal places; calculations use JavaScript floating-point arithmetic.

Example: Find the line through (1, 2) and (3, 6)

  1. Slope m = (6 − 2) ÷ (3 − 1) = 2.
  2. Intercept b = 2 − (2 × 1) = 0.
  3. The line equation is y = 2x.

When to use the Line Equation Calculator

Line Equation Calculator FAQs

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

Calculate the slope from the change in y divided by the change in x, then use either point to find the y-intercept in y = mx + b.

What is the equation of a vertical line?

A vertical line has the form x = a constant. Its slope is undefined, so it cannot be written in slope-intercept form.

What if I enter the same point twice?

A single point lies on infinitely many lines, so identical points do not determine a unique line.

References

How this calculator was built and tested is explained in our methodology. Spotted a problem? Let us know.