Algebra I & II · 25 min

Same value, different shape

The distributive law and combining like terms are rewrites. They change what an expression looks like without touching what it computes. Substitution is the check that proves it.

0 / 0

An expression is a recipe

Module 1 left you with single-variable expressions and the tree behind them. Module 2 takes the lid off: more variables, more structure, but no new kind of object.

An expression like 3(2x+5)(x4)3(2x + 5) - (x - 4) is still just a recipe. Hand it values for its variables and it collapses to a single number. The variables are named boxes; the operators are the steps; the output is whatever falls out the bottom.

The new skill this lesson is about isn’t evaluating expressions. It’s rewriting them: turning one expression into a different-looking expression that computes the exact same thing.

Like terms: same box, same power

Two terms are like terms when their variable parts are identical: the same letters raised to the same powers. 3x3x and 5x5x are like terms. 3x3x and 3y3y are not. 3x3x and 3x23x^2 are not.

Like terms collapse together by adding only their coefficients: 3x+5x=8x3x + 5x = 8x. Unlike terms just sit side by side; there’s nothing to merge.

Why is this legal? Because 3x+5x3x + 5x means “three copies of xx plus five copies of xx,” which is eight copies of xx, for every value xx could take. You’re not solving anything. You’re noticing that two ways of writing the count are the same count.

Collect the like terms

Simplify 4a+72a+34a + 7 - 2a + 3 by combining like terms. Then evaluate your simplified expression at a=5a = 5.

What is the value?

The distributive law, both directions

Here is the one structural rule that does most of the work in algebra:

a(b+c)=ab+aca(b + c) = ab + ac

Read left to right, it’s distributing: a product wrapped around a sum becomes a sum of products. Read right to left, it’s factoring: a sum with a shared piece becomes a single product.

It’s not a coincidence or a convention. Picture a rectangle that is aa tall and (b+c)(b + c) wide. Its area is a(b+c)a(b+c). Now slice it down the middle into an a×ba \times b piece and an a×ca \times c piece. Same rectangle, same area, two names for it. That’s the whole proof.

Invariant value at x = 2 29
Expression: 3·(2x + 5) - (x - 4)

Click a node to see available rewrite rules. Dashed-ring nodes have rules ready to apply.

Click a node in the tree and pick a rewrite. Distribute a product into a sum, combine like terms, factor a common piece back out. The tree changes shape with every move. Watch the value at x = 2 readout the entire time.

The thing that never moves

You just watched an expression’s tree get rearranged repeatedly, and the value at x = 2 readout did not flinch. That is the point of the whole lesson.

A rewrite is a value-preserving transformation. It changes the syntax (what the expression looks like, how its tree is shaped) and leaves the semantics (what it computes, for every input) untouched. Distributing, factoring, collecting like terms: all of them are this.

This is exactly what a compiler does when it optimizes your code, and what a computer algebra system does when it simplifies. The expression on the screen is allowed to change. The function it denotes is not.

The minus-sign trap

One rewrite causes more wrong answers than all the others combined: distributing a negative.

The expression (x4)-(x - 4) is shorthand for 1(x4)-1 \cdot (x - 4). Distribute the 1-1 into both terms:

(x4)=x+4-(x - 4) = -x + 4

Not x4-x - 4. The 1-1 hits the xx and the 4-4, and a negative times a negative is a positive. Miss the second term and every sign downstream is wrong. When you see a minus sign in front of a parenthesis, treat it as a 1-1 that must touch everything inside.

Distribute, then collect

Simplify 3(2x5)2(x4)3(2x - 5) - 2(x - 4). Distribute both products first, mind the signs, then combine like terms. Evaluate the result at x=3x = 3.

What is the value?

Substitution is the type check

How do you know a rewrite didn’t break anything? You substitute.

Pick a value, plug it into the original expression and into your rewritten one, and confirm they land on the same number. They have to, if the rewrite was legal, because a legal rewrite preserves value at every input.

In code you’d call this a test. You changed the implementation; you ran it on a known input; you asserted the output is unchanged. Same instinct, same safety. One substitution won’t prove two expressions are equal everywhere, but it catches almost every slip, and the slips it catches are the sign errors and the dropped terms that would otherwise haunt you for three more steps.

When distribution does not apply

A warning that will save you later. The distributive law connects multiplication and addition. It does not mean exponents distribute over addition.

(a+b)2a2+b2(a + b)^2 \neq a^2 + b^2

Check it: (2+3)2=52=25(2 + 3)^2 = 5^2 = 25, but 22+32=4+9=132^2 + 3^2 = 4 + 9 = 13. Not equal. The correct expansion is (a+b)2=a2+2ab+b2(a+b)^2 = a^2 + 2ab + b^2, and the extra 2ab2ab is the two off-diagonal rectangles when you draw (a+b)(a+b) by (a+b)(a+b) as a square. The cross terms are real area; you can’t wish them away.

Square a sum

Evaluate (a+b)2(a + b)^2 at a=2a = 2 and b=3b = 3. Add first, then square the result.

What is the value?

Where this goes next

You can now take an expression and reshape it: distribute, factor, collect like terms, and prove you didn’t break it by substituting. Every later lesson leans on this. Solving an equation will mean rewriting it into a shape you can read off; deriving the quadratic formula will be one long chain of legal rewrites.

g(f(x)) is one layer of a neural network wired into the next. log(∏) = ∑(log) is why a million tiny probabilities don’t sink training. Everything in this module is those two facts at scale, and rewriting expressions without changing their value is the ground they stand on.

Lesson complete

Nice tinkering.