Line Equation from Two Points Calculator
Turn two points into a complete line equation. Enter (x₁, y₁) and (x₂, y₂) — decimals and negatives welcome — and get the slope, the y-intercept, and the line written three ways: slope-intercept, point-slope, and standard form.
Example: with x₁ (first point) 1 · y₁ (first point) 3 · x₂ (second point) 4 · y₂ (second point) 9 → Slope-intercept form: y = 2x + 1.
- Slope (m)2
- y-intercept (b)1
- Point-slope formy - 3 = 2(x - 1)
Computed by the calculator below using its default values. Change any input to see your own numbers.
Slope first: m = (y₂ − y₁)/(x₂ − x₁) = (9 − 3)/(4 − 1) = 2. Then the intercept: b = y₁ − m·x₁ = 3 − 2 = 1. The line is y = 2x + 1.
Two points pin down exactly one line
Through any two distinct points there is exactly one straight line, so two points are all the information a line equation needs. The recipe has two steps in a fixed order: slope first, m = (y₂ − y₁)/(x₂ − x₁), because the intercept formula needs it; then b = y₁ − m·x₁, which slides the line to actually pass through your point. For (1, 3) and (4, 9): m = 6/3 = 2, then b = 3 − 2(1) = 1, giving y = 2x + 1.
The best habit this calculator can teach is the final check: plug both original points into the finished equation. At x = 4, y = 2(4) + 1 = 9 — matches the second point, so the line is right. Either point works for computing b, too; if the two give different intercepts, the slope step has an error.
How it’s calculated
m = (y₂ − y₁)/(x₂ − x₁); b = y₁ − m·x₁; slope-intercept y = mx + b; point-slope y − y₁ = m(x − x₁) written from the first point; standard form mx − y = −b scaled so the x-coefficient is positive. When x₁ = x₂ the line is vertical and reported as x = x₁. Displayed values are rounded to 4 decimal places.
The two points must be distinct — one point alone leaves the slope completely undetermined.
Worked example: the line through (1, 3) and (4, 9)
| Step | Computation | Result |
|---|---|---|
| Slope | (9 − 3) / (4 − 1) | m = 2 |
| Intercept | 3 − 2 × 1 | b = 1 |
| Equation | y = mx + b | y = 2x + 1 |
| Check with point 2 | 2 × 4 + 1 | 9 ✓ |
Computed with m = Δy/Δx and b = y₁ − m·x₁; the check row substitutes the unused point.
Common mistakes
- Subtracting in one order on top and the other on the bottom — (y₂ − y₁) over (x₁ − x₂) flips the slope's sign.
- Putting the x-differences in the numerator: slope is rise over run, Δy/Δx.
- Reporting y₁ as the intercept — b is the y-value at x = 0, which needs the b = y₁ − m·x₁ step unless x₁ happens to be 0.
- Missing the vertical-line case: when both points share an x-value, the answer is x = a, and no y = mx + b exists.
Frequently asked questions
How do you find the equation of a line from two points?
Two steps: slope m = (y₂ − y₁)/(x₂ − x₁), then y-intercept b = y₁ − m·x₁. Write y = mx + b. For (1, 3) and (4, 9): m = 2, b = 1, so y = 2x + 1.
Does it matter which point I call (x₁, y₁)?
No — swapping the points negates both Δy and Δx, so the slope is unchanged, and either point plugged into b = y − mx yields the same intercept. Consistency within each formula is all that matters.
What if the two points have the same x-coordinate?
The run Δx is zero, so the slope is undefined and the line is vertical: x = that shared value. It cannot be written in slope-intercept or point-slope form.
How do I check my line equation?
Substitute both original points; each must satisfy the equation exactly. One point matching is not enough — a wrong slope can still pass through the point you used to find b.
Why show three forms of the same line?
They are interchangeable but suited to different jobs: slope-intercept for graphing and comparing, point-slope for writing equations quickly from data, standard form for integer-coefficient work and finding both intercepts fast.