How to Write an Equation for Each Line: Slope & Points Guide

The fastest way to write an equation for each line is to match what you’re given to the right formula. Know the slope and y-intercept? Use slope-intercept form: y = mx + b. Know the slope and any single point? Use point-slope form: y − y₁ = m(x − x₁). Only have two points? Find the slope first, then plug one point into point-slope form. Everything else is simplifying.
The Two Forms That Do the Work
Slope-intercept form is written as y = mx + b, where m is the slope and b is the y-intercept — the point where the line crosses the y-axis. This is the form most people are asked to finish with, because it’s easy to graph and easy to read. Khan Academy introduces this form early in its algebra courses because nearly everything else builds on it.
Point-slope form is written as y − y₁ = m(x − x₁), where m is the slope and (x₁, y₁) is any known point on the line. Its main advantage is speed: when a problem hands you a point, you can write the equation almost immediately without solving for b first.
The Slope Formula
Slope measures how steep a line is, often described as “rise over run.” Given two points (x₁, y₁) and (x₂, y₂):
m = (y₂ − y₁) / (x₂ − x₁)
A few facts worth locking in: a horizontal line has a slope of 0, a vertical line has an undefined slope, and parallel lines share the same slope. As Math is Fun notes, the slope of a line is constant everywhere along it, which is why any two points give the same answer.
Case 1: Given the Slope and Y-Intercept
Put the numbers directly into y = mx + b. If the slope is 3 and the y-intercept is −2, the equation is y = 3x − 2.
Watch the signs. A negative y-intercept puts a minus sign in front of that number: y = 3x − 2, not y = 3x + (−2) left unresolved. Also note the special cases — y = 5 means slope 0, and x = 4 can’t be written in slope-intercept form at all because its slope is undefined.
Case 2: Given the Slope and a Single Point
Use point-slope form, then simplify into slope-intercept form if the problem asks for it or if you want a tidier answer.
Worked example: Write the equation of the line with slope −2 that passes through (4, 1).
Step 1 — Plug into y − y₁ = m(x − x₁): y − 1 = −2(x − 4)
Step 2 — Distribute the slope: y − 1 = −2x + 8
Step 3 — Add 1 to both sides: y = −2x + 9
The line crosses the y-axis at 9. Check the work by substituting the original point: −2(4) + 9 = 1. ✓ Purplemath emphasizes checking the answer this way, since a sign slip in the distribution step is the most common error here.
Case 3: Given Two Points
With two points and no slope, you’re solving two small problems in sequence: find the slope, then use one point.
Worked example: Find the equation of the line through (2, 3) and (6, 11).
Step 1 — Find the slope: m = (11 − 3) / (6 − 2) = 8 / 4 = 2
Step 2 — Choose either point. Using (2, 3) in point-slope form: y − 3 = 2(x − 2)
Step 3 — Simplify: y − 3 = 2x − 4 y = 2x − 1
Either point gives the same final line. If your two attempts disagree, you’ve made an arithmetic error somewhere.
A Quick Reference Table
| What you’re given | Which form to start with | What to do |
|---|---|---|
| Slope and y-intercept | y = mx + b | Substitute directly |
| Slope and one point | y − y₁ = m(x − x₁) | Plug in, then simplify |
| Two points | Slope formula first | Find m, then use point-slope |
| A graph | Count rise over run | Read the y-intercept, then substitute |
Special Cases and Common Mistakes
A horizontal line like y = 4 has slope 0 — the “m” term effectively disappears. A vertical line like x = −3 has an undefined slope, so it can’t be written as y = mx + b.
Other mistakes worth guarding against:
- Subtracting coordinates in different orders in the numerator and denominator. Keep the pairing consistent: (y₂ − y₁) over (x₂ − x₁).
- Dropping a negative sign when distributing. −3(x − 5) becomes −3x + 15, not −3x − 15.
- Forgetting to simplify. The form y − 3 = 2(x − 2) is correct, but most teachers want y = 2x − 1.
- Assuming the y-intercept is always visible. In two-point problems it usually isn’t until you’ve done the algebra.
Once the three cases feel routine, you can reverse the process just as easily — reading a slope and intercept off a finished equation, or converting standard form into slope-intercept form by isolating y.
Reading an Equation Backward
Working in reverse is just as valuable. Given any linear equation, you can extract the slope and y-intercept without graphing.
For slope-intercept form, read them directly. In y = −5x + 7, the slope is −5 and the y-intercept is (0, 7).
For standard form (Ax + By = C), isolate y. Starting with 4x + 2y = 10:
2y = −4x + 10 y = −2x + 5
The slope is −2 and the y-intercept is (0, 5). This conversion is the most useful algebraic move when comparing lines — checking whether two are parallel (equal slopes) or perpendicular (slopes that multiply to −1). A line with slope 3 has a perpendicular partner with slope −1/3, because 3 × (−1/3) = −1.
Parallel and Perpendicular Lines Through a Given Point
These problems combine everything above. You’re given a reference line and a point, and asked for a new line.
Worked example: Write the equation of the line perpendicular to y = 4x − 1 that passes through (8, 2).
Step 1 — Identify the perpendicular slope. The reference slope is 4, so the new slope is −1/4.
Step 2 — Use point-slope form: y − 2 = −1/4(x − 8)
Step 3 — Simplify: y − 2 = −1/4x + 2 y = −1/4x + 4
For a parallel version, keep the slope at 4 and follow the identical steps. The only change between the two problems is one number: the slope you substitute.
Choosing the Best Form
There’s no single “correct” form — each shines in a particular context.
| Form | Name | Best used when |
|---|---|---|
| y = mx + b | Slope-intercept | Graphing quickly or reading slope and intercept |
| y − y₁ = m(x − x₁) | Point-slope | You have a point and a slope |
| Ax + By = C | Standard | Solving systems or matching textbook conventions |
If a problem doesn’t specify a form, slope-intercept is the safest default because it displays the most information at a glance. But if the instructions say “standard form,” ignoring that loses points even when your math is correct.
What Slope and Intercept Mean in Context
In a cost model like C = 25h + 40, the slope 25 represents the hourly rate and the intercept 40 represents a fixed startup fee. In a distance model like d = 60t, the slope 60 is a speed in miles per hour and the intercept is 0, meaning the trip starts at the origin.
Reading a slope as a rate of change and an intercept as a starting value turns any linear equation into a sentence about the situation it models. That skill — interpreting rather than just manipulating — is where linear equations pay off outside the classroom.
Key Takeaways
- The direct answer: use y = mx + b when you know slope and y-intercept; use y − y₁ = m(x − x₁) when you know slope and a point; find slope first when you only have two points.
- Slope is calculated as (y₂ − y₁) / (x₂ − x₁) — the same result no matter which point you call “first,” as long as you stay consistent.
- Two points always determine exactly one line, so both points should satisfy your final equation.
- Horizontal lines have slope 0; vertical lines have undefined slope and can’t be written as y = mx + b.
- Always simplify to slope-intercept form unless the problem explicitly asks for another form.
- Check your work by substituting a known point back into the finished equation.