You find the equation of a line through two points by first computing the slope from the vertical change divided by the horizontal change, then substituting one point into the point-slope form y − y₁ = m(x − x₁). The exception matters: if the two x-values are identical, the slope is undefined and the line is vertical, written as x = a constant. Everything below works that rule in order, with the failure cases spelled out.

Label the Two Points Before Touching a Formula

The single most common error in this calculation happens before any arithmetic: mixing which number is x and which is y. Write your two points as an ordered pair (x₁, y₁) and (x₂, y₂) on paper first, with the subscripts visible. For example, if the problem gives (3, 7) and (8, 2), then x₁ = 3, y₁ = 7, x₂ = 8, y₂ = 2. Say it out loud if you have to.

A small discipline pays off here. Keep x₁ paired with y₁ in every substitution. The slope formula, the point-slope form, and any check you run later all use the same pairing, so fixing it once prevents a wrong answer that looks half right. If a problem hands you the points in the order (8, 2) and (3, 7) instead, that changes your labels, not your result. The line is the same line.

Watch for points written with missing parentheses or embedded in a word problem. A question about "the cost at 4 hours and 9 hours" gives you the x-values in prose, and you supply the y-values from context. Writing them as (4, cost at 4) first, then filling the numbers, keeps the pairing honest.

Here is the labeling step written as a checklist you can run against any problem:

1: Write both points as ordered pairs, with the smaller x-value labeled x₁ if you want, though either order is legal. 2: Confirm each y sits directly under its matching x. 3: Note the units, if any, attached to each coordinate. They matter for the slope, not the final equation's numbers. 4: Flag immediately whether the x-values are equal. That single check determines which of two entirely different procedures you run.

If any step feels shaky, stop and re-write the pairs. The rest of the method is mechanical once the labels are right.

The Slope Ratio That Decides Everything

Slope is vertical change divided by horizontal change: m = (y₂ − y₁) ÷ (x₂ − x₁). With (3, 7) and (8, 2), that is (2 − 7) ÷ (8 − 3) = −5 ÷ 5 = −1. A slope of −1 means the line falls one unit for every unit it moves right. If you reversed the subtraction order in both places — (7 − 2) ÷ (3 − 8) — you'd get 5 ÷ −5, which is also −1. Consistent order in numerator and denominator always gives the same slope, which is a useful self-check.

The sign of the slope carries the line's direction. Positive slope rises left to right; negative slope falls; zero slope means both points share a y-value and the line is horizontal, written y = that shared value. Memorizing four slope types is less useful than seeing them as one ratio shrinking, flipping, and finally breaking.

That break is the case to internalize now. Divide by zero and the expression is undefined — there is no number that answers it. A vertical line through (4, 1) and (4, 9) has a horizontal change of 0 and a vertical change of 8, and 8 ÷ 0 is not a number. The standard curriculum response, as taught in Algebra 1 courses and assumed by standardized tests like the SAT math section, is to declare the slope undefined and the line vertical. Some software will return "infinity" for the same input; treat that as a machine's way of saying the same thing, not as a usable slope value.

Slope as a concept dates to the early 17th century, when René Descartes' coordinate geometry tied algebraic equations to geometric figures. The formula you use in class is a direct descendant of that idea: a line is fully determined by its steepness and a single anchor point. Two points give you both.

Run the arithmetic twice. Once by hand, once mentally estimating whether the answer is plausible from the picture. A line through (3, 7) and (8, 2) should visibly fall as you read left to right; a positive answer would signal a sign error somewhere.

Build the Equation with Point-Slope First

Point-slope form is the workhorse: y − y₁ = m(x − x₁). Using m = −1 from above and the point (3, 7), you get y − 7 = −1(x − 3). That is a complete, correct equation of the line already. Many teachers accept it, and some textbooks call it the finished answer. If your assignment asks for slope-intercept form, keep going: distribute the −1 to get y − 7 = −x + 3, then add 7 to both sides for y = −x + 10.

Check the second point against your result. Substitute x = 8 into y = −x + 10 and you get y = 2, which matches (8, 2). That substitution is the cheapest verification available, and doing it every time eliminates most careless errors before they reach the page. If the check fails, the mistake is almost always a sign — a dropped negative during distribution.

Either point works in the point-slope formula. Starting from (8, 2) instead gives y − 2 = −1(x − 8), which simplifies to the same y = −x + 10. When two different starting points produce one final equation, you've confirmed both the slope and the algebra. This is a stronger check than substituting a single point, because it exercises the whole chain.

Knowing when to stop depends on the ask. Point-slope form is honest about where the equation came from, which is why calculus and later coursework favor it. Slope-intercept form, y = mx + b, is easier to graph and to compare across multiple lines, because b tells you the y-intercept directly. If the question says "write in slope-intercept form," simplify fully. If it just says "find the equation," point-slope is defensible, but slope-intercept is the safer default for beginners.

Watch for fractional slopes here. If the slope is 2/3, write y − 4 = (2/3)(x − 1) and distribute as (2/3)x − 2/3, then adjust the constant. Fractions are where sign errors cluster. Keep the fraction intact until the last line rather than converting to a decimal, which loses exactness and invites rounding mistakes.

Cross-Check with the Two-Point Formula

There's a combined version that skips the slope step entirely: y − y₁ = [(y₂ − y₁) ÷ (x₂ − x₁)] · (x − x₁). It's the point-slope form with the slope formula embedded. Some textbooks present it as the formula for a line through two points, and it's worth knowing because a single substitution produces the answer without an intermediate value to carry forward.

The trade-off is transparency. When something goes wrong in the combined version, you can't tell whether the error is in the slope or the substitution. Splitting into two steps — slope first, then point-slope — makes failures diagnosable. For exams and homework, I'd split. For a quick mental calculation when you're confident, the combined form is faster. That's a judgment call, not a rule, but it's the one I'd make.

Here is a side-by-side of the two routes using the same points, (3, 7) and (8, 2):

Step Split method Combined method
Compute slope m = (2 − 7) ÷ (8 − 3) = −1 Embedded in the formula
Substitute y − 7 = −1(x − 3) y − 7 = [(2 − 7) ÷ (8 − 3)](x − 3)
Simplify y = −x + 10 y = −1(x − 3) + 7 → y = −x + 10
Verify with other point Substitute x = 8, get y = 2 Same substitution, same result
Diagnosability if wrong Error locatable (slope vs. substitution) Error ambiguous

Both arrive at y = −x + 10, so the choice is about workflow, not correctness. Pick one and stick with it during a test to avoid confusion under time pressure.

One caveat for the combined form: it inherits the vertical-line failure without warning. If x₁ = x₂, the denominator is zero and the formula silently breaks. The split method forces you to confront the zero earlier, when you compute the slope, so you catch it before substituting.

When the Line Is Vertical — the Division-by-Zero Case

Vertical lines are the case most tutorials skip or bury, and they're the one that produces wrong answers on tests. If both points share an x-value — say (4, 1) and (4, 9) — the horizontal change is zero. The slope is undefined. The line has no y = mx + b form, because a vertical line isn't a function: it fails the vertical line test by crossing the same x at infinitely many y-values.

The correct answer is written x = 4. That's it. No slope, no intercept in the usual sense. Every point on the line has x-coordinate 4, which is precisely what "x = 4" says. A student who mechanically runs the slope formula gets a division by zero and may write "slope = 0," conflating vertical with horizontal. They are opposites: horizontal lines have slope 0 and equation y = constant; vertical lines have undefined slope and equation x = constant.

Here's a compact comparison of the four cases you'll encounter, with a worked equation for each:

Case Example points Slope Equation form Worked equation
Positive slope (1, 2), (3, 6) 2 y = mx + b y = 2x
Negative slope (3, 7), (8, 2) −1 y = mx + b y = −x + 10
Horizontal (2, 5), (7, 5) 0 y = constant y = 5
Vertical (4, 1), (4, 9) Undefined x = constant x = 4

Notice that the horizontal case still fits y = mx + b with m = 0: y = 0·x + 5 collapses to y = 5. The vertical case does not fit that form at all. That asymmetry is why the two are taught as separate special cases rather than variations of the same formula.

Software behavior varies. Spreadsheet trendlines and graphing calculators typically refuse or flag a vertical set of points because they're built to fit y = f(x). Graphing software like Desmos will plot a vertical line if you enter x = 4 directly, but it won't derive it from two points through its linear-regression tool. If a homework platform marks x = 4 wrong, the platform likely expects it in a different notation or is enforcing a function-only answer format — worth checking the assignment's stated form before assuming the math is wrong.

Check the Answer Against the Graph

Graphing is the fastest sanity check you have, and it catches errors that algebra alone won't. Plot both points on a coordinate plane, draw the line, and read off where it crosses the y-axis. For (3, 7) and (8, 2), the line should cross the y-axis at 10. If your algebra gave you b = 4 instead, the picture and the equation disagree, and the picture is right.

The graph also tells you the sign and rough size of the slope before you compute it. A line dropping from upper left to lower right means a negative slope. A steep line means a large absolute value of m. Estimating "this looks like about −1" before computing gives you a target to hit or miss. Teachers who require graphs alongside the equation are enforcing exactly this habit.

For the vertical case, the graph makes the situation obvious: two points stacked directly above one another demand a vertical line, and no amount of slope formula will produce a number. Sketching first turns the division-by-zero from a mystery into a visible fact.

Technology can plot it for you, but use it to confirm, not to substitute. Google Sheets, Desmos, and most graphing calculators will plot two points and a candidate equation, letting you see whether the line passes through both. Feed in your answer and look. If the line misses a point, the answer is wrong regardless of how clean the algebra looked.

Reading Slopes and Intercepts in Word Problems

Word problems disguise the same calculation behind context. A common shape: a service charges a base fee plus a per-unit rate, and you're given the total cost at two different quantities. "A repair shop charged $180 for 2 hours and $300 for 5 hours" gives you the points (2, 180) and (5, 300). The slope is (300 − 180) ÷ (5 − 2) = 120 ÷ 3 = 40, so the per-hour rate is $40. The y-intercept follows: y = 40x + b, and 180 = 40(2) + b gives b = 100, the base fee. The equation y = 40x + 100 reads directly as "cost = $40 per hour plus a $100 base."

The skill here is translating units into coordinates. The two quantities in the problem — hours and dollars — become x and y respectively, in the order the problem presents them. Swap them and the slope becomes 1/40, which is a real number but answers a different question ("hours per dollar"). Ask what the slope should mean before computing it; if the units don't match the intent, you've assigned x and y backwards.

Intercepts carry meaning too. The y-intercept is the value when x = 0, which is usually a starting amount or fixed fee. The x-intercept is where y = 0, often a break-even or threshold point. Not every word problem asks for both, but identifying what each would mean in context is a good habit and often what a follow-up question tests.

Keep the numbers in context when you present the answer. Instead of "y = 40x + 100," write "the cost is $40 per hour plus a $100 base fee," and show the equation alongside. That's the format graders reward and the format that's actually useful if you later need to predict a value. Plug in a new x and the equation does the work.

Error Check: The Mistakes That Cost Points

Four mistakes account for most lost points on this topic, and each has a cheap fix. Run through them before submitting anything.

Sign errors during distribution. Subtracting a negative, as in y − (−3) = m(x − 1), becomes y + 3. If you drop that, the whole equation shifts. Fix: rewrite subtraction of a negative as addition before distributing.

Flipping the slope. Computing (x₂ − x₁) ÷ (y₂ − y₁) instead of the reverse. Fix: say "rise over run" as you write it, and sanity-check against the graph.

Using the wrong point. Substituting (8, 2) into an equation built for (3, 7) when you meant (8, 2). Fix: the verification substitution on the second point catches this, so always do it.

Assuming every line has a slope. The vertical case produces division by zero. Fix: check for equal x-values before computing anything.

A fifth, subtler error: rounding a fractional slope mid-calculation and carrying the decimal forward. If m = 2/3, a decimal 0.667 gives a slightly wrong intercept. Fix: keep fractions exact until the final answer, and only then convert if the format requires it.

For any of these, the check is the same: substitute both original points into your final equation. If both hold, the equation is correct regardless of how you got there. If either fails, the error is in the algebra, and the two-point verification tells you which side.

Common-Form and Standard-Form Requests

Some assignments ask for "standard form," which means Ax + By = C with integer coefficients and A positive. From y = −x + 10, move x over: x + y = 10, which is already standard form with A = 1, B = 1, C = 10. From y = 40x + 100, reorganize as 40x − y = −100, then multiply by −1 if you want the leading coefficient positive: −40x + y = 100. Conventions differ by textbook — some require A > 0, some don't — so check the course's stated rule before finalizing.

Fractional slopes complicate standard form. A line with slope 2/3 through (1, 4) gives y − 4 = (2/3)(x − 1), which expands to 3y − 12 = 2x − 2, or 2x − 3y = −10 after rearranging. The multiplication by 3 clears the fraction, which is the point of standard form: integers only.

Different forms are equivalent answers to the same question, so conversion errors are recoverable. If you produce slope-intercept and the assignment wants standard, the conversion is arithmetic, not a re-solve. Check by substituting both points into whichever form you submit; equivalence holds across forms.

One practical note: online homework systems sometimes accept only one form and mark others wrong even when mathematically correct. Read the prompt's format requirement before submitting, and if the platform is ambiguous, submit slope-intercept first — it's the most widely accepted default.

FAQ

What if the two points are given in a different order?

Order doesn't change the line. Using (8, 2) as the first point and (3, 7) as the second gives slope (7 − 2) ÷ (3 − 8) = 5 ÷ −5 = −1, the same value. Swapping both numerator and denominator preserves the sign, so the final equation is identical.

Can I write the answer in point-slope form instead of slope-intercept?

Yes, unless the assignment specifies slope-intercept. Point-slope, such as y − 7 = −1(x − 3), is a complete equation of the line and is often preferred in calculus. If a grader marks it wrong, check the prompt's stated form requirement first.

Why does my calculator show "infinity" for the slope?

That's a machine's way of reporting division by zero, not a usable slope. It means your two points share an x-value and the line is vertical. Write the equation as x = a constant and disregard the infinity.

How do I check my answer quickly?

Substitute both original points into your final equation. If both pairs satisfy it, the equation is correct. For y = −x + 10, both (3, 7) and (8, 2) work, confirming the result in under a minute.

What's the difference between a horizontal and a vertical line?

Horizontal lines have slope 0 and equation y = constant; vertical lines have an undefined slope and equation x = constant. They're mirror cases with opposite behavior, and confusing the two is a common error on exams.

Does slope-intercept form work for every line?

No. Vertical lines cannot be written as y = mx + b because they aren't functions. Every non-vertical line, including horizontal ones, does fit slope-intercept form, with m = 0 for horizontal.

What does the y-intercept mean in a word problem?

The y-intercept is the value of y when x = 0, usually a starting amount or fixed fee. In a cost problem, it's the base charge before any units are added, and it corresponds to the constant b in y = mx + b.

Can a line through two points have a negative y-intercept?

Yes, and it's common. A line through (1, 5) and (3, 1) has slope −2 and y-intercept 7; a line through (3, 4) and (5, 0) has slope −2 and y-intercept 10. A negative intercept arises when the line would cross the y-axis at a negative value, often when the slope is positive and both points have positive x and negative y, or in real contexts like debt starting amounts.