Pre-Algebra • Expressions, Equations & Inequalities

Writing Linear Equations (y=mx+b) — I can write a linear equation in the form y=mx+b from a graph, table, or context.

Turn graphs, tables, and real-world situations into neat equations you can use to predict anything.

Middle School Math emblem with sigma notation, geometric shapes, and a ruler.
Inside this lesson 10 sections 5 questions 9 figures

SECTION 1

Where Did y = mx + b Come From?

People have been drawing straight lines for thousands of years. But writing a linear equation (an equation whose graph is a straight line) took centuries of math discoveries. Let's look at how we got the handy formula y = mx + b.

~300 BCE • Euclid & Geometry

The Greek mathematician Euclid studied lines and shapes, but he described them with words and drawings — not equations.

~825 CE • Al-Khwarizmi & Algebra

A Persian scholar named al-Khwarizmi wrote one of the first algebra textbooks. His work gave us the word "algebra" and showed how to solve equations with unknowns.

1637 • Descartes & the Coordinate Plane

French mathematician René Descartes invented the x-y coordinate plane. Now people could plot equations as pictures — connecting algebra and geometry for the first time.

1800s • Slope-Intercept Form Becomes Standard

Mathematicians began writing y = mx + b as the go-to way to describe a line. The letters m (slope) and b (y-intercept) became standard in textbooks around the world.

Today, y = mx + b is everywhere. Scientists use it to predict weather trends. Business owners use it to forecast profits. You'll use it whenever you need to describe how two quantities are connected in a straight-line pattern. The big question this lesson answers is: How do I write that equation from a graph, a table, or a word problem?

SECTION 2

Core Ideas You Need to Know

Before we start writing equations, let's nail down four key vocabulary words. Each one is a building block for y = mx + b.

1

Linear Equation

An equation that makes a straight line when you graph it. The variables (x and y) are only raised to the first power — no exponents like x² allowed.
2

Slope (m)

The steepness and direction of the line. It tells you how much y changes every time x increases by 1. Think of it as "rise over run."
3

Y-Intercept (b)

The point where the line crosses the y-axis. At this point, x = 0. It's your starting value before any changes happen.
4

Slope-Intercept Form

The format y = mx + b. The letter m holds the slope, and the letter b holds the y-intercept. Once you know m and b, you can write the whole equation.
✦

KEY TAKEAWAY

Think of a linear equation like a recipe. The slope (m) is how much of an ingredient you add each time, and the y-intercept (b) is what you start with before adding anything. If you know those two things, you have the whole recipe — or in math, the whole equation!

SECTION 3

Seeing y = mx + b on a Graph

A graph is the easiest place to spot slope and y-intercept. The diagram below shows the line y = 2x + 1. Notice how the line crosses the y-axis at 1 (that's b). Then for every 1 unit you move right, the line goes up 2 units (that's m).

Graph of y = 2x + 1xy01234123−1y-intercept (0, 1)b = 1Run=1Rise=2Slope m = 2/1 = 2y = 2x + 1
The pink dot marks the y-intercept at (0, 1). The dashed yellow box shows one "rise over run" triangle: rise = 2, run = 1, so the slope is 2.

To write the equation from a graph, you only need two pieces of information. First, find where the line crosses the y-axis — that's your b. Second, pick two points on the line and count the rise and run between them — that gives you m. Plug both values into y = mx + b, and you're done!

SECTION 4

The Math Behind the Equation

Let's break down the formula piece by piece. Once you understand what each letter means, writing the equation becomes as simple as filling in blanks.

SLOPE-INTERCEPT FORM

y=mx+by = mx + b

y = the output (dependent variable) · m = slope (rise ÷ run) · x = the input (independent variable) · b = y-intercept (the value of y when x = 0)

SLOPE FORMULA

m=(y2−y1)÷(x2−x1)m = (y₂ − y₁) ÷ (x₂ − x₁)

Pick any two points on the line: (x₁, y₁) and (x₂, y₂). Subtract the y-values (that's the rise), then subtract the x-values (that's the run). Divide rise by run to get the slope.

💡

Positive vs. Negative Slope

If the line goes uphill from left to right, the slope is positive. If it goes downhill, the slope is negative. A flat (horizontal) line has a slope of 0.

FINDING b FROM A POINT

b=y−mxb = y − mx

If you already know the slope (m) and one point (x, y) on the line, plug them in to solve for b.

SECTION 5

Writing Equations from Three Sources

You might be asked to write a linear equation from a graph, a table, or a real-world context. The steps are slightly different for each. The diagram below shows all three side by side.

Three Ways to Write y = mx + bFROM A GRAPHStep 1: Read they-intercept (b)from where the linecrosses the y-axis.Step 2: Pick two points.Count rise and runto find theslope (m)Step 3: Plug m and binto y = mx + b.Example:b = 3, m = −2y = −2x + 3FROM A TABLEStep 1: Find theslope (m)using any two rows:m = Δy ÷ ΔxStep 2: Look forx = 0 in the table.That y-value isbStep 3: If x = 0 isn'tin the table, useb = y − mxExample:m = 4, b = −1y = 4x − 1FROM CONTEXTStep 1: Find thestarting value (b)Look for words like"initial," "already," or"starts with."Step 2: Find therate of change (m)Look for "per," "each,"or "every."Step 3: Writey = mx + b.Example:$5/week, start $20y = 5x + 20
All three methods lead to the same formula: y = mx + b. The difference is where you find m and b.
SourceHow to find m (slope)How to find b (y-intercept)
GraphCount rise ÷ run between two points on the lineRead the y-value where the line crosses the y-axis
TablePick two rows: (y₂ − y₁) ÷ (x₂ − x₁)Find the y-value when x = 0, or use b = y − mx
ContextLook for "per," "each," or "every" — that's the rateLook for "starts with," "initial," or "already has"

Quick-reference: finding m and b from different sources

SECTION 6

Worked Examples

Example 1: From a Table

xy
05
18
211
314

Data table for Example 1

Write the equation in y = mx + b form

  1. 1

    Step 1 — Find b (the y-intercept)

    Look for the row where x = 0. When x = 0, y = 5. So b = 5.
    b = 5
  2. 2

    Step 2 — Find m (the slope)

    Pick two rows. Let's use (0, 5) and (1, 8). The rise is 8 − 5 = 3. The run is 1 − 0 = 1. So m = 3 ÷ 1 = 3. You can check: every time x goes up by 1, y goes up by 3. ✓
    m = 3
  3. 3

    Step 3 — Write the equation

    Plug m = 3 and b = 5 into y = mx + b.
    y = 3x + 5

Example 2: From a Word Problem

A pizza shop charges $12 for a plain pizza plus $2 for each topping. Write an equation for the total cost (y) based on the number of toppings (x).

Write the equation in y = mx + b form

  1. 1

    Step 1 — Identify the starting value (b)

    The plain pizza costs $12. That's the cost before any toppings, so b = 12.
    b = 12
  2. 2

    Step 2 — Identify the rate of change (m)

    Each topping adds $2. The word "each" tells you this is the rate. So m = 2.
    m = 2
  3. 3

    Step 3 — Write the equation

    Plug m = 2 and b = 12 into y = mx + b.
    y = 2x + 12
  4. 4

    Step 4 — Check with a value

    If you order 3 toppings: y = 2(3) + 12 = 6 + 12 = 18. A pizza with 3 toppings costs $18. That makes sense!
    Check: $18 ✓

SECTION 7

Common Mistakes & How to Avoid Them

Even great math students slip up when writing linear equations. Here are the most common mistakes and how to dodge them.

MistakeWhy It HappensHow to Fix It
Swapping m and bStudents put the y-intercept where the slope should go, or vice versa.Remember: m is always multiplied by x. b stands alone.
Forgetting the negative sign on slopeA line going downhill has a negative slope, but students write it as positive.If the line goes down from left to right, the slope MUST be negative.
Flipping rise and runComputing run ÷ rise instead of rise ÷ run.Rise is the vertical (up/down) change. Run is the horizontal (left/right) change. Rise comes first.
Using the wrong point for bPicking any point on the line instead of the one where x = 0.The y-intercept is ONLY where the line crosses the y-axis (x = 0).

Common mistakes when writing y = mx + b

🧠

QUICK MEMORY TRICK

Think of m for "move" — how fast the line moves up or down. Think of b for "beginning" — where the line begins on the y-axis.

SECTION 8

Connection to Future Math

Learning y = mx + b is your first step into a huge area of math. In later courses, you'll see more powerful versions of this idea. Here's a sneak peek.

What You Know NowWhat's Coming Next
y = mx + b (slope-intercept form)Standard form (Ax + By = C) and point-slope form y − y₁ = m(x − x₁)
One equation, one lineSystems of equations — two lines at once, finding where they cross
Straight lines onlyQuadratic equations (y = ax² + bx + c) make curves called parabolas
Finding slope from two pointsIn calculus, slope becomes "derivatives" — instant rates of change

How y = mx + b connects to future topics

The great news? Every one of those future topics builds on the same two ideas you've learned here: slope and y-intercept. Master them now, and you'll have a huge head start.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

In the equation y = mx + b, what does b represent? Where would you find it on a graph?
Show answer
The letter b represents the y-intercept. It is the value of y when x equals 0. On a graph, you find b at the exact point where the line crosses the vertical (y) axis. For example, if b = 4, the line passes through the point (0, 4). This is the "starting value" before any change from the slope kicks in.

Question 2: BASIC CALCULATION

A line passes through the points (0, −3) and (2, 1). Write the equation in y = mx + b form.
Show answer
First, find b. Since one of the points is (0, −3), the y-intercept is b = −3. Next, find the slope: m = (1 − (−3)) ÷ (2 − 0) = 4 ÷ 2 = 2. Now plug into y = mx + b. The equation is y = 2x − 3. You can verify by substituting x = 2: y = 2(2) − 3 = 4 − 3 = 1. That matches the point (2, 1). ✓

Question 3: INTERMEDIATE

Use the table below to write a linear equation in y = mx + b form. x: 2, 4, 6, 8 y: 9, 15, 21, 27
Show answer
Step 1 — Find the slope using two rows. Use (2, 9) and (4, 15): m = (15 − 9) ÷ (4 − 2) = 6 ÷ 2 = 3. Step 2 — The table doesn't include x = 0, so use b = y − mx with the point (2, 9): b = 9 − 3(2) = 9 − 6 = 3. Step 3 — The equation is y = 3x + 3. Check with (6, 21): y = 3(6) + 3 = 18 + 3 = 21. ✓ The slope of 3 means y increases by 3 for every 1-unit increase in x.

Question 4: APPLIED

Mia has $50 in her savings account. She adds $15 every week. Write a linear equation for the total amount of money (y) after x weeks. How much will she have after 10 weeks?
Show answer
The starting value is $50, so b = 50. She saves $15 per week, so the rate of change is m = 15. The equation is y = 15x + 50. After 10 weeks: y = 15(10) + 50 = 150 + 50 = $200. The slope 15 tells us Mia adds $15 each week, and the y-intercept 50 tells us her starting balance. This kind of equation is useful anytime you have a steady rate of change plus a starting amount.

Question 5: CRITICAL THINKING

Two friends are reading the same 300-page book. Alex has already read 80 pages and reads 20 pages per day. Bella has already read 30 pages and reads 30 pages per day. Write an equation for each person. On which day will they be on the same page?
Show answer
Alex: starts at 80 pages (b = 80) and reads 20 per day (m = 20), so y = 20x + 80. Bella: starts at 30 pages (b = 30) and reads 30 per day (m = 30), so y = 30x + 30. To find when they're on the same page, set the equations equal: 20x + 80 = 30x + 30. Subtract 20x from both sides: 80 = 10x + 30. Subtract 30: 50 = 10x. Divide by 10: x = 5. On day 5 both will have read 180 pages (check: Alex: 20 × 5 + 80 = 180; Bella: 30 × 5 + 30 = 180). This is a preview of solving systems of equations, which you'll study in Algebra 1!

SUMMARY

Lesson Summary

Summary

A linear equation in slope-intercept form is written as y = mx + b, where m is the slope (rise over run — how steep the line is) and b is the y-intercept (where the line crosses the y-axis, or the starting value). You can find m and b from a graph by reading the y-intercept and counting rise ÷ run, from a table by calculating the change in y over the change in x, or from a real-world context by identifying the rate and starting amount.

Remember: m stands for "move" (how fast the line moves) and b stands for "beginning" (where the line begins on the y-axis). Always check your equation by plugging in a known point. Mastering y = mx + b prepares you for systems of equations, standard form, and eventually quadratic equations in Algebra and beyond.

Varsity Tutors • Pre-Algebra • Writing Linear Equations (y=mx+b)