To find the equation of a line through two points in slope-intercept form, compute the slope m = (y₂ − y₁)/(x₂ − x₁), then substitute one point into y = mx + b and solve for b. The result is y = mx + b with both numbers filled in. This works for every pair of points except one: when x₁ = x₂, the line is vertical, the slope is undefined, and no slope-intercept equation exists — the line is just x = x₁. Everything below assumes the two points have different x-coordinates.
Name the Two Points Before Touching the Formula
Label one point (x₁, y₁) and the other (x₂, y₂) on paper before substituting anything. The labels are arbitrary — either point can be first — but once chosen, they must stay consistent through every substitution. Swapping the labels partway through is the single most common arithmetic error in this procedure. Write the ordered pairs directly under the formula so your eye can catch a mismatch.
Coordinates can be any real numbers: negatives, fractions, decimals, zero. The formula does not care about sign. What it does care about is subtraction order. The slope is a ratio of two differences, and both differences must run in the same direction — top and bottom from the same starting point.
A quick sanity check before calculating: if both points share the same y-value, the line is horizontal and the slope will come out to 0. If both share the same x-value, stop — that's the vertical case with no slope-intercept answer. Spotting either pattern early saves the full computation.
Keep the raw coordinates visible for the substitution step later. You will need one full ordered pair to solve for b, and copying it from the original problem rather than from your scratch work reduces transcription mistakes.
Compute the Slope as a Ratio of Differences
Subtract the y-values, subtract the x-values in the same order, and divide. For points (2, 3) and (5, 9): m = (9 − 3)/(5 − 2) = 6/3 = 2. The line rises 2 units for every 1 unit right. That rise-over-run reading is not decoration — it's the fastest way to verify the slope is plausible against a rough sketch.
Negative slopes follow the same arithmetic. For (1, 7) and (3, 1): m = (1 − 7)/(3 − 1) = −6/2 = −3. The line falls 3 units per unit right. If your two points clearly trend downward on a sketch and your slope comes out positive, you reversed a subtraction.
When the differences are fractions, keep them as fractions until the division is done. For (−1/2, 3/4) and (1/2, 1/4): the y-difference is 1/4 − 3/4 = −1/2, the x-difference is 1/2 − (−1/2) = 1, so m = −1/2. Converting to decimals early invites rounding drift that later produces an equation that doesn't quite pass through the second point.
| Points | y-difference | x-difference | Slope m |
|---|---|---|---|
| (2, 3), (5, 9) | 6 | 3 | 2 |
| (1, 7), (3, 1) | −6 | 2 | −3 |
| (−1/2, 3/4), (1/2, 1/4) | −1/2 | 1 | −1/2 |
| (0, −4), (6, 0) | 4 | 6 | 2/3 |
| (−3, 5), (−3, 8) | 3 | 0 | undefined |
The last row is the failure case. Division by zero is not a large slope; it is no slope at all, and the slope-intercept form cannot represent that line.
Solve for b by Substituting One Point
With m in hand, drop either original point into y = mx + b and isolate b. Using (2, 3) with m = 2: 3 = 2(2) + b, so 3 = 4 + b and b = −1. The finished equation is y = 2x − 1. Substituting the other point, (5, 9), gives 9 = 10 + b, so b = −1 again — a free correctness check built into the method.
Choose the point with the friendlier numbers. A point containing zero collapses the multiplication: for a line through (0, −4) with m = 2/3, the substitution is −4 = (2/3)(0) + b, so b = −4 immediately, and the equation is y = (2/3)x − 4. Picking the zero-coordinate point is a legitimate shortcut, not a different method.
Fractional slopes multiply cleanly if you keep b as a fraction too. For the pair (−1/2, 3/4) and (1/2, 1/4) with m = −1/2: 3/4 = (−1/2)(−1/2) + b, so 3/4 = 1/4 + b and b = 1/2. The equation is y = −(1/2)x + 1/2. Convert to a common denominator before subtracting — mixing denominators here is where most fraction errors enter.
If b comes out as an ugly decimal, keep it exact as a fraction in the final equation. A slope-intercept equation is a mathematical statement, and 7/3 is more accurate than 2.33. Round only when a word problem explicitly asks for a rounded answer.
Numbered Routine: Two Points to a Finished Equation in Six Moves
Here's the whole procedure compressed into the order you'd actually do it, with a running example of points (4, −1) and (10, 8). The final answer should be y = 1.5x − 7; check yourself against that as you follow along.
Work the steps in order. Each one feeds the next, and none can be skipped — even the label choice in step 1 matters because the subtraction order in step 3 depends on it.
1: Write both points clearly and assign one as (x₁, y₁) and the other as (x₂, y₂). 2: Check the x-coordinates: if they're equal, stop — the line is vertical and the answer is x = that value. 3: Compute m = (y₂ − y₁)/(x₂ − x₁). For the example: (8 − (−1))/(10 − 4) = 9/6 = 3/2. 4: Pick one point — either one — and substitute its x, y, and the computed m into y = mx + b. 5: Solve the resulting one-variable equation for b. Here: −1 = (3/2)(4) + b, so −1 = 6 + b and b = −7. 6: Write the final equation as y = (3/2)x − 7, then verify by substituting the other point: 8 should equal (3/2)(10) − 7 = 15 − 7 = 8. It does.
When verification fails, the fault is almost always in step 3 or step 4. Re-check the subtraction signs first — a dropped negative in the y-difference flips the slope, and that single error propagates through b and the final equation. Re-substituting the second point as a check costs about 15 seconds and catches it before the answer is submitted. If both points fail the check, the slope itself is wrong; recompute it from scratch rather than patching b.
Point-Slope Form Gets You to Slope-Intercept Without Finding b Separately
The slope-intercept form is a required output, but it isn't the only route. Point-slope form, y − y₁ = m(x − x₁), jumps straight from the two points to an equation and then converts to slope-intercept by distributing and isolating y. For (4, −1) and (10, 8) with m = 3/2: y − (−1) = (3/2)(x − 4), so y + 1 = (3/2)x − 6, and y = (3/2)x − 7. Same answer, and b appears as the final constant.
This route is cleaner when both coordinates are fractions or when the slope is large and b would be an awkward number under direct substitution. It also handles a case the substitution method obscures: when one point is the y-intercept itself, the conversion collapses instantly. A line through (0, 5) and (4, 13) has m = 2, and point-slope form gives y − 5 = 2(x − 0), which is already y = 2x + 5 — b was the y-value of the intercept all along.
Two-point form, (y − y₁)/(x − x₁) = (y₂ − y₁)/(x₂ − x₁), is the same statement rearranged and is what a graphing calculator or CAS will often display internally. Solving it algebraically for y always lands on slope-intercept, so it's a valid cross-check if your answer looks suspicious.
The cost comparison is worth knowing. Direct substitution requires one equation solve after the slope; point-slope conversion requires distribution and one addition. For clean integers, substitution is faster. For fractions, point-slope tends to produce fewer sign errors because it preserves the structure of the original points longer. Use whichever matches your comfort, then verify — the check is where the real safety lies.
Horizontal, Vertical, and Fraction Cases That Change the Answer
A horizontal line through (1, 4) and (7, 4) has slope 0, and substitution gives 4 = 0(1) + b, so b = 4 and the equation is y = 4. Some students expect y = 4 to be written with an mx term — it can be, as y = 0x + 4, but the simpler form is standard and equally correct.
A vertical line through (3, 2) and (3, 9) has an undefined slope because 9 − 2 = 7 and 3 − 3 = 0. There is no pair (m, b) that produces a vertical line, so the correct answer in slope-intercept form is "no solution" — the line is x = 3. If a textbook asks for slope-intercept form specifically, the expected response is to identify the case and state the vertical equation, not to force a quotient.
Fractional slopes produce equations where b can be a fraction even when both points are integers. Points (2, 5) and (8, 9) give m = 4/6 = 2/3, and substituting (2, 5): 5 = (2/3)(2) + b, so b = 5 − 4/3 = 11/3. The equation is y = (2/3)x + 11/3. Writing (11/3) as 3.67 rounds away exactness; keep the fraction.
Negative coordinates deserve an explicit sign check. For (−3, 5) and (−7, 11): m = (11 − 5)/(−7 − (−3)) = 6/(−4) = −3/2. Substituting (−3, 5): 5 = (−3/2)(−3) + b = 9/2 + b, so b = 1/2. The equation is y = −(3/2)x + 1/2. Note that the −3/2 slope times the −3 x-value produces a positive product — a step people often mistakenly make negative.
Decimal Answers, Word Problems, and Graphing Checks
When a context asks for a rounded slope-intercept equation, carry the exact fraction through the algebra and round only on the final line. A slope of 7/3 becomes 2.33 to two decimals, but if you round m before finding b, the constant shifts. For points (1, 2) and (4, 9): exact m = 7/3, b = 2 − 7/3 = −1/3, so y ≈ 2.33x − 0.33. Rounding m to 2.3 first would give b = 2 − 2.3 = −0.3 and a visibly worse fit at x = 4.
Word problems usually arrive disguised. Two contract pricing tiers — $400 for 10 units and $900 for 30 units — define points (10, 400) and (30, 900) and the linear model is the line through them. The slope is 500/20 = 25 dollars per unit, and substituting gives 400 = 25(10) + b, so b = 150. The cost model is C = 25u + 150, and the meaning of b — a fixed starting cost before any units — is often the actual question being graded.
Use graphing as the cheap check. A Casio fx-9750GIII, Texas Instruments TI-84 Plus CE, and Desmos all accept two points or the finished equation, and graphing the line against the two dots takes under a minute. If the plotted line misses either point, the algebra has an error. This is faster than re-deriving when you're unsure whether the mistake was in m or in b.
| Scenario | Slope m | b | Finished equation |
|---|---|---|---|
| Integer points (2, 3), (5, 9) | 2 | −1 | y = 2x − 1 |
| Fractional slope (2, 5), (8, 9) | 2/3 | 11/3 | y = (2/3)x + 11/3 |
| Negative coordinates (−3, 5), (−7, 11) | −3/2 | 1/2 | y = −(3/2)x + 1/2 |
| Horizontal (1, 4), (7, 4) | 0 | 4 | y = 4 |
| Vertical (3, 2), (3, 9) | undefined | none | x = 3 |
Reading the table row by row: the second and third rows show that integer points do not guarantee integer b, and the last two show that "no slope" and "zero slope" are opposite situations with different answers.
Sign Errors and Misapplied Formulas That Produce the Wrong b
The most frequent mistake is a double-negative in the slope subtraction. Points (5, 2) and (8, −4) give a y-difference of −4 − 2 = −6, not 2 − (−4) = 6. Both versions look defensible if you're rushing; only one produces slope −2, and substituting (5, 2) into y = −2x + b gives 2 = −10 + b, so b = 12. The equation is y = −2x + 12 and passes through both points — verify at (8, −4): −2(8) + 12 = −4. The reversed subtraction gives m = 2, b = −8, and fails the second point.
A second trap is solving for b correctly but writing the final equation with b attached to the wrong variable, producing y = (3/2) − 7x instead of y = (3/2)x − 7. The constant b is a number added to the mx term; it never multiplies x. Read the finished line out loud as "y equals m x plus b" before submitting.
The third is dividing the differences in mismatched order: (y₂ − y₁)/(x₁ − x₂), which flips the sign of m. The formula doesn't care which point is "first," but it does require both differences to use the same orientation. If the top is second-minus-first, the bottom must be second-minus-first too.
A subtler issue: using the same point twice. When you substitute to find b, plug in the full ordered pair exactly once. Students occasionally substitute x from one point and y from the other, which yields a b that fits neither. Write the point directly above the substitution line as a reminder of which pair you're using, then check against the other point as the final step.
When Slope-Intercept Loses Accuracy: Vertical Lines, Rounding, and Overflow
The slope-intercept form is not universally applicable, and knowing its limits prevents wrong answers. Vertical lines have no slope-intercept equation at all — no m value exists, and any attempt to divide by zero in the slope formula is an error, not a calculation to complete. A teacher or grader needs to see x = 3, not a division-by-zero workaround.
For very steep lines, the slope is a large number and b can be astronomically far from zero. Points (0.001, 5) and (0.002, 5005) give m = 5000 and b = 0 — a legitimate line with an enormous slope and the equation y = 5000x. Writing the equation in slope-intercept is still exact here; the risk is numerical, not mathematical, when a calculator rounds the slope and produces an equation that misses the second point by a visible margin.
Rounding in decimal form is the practical ceiling. If a problem's answer key uses two decimal places, deliver two decimal places, but know that the rounded equation no longer passes exactly through both points. The exact fraction is the truth; the decimal is a convenience. State this in written work if the problem permits.
Finally, slope-intercept doesn't directly answer every question about a line. If a problem asks for the x-intercept, solve y = 0 in the finished equation — don't re-derive from the original points. For (2, 3) and (5, 9), y = 2x − 1, so 0 = 2x − 1 gives x = 1/2, and the x-intercept is (1/2, 0). The finished equation is a tool; keep using it after you write it.
FAQ
What if both points have the same x-coordinate?
There is no slope-intercept equation for that line. When x₁ = x₂, the run is zero and the slope is undefined, so no value of m fits. The line is vertical and is written x = the shared x-value, such as x = 3 for points (3, 2) and (3, 9). Any answer offering a number for m in that case is wrong, regardless of how the algebra looks.
Does it matter which point I call (x₁, y₁)?
No, the resulting equation is identical either way — but only if you stay consistent. Calling (2, 3) the first point and calling (5, 9) the first point both produce y = 2x − 1 for the pair, because the sign flip in the y-difference cancels the sign flip in the x-difference. Where students go wrong is mixing the order: y-difference second-minus-first but x-difference first-minus-second. Pick an order and hold it through every subtraction.
How do I know if my answer is right without the answer key?
Substitute both original points into your finished equation. A correct equation makes both substitutions true. For y = (3/2)x − 7 through (4, −1) and (10, 8), plugging x = 4 gives −1 and x = 10 gives 8. If either fails, recompute the slope first, since a wrong m poisons b. This check costs roughly 15 seconds and catches nearly every error.
Can b be zero, and what does that mean?
Yes, and it means the line passes through the origin. A line through (0, 0) and (5, 10) has m = 2 and b = 0, giving y = 2x. A zero b does not mean the equation is incomplete; it means the y-intercept is exactly at (0, 0). Write the equation as y = 2x rather than leaving a blank after the plus sign.
Is slope-intercept the same as point-slope form?
No, though both describe the same line. Slope-intercept is y = mx + b and displays the slope and y-intercept directly. Point-slope is y − y₁ = m(x − x₁) and displays the slope and one point. Converting from point-slope to slope-intercept takes two algebra steps — distribute and isolate y — and produces the same final equation.
Does this work when the points are decimals instead of fractions?
Yes, with a caution about rounding. Convert decimals to fractions if the values are clean (0.5 → 1/2, 0.25 → 1/4), compute exactly, then convert the final equation to decimals only if required. For (0.5, 1) and (1.5, 4), the slope is 3/1 = 3 and b = 1 − 1.5 = −0.5, so y = 3x − 0.5, which is exact. Rounding intermediate values is what causes drift.
What's the fastest way to check with a graphing calculator?
Enter the two points as a list or plot the finished equation and the two coordinate pairs on the same screen. On a TI-84 Plus CE or Casio fx-9750GIII, graphing both the line and the points takes under a minute. If the line visibly misses either dot, recheck the slope subtraction, which is where errors concentrate. Desmos performs the same check in a browser.