Line Equation Calculator (Slope-Intercept)
Turn two points into the slope-intercept equation y = mx + b, with the slope, y-intercept and x-intercept — vertical lines handled.
How it works
m = (y₂ − y₁)/(x₂ − x₁) · b = y₁ − m·x₁ · y = mx + b
Two points determine a unique line. First find the slope m from the rise over run, then back out the y-intercept b by substituting either point into y = mx + b. The result y = mx + b is the slope-intercept form, ready to graph or evaluate at any x. When both points share an x-value the line is vertical and takes the form x = constant instead.
Worked example
For (1, 2) and (3, 8): m = (8 − 2)/(3 − 1) = 3, then b = 2 − 3·1 = −1, so the line is y = 3x − 1.
Sources: Linear equation — Wikipedia
Frequently asked questions
What is the y-intercept?
It is the y-value where the line crosses the y-axis (x = 0). In y = mx + b, b is that intercept.
Why can’t a vertical line be written as y = mx + b?
A vertical line has an undefined slope, so there is no valid m. It is written x = constant, because every point on it shares the same x-value.
How do I find where the line crosses the x-axis?
Set y = 0 and solve: x = −b/m. This only exists when the slope m is non-zero (a horizontal line never crosses the x-axis unless it is the axis itself).
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.