Line Equation from Two Points Calculator
Find the equation of a line through two points — slope-intercept form (y = mx + b), standard form (Ax + By = C), and point-slope form, with step-by-step working and a graph. Handles vertical lines (x = k) and horizontal lines (y = k) too.
Enter two points
Tip: fractions work too — type 3/4 and the calculator keeps exact fractions.
Result
- Slope (m)
- Y-intercept (b)
- Slope-intercept form
- Point-slope form
- Standard form (Ax + By = C)
Steps
Graph
Worked examples
Example 1 — Points (0, 0) and (2, 4)
Slope m = (4 − 0) / (2 − 0) = 4 / 2 = 2. Since the line passes through the origin, b = 0. y = 2x.
Standard form: 2x − y = 0. Point-slope form: y − 0 = 2(x − 0).
Example 2 — Points (1, 1) and (3, 7)
Slope m = (7 − 1) / (3 − 1) = 6 / 2 = 3. Using point (1, 1): 1 = 3(1) + b → b = −2. y = 3x − 2.
Standard form: 3x − y = 2. Point-slope form: y − 1 = 3(x − 1).
Example 3 — Points (2, 5) and (2, 9) — vertical line
x₁ = x₂ = 2, so Δx = 0 and the slope is undefined. Every point on the line has x-coordinate 2. x = 2.
A vertical line has no slope-intercept form; its standard form is x = 2.
Example 4 — Points (1, 3) and (4, 3) — horizontal line
y₁ = y₂ = 3, so Δy = 0 and slope m = 0. The y-value never changes. y = 3.
Standard form: y = 3 (0x + y = 3).
How it works
- Slope: m = (y₂ − y₁) / (x₂ − x₁), computed as an exact fraction (e.g. 3/4, not 0.75).
- Y-intercept: b = y₁ − m·x₁.
- Forms: slope-intercept y = mx + b, point-slope y − y₁ = m(x − x₁), and standard form Ax + By = C with integer coefficients, A > 0, no common factor.
- Special cases: if x₁ = x₂ the line is vertical (x = k, slope undefined); if y₁ = y₂ the line is horizontal (y = k, slope 0).
Frequently asked questions
How do you find the equation of a line from two points?
First compute the slope m = (y2 − y1) / (x2 − x1). Then find the y-intercept b = y1 − m·x1. The equation is y = mx + b. This calculator does all three steps for you and also shows the point-slope and standard forms.
What is the slope-intercept form from two points?
The slope-intercept form is y = mx + b, where m is the slope and b is the y-intercept. For example, through (1, 1) and (3, 7): m = (7 − 1)/(3 − 1) = 3, b = 1 − 3(1) = −2, so y = 3x − 2.
What is the standard form Ax + By = C from two points?
Rearrange y = mx + b into Ax + By = C with integer coefficients, A > 0, and no common factor. For example, y = 3x − 2 becomes 3x − y = 2. The calculator above prints the standard form automatically.
What happens when x1 = x2 (vertical line)?
When both x-coordinates are equal, Δx = 0 and the slope is undefined — the line is vertical. Its equation is simply x = k, e.g. through (2, 5) and (2, 9) the equation is x = 2. A vertical line has no slope-intercept form because it never crosses the y-axis in a single point.
What happens when y1 = y2 (horizontal line)?
When both y-coordinates are equal, Δy = 0 and the slope is 0 — the line is horizontal. Its equation is y = k, e.g. through (1, 3) and (4, 3) the equation is y = 3.
Is this the same as a distance-between-two-points calculator?
No. This tool finds the equation of the line that passes through two points (its slope and forms like y = mx + b). A distance calculator measures how far apart the two points are (the length of the segment between them). If you need the distance, use the distance between two points calculator instead.
Can I enter fractions like 3/4?
Yes. Type fractions as 3/4 and the calculator keeps exact fraction arithmetic — the slope and intercept are computed as exact rationals (e.g. −3/4), not rounded decimals.
What if both points are the same?
A single point does not define a unique line — infinitely many lines pass through it. Enter two different points to get an equation.
Free tool by NRTechStudio