Line Equation Calculator
Enter two points and get the equation of the line through them, in every form, with a graph.
Last updated: June 22, 2026 · Reviewed by TG we-Calculate Editorial TeamPoint A (x₁, y₁)
Point B (x₂, y₂)
- 1
Rise (Δy)
y₂ − y₁ = 8 − 2 = 6 - 2
Run (Δx)
x₂ − x₁ = 4 − 1 = 3 - 3
Slope m = Δy ÷ Δx
6 ÷ 3 = 2
Formula
How this is calculated
A straight line through two points is fully determined by its slope and where it crosses the y-axis. The slope m is the rise over the run — the change in y divided by the change in x: m = (y₂ − y₁) ÷ (x₂ − x₁). Once you have the slope, the y-intercept b is found by substituting either point into y = mx + b and solving, which gives b = y₁ − m·x₁.
From these two numbers the calculator writes the line in three equivalent forms: slope-intercept (y = mx + b), point-slope (y − y₁ = m(x − x₁)), and standard form (Ax + By = C with integer coefficients). The x-intercept, where the line crosses the x-axis, is −b ÷ m.
Two special cases are handled separately. If both points have the same x-value the line is vertical, the slope is undefined, and the equation is simply x = x₁. If the two y-values are equal the line is horizontal with slope 0 and equation y = y₁.
Examples
| Input | Result |
|---|---|
| (1, 2) and (4, 8) | y = 2x |
| (0, 3) and (2, 7) | y = 2x + 3 |
Frequently asked questions
Compute the slope m = (y₂ − y₁)/(x₂ − x₁), then the y-intercept b = y₁ − m·x₁. The line is y = mx + b.
The line is vertical, its slope is undefined, and the equation is x = x₁ (a constant).
Ax + By = C with integer coefficients and A ≥ 0. It is derived from the slope-intercept form by clearing fractions and moving the x-term to the left.
Also known as
Sources & references
TG we-Calculate Editorial Team. (2026). Line Equation Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/line-equation-calculator
TG we-Calculate Editorial Team. "Line Equation Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/line-equation-calculator.
TG we-Calculate Editorial Team, "Line Equation Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/line-equation-calculator
@misc{wecalculate_line_equation_calculator, title = {Line Equation Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/line-equation-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
