Day 5 — Variables, Linear Equations & Inequalities

Updated

July 30, 2025

Day 5 — Variables, Linear Equations & Inequalities

Day 11 — Variables & expressions

Stage II · concept day
Goal: Distinguish atoms from expressions; evaluate by substitution; combine like terms; apply distributive law; preview algebraic identities; connect free vs bound variables to programming scope.

Why this matters

Programming and mathematics both name unknown or varying quantities. Algebraic expressions are structured recipes; evaluating them is substitution into a tree of operations. If you cannot parse \(3(x-2)^2-4x\), later factoring and functions feel like symbol soup. Compilers see expressions as ASTs—same mental model as Day 1.

Theory

Variables, constants, atoms

A variable is a symbol standing for an element of a stated set (often \(\mathbb{R}\), \(\mathbb{Q}\), or \(\mathbb{Z}\)).
A constant is a fixed value (literals and fixed parameters).
An atom (atomic expression) is a variable or a constant numeral—leaves of the expression tree.

Expressions vs equations vs identities

  • Expression: a syntactic form denoting a value once variables are fixed — e.g. \(3x+1\), \(\dfrac{x}{x+1}\).
  • Equation: a claim that two expressions are equal — e.g. \(3x+1=7\). May be true for some, all, or no substitutions.
  • Identity: an equation true for all allowed values — e.g. \((x+1)^2=x^2+2x+1\).
  • Contradiction (as equation): never true — e.g. \(x=x+1\) over \(\mathbb{R}\).

Today’s focus is expressions and their evaluation/simplification.

Free vs bound (analogy)

In \(2n+1\), the variable \(n\) is free—its value is not fixed by the expression alone.
In “for all integers \(n\), \(n+(n+1)\) is odd,” the \(n\) is bound by the quantifier (Stage III).
In code, a function parameter is bound in the function body; a free name must come from outer scope. Same discipline: know what is fixed vs open.

Anatomy of polynomial expressions (preview)

A monomial in \(x\): \(c x^k\) with coefficient \(c\) and degree \(k\) (nonnegative integer for polynomials).
Like terms share the same variable powers: \(3x^2\) and \(-5x^2\) are like; \(3x^2\) and \(3x\) are not.
Combining like terms: \(3x^2-5x^2=(3-5)x^2=-2x^2\) (distributivity / field axioms).

Polynomial (univariate): finite sum of monomials \(a_n x^n+\cdots+a_1 x+a_0\).

Distributive law

For all numbers \(a,b,c\) in a ring/field such as \(\mathbb{R}\):

\[a(b+c)=ab+ac,\qquad (b+c)a=ba+ca.\]

Also: \(-(b+c)=-b-c\) because \(-1\) distributes.
FOIL is distributivity twice: \((a+b)(c+d)=ac+ad+bc+bd\).

Evaluating expressions

Substitution: replace each free variable by a value (with parentheses when needed), then apply order of operations.

Domain issues: \(\frac{1}{x-1}\) undefined at \(x=1\). Track excluded values even before formal function domains (Day 18).

Algebraic identities (preview)

These will be proved by expansion (and used constantly):

\[ \begin{align*} (a+b)^2 &= a^2+2ab+b^2,\\ (a-b)^2 &= a^2-2ab+b^2,\\ (a+b)(a-b) &= a^2-b^2,\\ (a+b)^3 &= a^3+3a^2b+3ab^2+b^3. \end{align*} \]

Difference of squares \((a+b)(a-b)=a^2-b^2\) is the most used factoring preview.

Nested structure and expression trees

\(3x+(2(x-1))^2\) has main operation \(+\) at the root.
Evaluation order = post-order on the tree = standard precedence on the string.

Equality of expressions

Two expressions \(E\) and \(F\) are identically equal (on a domain \(D\)) if \(E(x)=F(x)\) for all \(x\in D\).
Expanding and combining like terms is a standard way to prove identity on \(\mathbb{R}\).

Worked examples

Example 1 — Like terms

Simplify \(5x-3+2x+7-x\).
\((5x+2x-x)+(-3+7)=6x+4\).

Example 2 — Distribute

Expand \(3(2x-5)-(x+1)=6x-15-x-1=5x-16\).

Example 3 — FOIL

\((2x+3)(x-4)=2x\cdot x+2x(-4)+3x+3(-4)=2x^2-8x+3x-12=2x^2-5x-12\).

Example 4 — Evaluate

\(E(x)=3(x-2)^2-4x\) at \(x=5\): \(3(3)^2-20=27-20=7\).
At \(x=-1\): \(3(-3)^2-4(-1)=27+4=31\).

Example 5 — Identity check

Expand \((x+1)^2=x^2+2x+1\). At \(x=10\) both sides \(121\).

Example 6 — Difference of squares

\((x+5)(x-5)=x^2-25\). Evaluate both at \(x=5\): \(0=0\).

Example 7 — Excluded value

\(E(x)=\dfrac{x^2-1}{x-1}\) for \(x\neq 1\). At \(x=3\): \(\frac{8}{2}=4\).
Algebraically \(E(x)=x+1\) for \(x\neq 1\) (Day 17 cancels carefully).

Example 8 — Nested

Simplify \(2\bigl(3-(4-x)\bigr)=2(3-4+x)=2(x-1)=2x-2\).

Example 9 — Multi-variable

\(3ab+2a- ab+5a= (3ab-ab)+(2a+5a)=2ab+7a\).

Example 10 — Cube preview

\((x+1)^3=x^3+3x^2+3x+1\) by \((x+1)(x^2+2x+1)\).

Example 11 — Free vs bound

In \(\sum_{i=1}^{n} i\), the \(i\) is bound; \(n\) is free (parameter). Changing dummy \(i\to k\) does not change the sum.

Example 12 — Common factor

\(6x+9=3(2x+3)\); \(x^2+x=x(x+1)\).

Example 13 — Substitution pitfall

\(x=-3\) into \(x^2\): \((-3)^2=9\), not \(-3^2=-9\).

Example 14 — Prove small identity

Show \((a+b)^2- (a-b)^2=4ab\):
Left: \((a^2+2ab+b^2)-(a^2-2ab+b^2)=4ab\).

Exercises

Easy

  1. Combine like terms: \(7y-2+3y+8-y\).
  2. Expand \(4(3x-2)\).
  3. Evaluate \(2x^2-3x+1\) at \(x=4\).
  4. Expand \((x+3)(x+5)\).
  5. Factor out common factor: \(10x-15\).

Medium

  1. Expand and simplify $ (2x-1)(x+4)-x(x-3) $.
  2. Evaluate \(\dfrac{x+2}{x-2}\) at \(x=0\), \(x=4\); for which \(x\) undefined?
  3. Expand \((a+b)^2\) and \((a-b)^2\); subtract to prove \(4ab\) identity.
  4. Show \((x+y)(x-y)=x^2-y^2\) by expansion.
  5. Simplify \(3(a+2b)-2(2a-b)+a\).
  6. Substitute \(x=-2\) into \(x^2-5x-1\) carefully.
  7. Are $ (x+1)^2 $ and \(x^2+1\) identical? Prove or give counterexample.
  8. Build an expression tree for \(2(x+1)^2-3x\) (describe nodes).

Hard / proof

  1. Prove by expansion that \((a+b)^3=a^3+3a^2b+3ab^2+b^3\).
  2. Prove: if \(E(x)=F(x)\) for all \(x\) and \(G\) is any expression, then \(E+G\) and \(F+G\) are identical.
  3. For which real \(c\) is \(x^2+c\) always positive? Always nonnegative?
  4. Expand \((x+y+z)^2\) completely.
  5. Show that \(n\) free in \(2n+1\) vs bound in “\(\exists n\in\mathbb{Z}\) such that \(n^2=2\)” — explain the difference in one paragraph.
  6. Prove \((a+b+c)^2=a^2+b^2+c^2+2ab+2ac+2bc\).
  7. Determine whether \(\frac{x^2-1}{x-1}\) and \(x+1\) are identical as expressions on \(\mathbb{R}\) (consider \(x=1\)).

Challenge / CS-flavored

  1. Loop index \(i\) from \(0\) to \(n-1\): write an expression for the last index; for the count of iterations.
  2. Array length \(n\), middle index \(\lfloor n/2\rfloor\) — expression in \(n\).
  3. Cost expression \(3n^2+2n+5\) at \(n=10\); which term dominates for large \(n\) qualitatively?
  4. In a pure function f(x) = 3*x+1, is x free or bound in the body? What about a global used inside?
  5. Parse a-b-c as expression tree under left associativity; evaluate \(a=10,b=3,c=2\).

Formalizing “like terms”

Two monomials \(c x_1^{e_1}\cdots x_k^{e_k}\) and \(d x_1^{f_1}\cdots x_k^{f_k}\) are like when \(e_i=f_i\) for all \(i\). Only then \(c\) and \(d\) combine: \((c+d)\) times the common power product.

Ring axioms used constantly

When simplifying, you silently use associativity, commutativity of \(+\) and \(\times\), distributivity, and additive inverses. Writing \(a-b\) as \(a+(-b)\) prevents sign errors.

Polynomial vs non-polynomial expressions

\(x+\frac{1}{x}\), \(\sqrt{x}\), \(2^{x}\) are expressions but not polynomials. Polynomial restriction: finitely many nonnegative integer powers, coefficients from the base ring/field.

Evaluation homomorphism idea

Substituting \(x\mapsto c\) respects operations: \(\widehat{E+F}=\hat E+\hat F\), etc. That is why algebraic identities remain true after substitution (when defined).

Worked identity table

Expand Result
\((x+y+z)^2\) \(x^2+y^2+z^2+2xy+2xz+2yz\)
\((x+y)^3\) \(x^3+3x^2y+3xy^2+y^3\)
\((x-y)(x^2+xy+y^2)\) \(x^3-y^3\)
\((x+y)(x^2-xy+y^2)\) \(x^3+y^3\)

Extra exercises

  1. Expand \((2x-3y)^2\).
  2. Prove \((x+y)^2-(x-y)^2=4xy\) without picking numbers.
  3. For \(E(x)=x^{2}-1\) and \(F(x)=(x-1)(x+1)\), show identical as polynomials by expansion.
  4. Substitute \(x=y=z=1\) into \((x+y+z)^2\) expansion both ways.
  5. Expression tree for \(\frac{a+b}{c+d}\): what is the root operation?

CS connection

Expression trees are ASTs; constant folding combines like constants at compile time. Free vs bound variables are scope and lambda calculus. Algebraic simplification is peephole optimization. Identities like difference of squares appear in algorithmic rewrites and in closed forms.

Common pitfalls

Pitfall What to do instead
Combining \(3x^2+3x\) into \(6x^2\) Only like powers
\(- (x-3)=-x-3\) Distribute the minus: \(-x+3\)
Substituting negatives without parentheses Write \((-3)^2\)
Treating expressions as equations Expressions do not “solve”; they evaluate/simplify
Canceling terms over addition Factor first
Claiming identity after checking one \(x\) Must hold for all \(x\) in domain

Fully worked extra examples

E15 — Multi-step expand.
\((x+2)(x-2)(x+3)=(x^{2}-4)(x+3)=x^{3}+3x^{2}-4x-12\).

E16 — Nested evaluation with negatives.
\(E=2-3\bigl(1-(x-4)\bigr)\) at \(x=2\): inner \(1-(2-4)=1-(-2)=3\); \(2-3\cdot 3=2-9=-7\).

E17 — Identity failure counterexample.
Claim “\((x+y)^{2}=x^{2}+y^{2}\)”: at \(x=y=1\), left \(4\), right \(2\). False. Missing \(2xy\).

E18 — Parameter expression.
Cost \(C(n)=12n+50\). Incremental cost of one more unit: \(C(n+1)-C(n)=12\) (discrete derivative of linear).

E19 — Like terms multivariable.
\(3xy^{2}-5x^{2}y+2xy^{2}+x^{2}y=(3+2)xy^{2}+(-5+1)x^{2}y=5xy^{2}-4x^{2}y\).

End-of-day synthesis problems

S1. Expand and simplify \((2x-1)(x+3)-(x-2)^{2}\).

S2. Evaluate \(E(x)=x^{2}-5x+6\) at \(x=0,\pm 1,\pm 2\); relate to factors.

S3. Prove \((a+b)^{2}=a^{2}+2ab+b^{2}\) by distributivity only.

S4. Are \(x^{2}-1\) and \((x-1)(x+1)\) identical as polynomials? As functions on \(\mathbb{R}\)?

S5. Expression tree + evaluate \(3^{2+1}\) vs \(3^{2}\cdot 3\) vs \((3^{2})^{1}\) carefully with precedence.

S6. Free vs bound: rewrite \(\sum_{i=1}^{n}(2i+1)\) with index \(k\); what stays free?

S7. For which \(x\) is \(\frac{x^{2}-4}{x-2}\) defined? Simplify on its domain.

S8. Combine \(4a^{2}b-2ab^{2}+a^{2}b\) like terms in two variables.

Checkpoint

  • Define expression vs equation vs identity
  • Combine like terms and distribute reliably
  • Evaluate nested expressions with negatives
  • Expand \((a\pm b)^2\) and \((a+b)(a-b)\)
  • Explain free vs bound with a math and a code analogy
  • Spot excluded values in rational expressions
  • Complete S1 and S3

Write two takeaways in your own words.

Deep dive — expressions, identities, evaluation

D1 — Multi-step expand and simplify.
\((2x-1)(x+3)-(x-2)^{2}= (2x^{2}+6x-x-3)-(x^{2}-4x+4)=2x^{2}+5x-3-x^{2}+4x-4=x^{2}+9x-7\).
Expand each product fully before combining; watch the minus before \((x-2)^{2}\).

D2 — Identity proof by distributivity only.
\((a+b)^{2}=(a+b)(a+b)=a(a+b)+b(a+b)=a^{2}+ab+ba+b^{2}=a^{2}+2ab+b^{2}\) (using \(ab=ba\)).

D3 — Difference of squares and cubes links.
\((x-y)(x^{2}+xy+y^{2})=x^{3}-y^{3}\); \((x+y)(x^{2}-xy+y^{2})=x^{3}+y^{3}\).
Verify by FOIL/distribution; store as expansion/factoring duals (Day 16).

D4 — Evaluation with nested negatives.
\(E=2-3\bigl(1-(x-4)\bigr)\) at \(x=2\): inner \(x-4=-2\), \(1-(-2)=3\), \(2-3\cdot 3=-7\).
Parentheses beat mental shortcuts when signs stack.

D5 — Free vs bound contrast.
In \(2n+1\), \(n\) is free. In \(\sum_{i=1}^{n}(2i+1)\), \(i\) is bound (dummy), \(n\) remains free.
Renaming \(i\to k\) does not change the sum; renaming \(n\) would change the meaning.

D6 — Excluded values before “cancel.”
\(\dfrac{x^{2}-4}{x-2}\) equals \(x+2\) for \(x\neq 2\), but as raw expressions on all of \(\mathbb{R}\) they differ at \(x=2\) (undefined vs \(4\)). Polynomial identity after clearing the hole is a separate statement.

Extra practice set

  1. Expand \((2x-3y)^{2}\) and \((x+y+z)^{2}\).
  2. Prove \((x+y)^{2}-(x-y)^{2}=4xy\) by expansion only.
  3. Are \((x+1)^{2}\) and \(x^{2}+1\) identical? Counterexample.
  4. Expression tree for \(\dfrac{a+b}{c+d}\): root operation? Evaluate \(a=1,b=2,c=3,d=1\).
  5. Combine like terms: \(4a^{2}b-2ab^{2}+a^{2}b+5ab^{2}\).

Synthesis checklist (expressions day)

Syn-A. Expand and simplify one multi-factor expression (include a squared binomial).
Syn-B. Prove \((a+b)^{2}=a^{2}+2ab+b^{2}\) using only distributivity and \(ab=ba\).
Syn-C. Evaluate a nested expression at a negative input with full parentheses.
Syn-D. State one free-vs-bound example (math sum or code parameter).
Syn-E. Name an excluded value for a rational expression and simplify on the domain.
Syn-F. Distinguish expression / equation / identity with one example each.

Complete Syn-A–C before moving to linear equations.

Tomorrow

Day 12 — Linear equations. Axioms of equality; multi-step solving; identities vs contradictions vs conditionals; word problems; formula rearrangement.


Day 12 — Linear equations

Stage II · concept day
Goal: Use equality axioms to solve multi-step linear equations; classify identities, contradictions, and conditionals; solve word problems; rearrange formulas.

Why this matters

Solving \(ax+b=c\) is the prototype of state equations and constraint solving. Every unit conversion, break-even model, and “solve for \(n\) in a complexity identity” uses the same reversible steps. Mistakes are usually illegal operations (dividing by zero, losing solutions) rather than arithmetic.

Theory

Equality axioms / properties

Equality on numbers is an equivalence relation and respects operations:

  1. Reflexive: \(a=a\)
  2. Symmetric: \(a=b\Rightarrow b=a\)
  3. Transitive: \(a=b\) and \(b=c\Rightarrow a=c\)
  4. Addition property: \(a=b\Rightarrow a+c=b+c\)
  5. Multiplication property: \(a=b\Rightarrow ac=bc\)
  6. Substitution: if \(a=b\), either may replace the other in expressions

Cancellation (careful): if \(ac=bc\) and \(c\neq 0\), then \(a=b\). If \(c=0\), no information.

Linear equations in one variable

A linear equation in \(x\) can be written \[ax+b=0\qquad\text{or}\qquad ax+b=cx+d\] with \(a,b,c,d\) constants, \(x\) appearing only to the first power (after simplification).

Solution strategy:

  1. Expand / clear parentheses.
  2. Combine like terms on each side.
  3. Collect variable terms on one side, constants on the other (add inverses).
  4. Divide/multiply by the coefficient of \(x\) if nonzero.
  5. Check in the original equation.

Conditional, identity, contradiction

After simplifying \(ax+b=cx+d\) to \(px=q\) form:

Case Meaning Solution set
\(p\neq 0\) Conditional equation \(\{q/p\}\) one solution
\(p=0\) and \(q=0\) Identity (always true) all reals (or stated domain)
\(p=0\) and \(q\neq 0\) Contradiction (never true) empty set \(\emptyset\)

Examples: \(2x+1=2x+1\) identity; \(2x+1=2x+3\) contradiction; \(2x+1=5\) conditional \(x=2\).

Clearing fractions and decimals

Multiply both sides by a common denominator (LCD) of all fractions to obtain an integer-coefficient equation.
For decimals, multiply by a power of \(10\).

Word problems → equations

  1. Define variable(s) with units.
  2. Translate relationships (sum, difference, rate \(\times\) time, percent of).
  3. Solve.
  4. Check reasonableness and original wording.

Classic patterns: total = parts; distance \(=rt\); mixture; consecutive integers; “one number is \(3\) more than twice another.”

Formula rearrangement

Treat the target variable as \(x\) and apply the same properties.

Example: \(v=u+at\) solve for \(t\): \(t=\dfrac{v-u}{a}\) if \(a\neq 0\).
\(F=\dfrac{9}{5}C+32\) solve for \(C\): \(C=\dfrac{5}{9}(F-32)\).

Equivalent equations

Two equations are equivalent if they have the same solution set.
Allowed steps (add same quantity, multiply by nonzero constant) produce equivalent equations.
Multiplying by an expression that can be zero may add extraneous solutions; dividing may lose solutions—more critical for nonlinear/rational cases (Day 17).

Worked examples

Example 1 — Two-step

\(3x-7=11\). Add \(7\): \(3x=18\). Divide by \(3\): \(x=6\). Check: \(18-7=11\).

Example 2 — Variables both sides

\(5x+3=2x-9\). Subtract \(2x\): \(3x+3=-9\). Subtract \(3\): \(3x=-12\). \(x=-4\).

Example 3 — Distribute

\(2(3x-4)+5=3(x+1)\). \(6x-8+5=3x+3\). \(6x-3=3x+3\). \(3x=6\). \(x=2\).

Example 4 — Fractions

\(\dfrac{x}{2}+\dfrac{x}{3}=5\). Multiply by \(6\): \(3x+2x=30\). \(5x=30\). \(x=6\).

Example 5 — Identity

\(4(x-1)+2=2(2x+1)-4\). Left \(4x-4+2=4x-2\). Right \(4x+2-4=4x-2\). Equal for all \(x\).

Example 6 — Contradiction

\(3(x+2)=3x+5\). \(3x+6=3x+5\). \(6=5\). Never. \(\emptyset\).

Example 7 — Word: consecutive

Three consecutive integers sum to \(54\). Let \(n+(n+1)+(n+2)=54\). \(3n+3=54\). \(3n=51\). \(n=17\). Triple \(17,18,19\).

Example 8 — Rate

Car \(A\) at \(60\) km/h, car \(B\) at \(80\) km/h, start together opposite directions. When \(420\) km apart? \((60+80)t=420\). \(t=3\) h.

Example 9 — Percent

A number \(n\) increased by \(15\%\) is \(92\). \(1.15n=92\). \(n=80\).

Example 10 — Formula

\(A=\frac{1}{2}(b_1+b_2)h\) solve for \(b_2\): \(2A/h=b_1+b_2\), so \(b_2=\frac{2A}{h}-b_1\) (\(h\neq 0\)).

Example 11 — Decimals

\(0.2x+0.05(100-x)=8\). Multiply by \(100\): \(20x+5(100-x)=800\). \(20x+500-5x=800\). \(15x=300\). \(x=20\).

Example 12 — Literal

Solve \(ax+b=cx+d\) for \(x\) (assuming \(a\neq c\)): \((a-c)x=d-b\), \(x=\dfrac{d-b}{a-c}\).

Example 13 — Check necessity

\(\frac{x}{x}=1\) is not true for \(x=0\); after multiplying by \(x\) carelessly you might think all \(x\) work. Domain matters.

Example 14 — Break-even

Cost \(C=500+12n\), revenue \(R=20n\). Break-even \(20n=500+12n\). \(8n=500\). \(n=62.5\) — if \(n\) must be integer, interpret context (ceil units).

Exercises

Easy

  1. Solve \(5x+2=17\).
  2. Solve \(1-2x=9\).
  3. Solve \(3(x+4)=24\).
  4. Solve \(\frac{x}{5}= -3\).
  5. Solve for \(r\): \(C=2\pi r\).

Medium

  1. Solve \(4(2x-1)-3=2(x+5)+x\).
  2. Solve \(\dfrac{2x-1}{3}=\dfrac{x+4}{2}\).
  3. Classify: \(5x-1=5(x+2)-11\) as identity / conditional / contradiction; solve if applicable.
  4. Classify \(2(x+3)=2x+5\).
  5. Word: one number is \(4\) less than \(3\) times another; sum is \(28\). Find the numbers.
  6. Mixture: \(20\) L of \(10\%\) solution mixed with \(x\) L of \(30\%\) to get \(25\%\). Equation and \(x\).
  7. Rearrange \(v^2=u^2+2as\) for \(s\).
  8. Solve \(0.15x+0.10(20)=0.12(x+20)\).

Hard

  1. Prove: if \(a=b\), then \(a+c=b+c\) using “same quantity added” reasoning from field axioms (informal OK).
  2. Solve for \(x\) in terms of parameters: \(a(x-b)=c(x+d)\) with stated conditions when unique.
  3. For which \(k\) does \(kx+1=2x+k\) have (i) one solution (ii) all \(x\) (iii) no solution?
  4. Word: digit problem—two-digit number \(10t+u\), digits sum to \(12\), number \(= 4\) times sum of digits? Set equations carefully.
  5. Explain why multiplying both sides of an equation by \(0\) is useless; give example.
  6. Distance: runners \(3\) km apart run toward each other at \(8\) and \(7\) km/h. Time to meet?
  7. Show that \(x=2\) is not a solution of \(x+1=x+2\) without “simplifying to \(1=2\)” first—by direct substitution.

Challenge / CS-flavored

  1. Memory: \(n\) structures of \(24\) bytes plus \(16\) byte header uses \(4096\) bytes total. Solve for max \(n\).
  2. Loop: for i in 0..n-1 runs how many times? Solve \(n\) if runtime proportional to \(n\) equals \(1000\) units when \(c n=1000\) and \(c=4\).
  3. Temperature conversion chain: solve \(F\) given \(C\), then invert.
  4. Fixed point: \(x=0.8x+20\) (e.g. damped update). Solve \(x\).
  5. Explain “solve for \(n\)” in \(2^n \ge 10^6\) as not linear—why Day 8/20 methods differ.

Solution sets formally

The solution set of an equation in variable \(x\) over \(\mathbb{R}\) is \(\{x\in\mathbb{R}: \text{equation holds}\}\).
Linear case yields \(\emptyset\), a singleton, or \(\mathbb{R}\) (after simplification to \(px=q\)).

Equivalent transformations (safe list)

Safe (preserve solution set over \(\mathbb{R}\) for linear forms):

  • Add/subtract the same expression in \(x\) to both sides
  • Multiply/divide both sides by a nonzero constant

Unsafe without casework:

  • Multiply/divide by an expression that might be \(0\)
  • Square both sides (can add solutions; nonlinear)

Literal equations catalog

Formula Solve for
\(I=Prt\) \(t=\frac{I}{Pr}\)
\(\frac{1}{f}=\frac{1}{u}+\frac{1}{v}\) \(f=\frac{uv}{u+v}\) (with \(u+v\neq 0\))
\(y-y_1=m(x-x_1)\) \(m=\frac{y-y_1}{x-x_1}\) (\(x\neq x_1\))
\(an+b=c\) \(n=\frac{c-b}{a}\) (\(a\neq 0\))

Word problem schema

Uniform motion: \(d=rt\), chase/together/apart cases.
Mixture: pure amounts of solute: concentration \(\times\) volume.
Work: rates add when parallel.
Digits: \(10t+u\) structure.
Age: “in \(k\) years” shifts both ages by \(k\).

Extra exercises

  1. Solve for \(x\): \(a(x+1)=b(x-1)\) with \(a\neq b\).
  2. For which \(m\) is \(mx+1=2x+m\) an identity?
  3. Two trains \(150\) km apart head toward each other at \(70\) and \(80\) km/h; time to meet.
  4. Clear decimals: \(0.05x+0.1(20-x)=1.2\).
  5. Show that if two linear equations are equivalent, their graphs (as lines in \(x\) only—degraded) match solution sets on the number line.

CS connection

Constraint solving, unit tests as equations, and configuration “solve for thread count given budget” are linear equation patterns. Formula rearrangement is API design: which quantity is input. Identity vs contradiction mirrors tautology vs unsatisfiable boolean constraints (Stage III).

Common pitfalls

Pitfall What to do instead
Moving terms without sign change Adding the additive inverse
Dividing by variable coefficient that might be \(0\) Case-split on parameters
Forgetting to check Substitute back
Losing domain restrictions Track steps that multiply by expressions
Word problem variable undefined Sentence: “let \(x\) be …” with units
Treating identity as “no solution” All values work

Fully worked extra examples

E15 — Fractions both sides.
\(\frac{x+1}{3}=\frac{2x-1}{5}\). Cross: \(5(x+1)=3(2x-1)\), \(5x+5=6x-3\), \(8=x\).

E16 — Identity recognition.
\(2(x-4)+8=2x\): left \(2x-8+8=2x\). Identity; solution set \(\mathbb{R}\).

E17 — Literal with factoring.
\(ax-c=bx+d\)\(ax-bx=d+c\)\(x(a-b)=d+c\). If \(a\neq b\), \(x=\frac{d+c}{a-b}\). If \(a=b\) and \(d+c=0\), all \(x\); if \(a=b\) and \(d+c\neq 0\), empty.

E18 — Mixture.
\(10\) L of \(20\%\) acid + \(x\) L of \(50\%\) acid → \(30\%\) mixture:
\(0.2\cdot 10+0.5x=0.3(10+x)\), \(2+0.5x=3+0.3x\), \(0.2x=1\), \(x=5\).

End-of-day synthesis problems

S1. Solve \(\frac{2x-1}{4}-\frac{x+3}{6}=1\) by LCD.

S2. Classify and solve \(k x+3=2x+k\) in cases on \(k\).

S3. Word: ticket prices adults \(\$a\) children \(\$c\); \(3\) adults \(+2\) children \(=\$46\); \(1\) adult \(+4\) children \(=\$36\). Wait—single variable day: instead, one number is thrice another; sum \(64\). Find them.

S4. Rearrange \(\frac{1}{R}=\frac{1}{R_1}+\frac{1}{R_2}\) for \(R_1\).

S5. Prove: adding \(c\) to both sides preserves solutions (equality axiom narrative).

S6. Solve \(0.25(x-3)=0.1x+1.1\).

S7. Identity check: expand both sides of \(2(x+3)-x=x+6\).

S8. Distance: walk \(4\) km/h for \(t\) hours and bike \(12\) km/h for \(2-t\) hours cover \(20\) km total. Equation for \(t\).

Checkpoint

  • Use \(+c\) and \(\times c\) (\(c\neq 0\)) properties deliberately
  • Solve multi-step linear equations with parentheses and fractions
  • Classify identity / contradiction / conditional
  • Translate a word problem to an equation and solve
  • Rearrange a multi-variable formula for a chosen variable
  • Case-split a parameter equation (S2 style)

Write two takeaways in your own words.

Deep dive — linear equations, cases, word models

D1 — Clear fractions with LCD carefully.
\(\dfrac{2x-1}{4}-\dfrac{x+3}{6}=1\). LCD \(12\):
\(3(2x-1)-2(x+3)=12\), \(6x-3-2x-6=12\), \(4x-9=12\), \(4x=21\), \(x=\frac{21}{4}\).
Check by substitution into the original.

D2 — Parameter cases (full write-up).
\(kx+3=2x+k\). Collect: \(kx-2x=k-3\), \(x(k-2)=k-3\).
- If \(k\neq 2\): unique \(x=\dfrac{k-3}{k-2}\).
- If \(k=2\) and \(k-3=0\) i.e. \(2=3\) false: wait, when \(k=2\), right side \(k-3=-1\neq 0\)\(0\cdot x=-1\) contradiction → \(\emptyset\).
- Identity would need \(k=2\) and \(k-3=0\) simultaneously—impossible here. (Compare \(kx+k=2x+2\) for a true identity case when \(k=2\).)

D3 — Literal formula rearrangement.
\(\dfrac{1}{R}=\dfrac{1}{R_1}+\dfrac{1}{R_2}\). Solve for \(R_1\):
\(\dfrac{1}{R_1}=\dfrac{1}{R}-\dfrac{1}{R_2}=\dfrac{R_2-R}{R R_2}\), so \(R_1=\dfrac{R R_2}{R_2-R}\) when \(R_2\neq R\).

D4 — Mixture model.
\(10\) L of \(20\%\) acid + \(x\) L of \(50\%\)\(30\%\) blend:
\(0.2\cdot 10+0.5x=0.3(10+x)\), \(2+0.5x=3+0.3x\), \(0.2x=1\), \(x=5\).

D5 — Motion toward each other.
Distance \(150\) km, speeds \(70\) and \(80\) km/h: \((70+80)t=150\), \(t=1\) h.
Opposite directions with same numbers: still add speeds for separation rate.

D6 — Equivalent equations discipline.
Adding the same expression to both sides preserves the solution set.
Multiplying by a nonzero constant preserves it.
Multiplying by an expression that can vanish (e.g. \(x\)) can add or drop solutions—defer full rational-equation care to Day 17, but never multiply a linear training equation by \(0\).

Extra practice set

  1. Solve \(\dfrac{x+1}{3}=\dfrac{2x-1}{5}\) and check.
  2. For which \(m\) is \(mx+1=2x+m\) an identity? Conditional? Empty?
  3. Two numbers sum to \(64\); one is thrice the other. Find them.
  4. Rearrange \(v^{2}=u^{2}+2as\) for \(a\).
  5. Clear decimals: \(0.05x+0.1(20-x)=1.2\).

Tomorrow

Day 13 — Inequalities. Flip rule when multiplying by negatives; compound inequalities; interval notation; absolute value inequalities; 1D systems of inequalities.


Day 13 — Inequalities

Stage II · concept day
Goal: Apply inequality properties (especially flip when multiplying by a negative); solve compound inequalities; use interval notation; solve absolute value inequalities; handle 1D systems of inequalities.

Why this matters

Bounds, loop invariants, complexity “\(n\ge n_0\),” and SLOs are inequalities. Off-by-one errors are inequality edge errors. Absolute value inequalities encode distance constraints—“within \(\varepsilon\) of target.”

Theory

Order on \(\mathbb{R}\)

\(a<b\) means \(b-a\) is positive.
\(a\le b\) means \(a<b\) or \(a=b\).
Trichotomy: for any \(a,b\), exactly one of \(a<b\), \(a=b\), \(a>b\).

Properties of inequalities

For real \(a,b,c\):

  1. \(a<b\Rightarrow a+c<b+c\)
  2. If \(c>0\) and \(a<b\), then \(ac<bc\)
  3. If \(c<0\) and \(a<b\), then \(ac>bc\) (flip)
  4. Transitivity: \(a<b\) and \(b<c\Rightarrow a<c\)
  5. If \(a<b\) and \(c<d\), then \(a+c<b+d\)

Proof of flip (3). \(c<0\) so \(-c>0\). From \(a<b\), multiply by \(-c>0\): \(-ca<-cb\), i.e. \(-ac<-bc\). Add \(ac+bc\): \(bc<ac\), so \(ac>bc\). \(\square\)

Same rules for \(\le\) with care at equality.

Taking reciprocals: if \(0<a<b\), then \(\frac{1}{a}>\frac{1}{b}\). (Both positive.)

Linear inequalities

Solve like equations but flip when multiplying/dividing by a negative.

Example: \(-2x+4\le 10\). \(-2x\le 6\). Divide by \(-2\): \(x\ge -3\).

Compound inequalities

Conjunction (and): \(a\le x\le b\) means \(x\ge a\) and \(x\le b\).
Disjunction (or): \(x\le a\) or \(x\ge b\) (e.g. outside an interval).

Solve each part; intersect (and) or union (or).

Interval notation

Inequality Interval
\(a\le x\le b\) \([a,b]\)
\(a< x< b\) \((a,b)\)
\(a\le x< b\) \([a,b)\)
\(x\ge a\) \([a,\infty)\)
\(x< b\) \((-\infty,b)\)
all reals \(\mathbb{R}=(-\infty,\infty)\)
empty \(\emptyset\)

\(\infty\) is not a number; always write soft parentheses next to \(\infty\).

Absolute value inequalities

\(|A|\) is distance from \(A\) to \(0\) on the line.

Theorem.

  1. \(|A|\le k\) with \(k\ge 0\) \(\Leftrightarrow\) \(-k\le A\le k\)
  2. \(|A|\ge k\) with \(k\ge 0\) \(\Leftrightarrow\) \(A\le -k\) or \(A\ge k\)
  3. If \(k<0\), then \(|A|\le k\) is impossible; \(|A|\ge k\) is always true

Proof idea of (1). \(|A|\le k\) means distance to \(0\) at most \(k\), i.e. \(A\) in \([-k,k]\). Formally: if \(A\ge 0\), \(A\le k\); if \(A<0\), \(-A\le k\) so \(A\ge -k\). \(\square\)

Examples: \(|x-3|<2\Leftrightarrow 1<x<5\).
\(|x+1|\ge 4\Leftrightarrow x+1\le -4\) or \(x+1\ge 4\) \(\Leftrightarrow\) \(x\le -5\) or \(x\ge 3\).

Systems of inequalities in 1D

A system is a list of simultaneous constraints on one variable. Solution is the intersection of solution sets (for “and” systems).

Graphically: shade the number line; final solution is overlap.

Quadratic inequalities (preview light)

Sign charts for \((x-1)(x+2)>0\) appear after factoring (Day 16); today optional awareness only.

Nested absolute values and triangle inequality

Triangle inequality. For all real \(a,b\), \[|a+b|\le |a|+|b|.\] Proof idea. \(|a+b|^2=(a+b)^2=a^2+2ab+b^2\le a^2+2|a||b|+b^2=(|a|+|b|)^2\) because \(ab\le |a||b|\). Take nonnegative square roots. \(\square\)

Reverse triangle: \(\bigl||a|-|b|\bigr|\le |a-b|\).

These are the continuous analogues of “error bounds add” in numerical work: if \(|x-\hat x|\le\varepsilon\) and \(|y-\hat y|\le\delta\), then \(|(x+y)-(\hat x+\hat y)|\le\varepsilon+\delta\).

Multiplying inequalities (same direction)

If \(0\le a\le b\) and \(0\le c\le d\), then \(ac\le bd\).
Proof. \(ac\le bc\) (since \(c\ge 0\) and \(a\le b\)), and \(bc\le bd\) (since \(b\ge 0\) and \(c\le d\)). Transitivity. \(\square\)
Warning: without nonnegativity this fails (e.g. \(-3\le -1\) and \(-2\le 1\) but products \(6\) and \(-1\)).

Integer vs real solutions

An inequality solved over \(\mathbb{R}\) may be further restricted to \(x\in\mathbb{Z}\).
Example: \(|x-1|<2.5\) over \(\mathbb{R}\) is \((-1.5,3.5)\); over \(\mathbb{Z}\) is \(\{-1,0,1,2,3\}\).
Loop bounds are almost always integer inequalities; always state the universe.

Worked examples

Example 1 — Flip

\(-3x>12\). Divide by \(-3\): \(x<-4\). Interval \((-\infty,-4)\).

Example 2 — Compound and

\(-1\le 2x+3<7\). Subtract \(3\): \(-4\le 2x<4\). Divide by \(2\): \(-2\le x<2\). Interval \([-2,2)\).

Example 3 — Compound or

\(x+1\le -2\) or \(x+1\ge 5\): \(x\le -3\) or \(x\ge 4\). \((-\infty,-3]\cup[4,\infty)\).

Example 4 — Absolute \(\le\)

\(|2x-1|\le 5\). \(-5\le 2x-1\le 5\). \(-4\le 2x\le 6\). \(-2\le x\le 3\). \([-2,3]\).

Example 5 — Absolute \(\ge\)

\(|x/2|>3\). \(x/2<-3\) or \(x/2>3\). \(x<-6\) or \(x>6\).

Example 6 — Negative \(k\)

\(|x|\le -1\): empty. \(|x|\ge -1\): all reals.

Example 7 — System

\(\begin{cases}x>1\\ x\le 4\\ x\neq 2\end{cases}\)\((1,2)\cup(2,4]\).

Example 8 — Reciprocal

\(0<x\le 2\) \(\Rightarrow\) \(\frac{1}{x}\ge \frac{1}{2}\) (and \(\frac{1}{x}>0\)).

Example 9 — Word bound

Score \(s\) at least \(90\): \(s\ge 90\). Average of two tests \(\ge 90\): \(\frac{s_1+s_2}{2}\ge 90\).

Example 10 — Distance

All \(x\) within \(0.5\) of \(3\): \(|x-3|\le 0.5\) \(\Leftrightarrow\) \(2.5\le x\le 3.5\).

Example 11 — Multiply by variable (danger)

If \(x\) might be negative, do not multiply inequality by \(x\) without cases. Prefer bring to one side.

Example 12 — Fraction inequality linear

\(\dfrac{x-1}{2}>\dfrac{x}{3}\). Multiply by \(6>0\): \(3(x-1)>2x\). \(3x-3>2x\). \(x>3\).

Example 13 — All reals / empty linear

\(2x+1<2x+4\) always true. \(2x+5\le 2x+1\) never.

Example 14 — Interval operations

\([-2,5)\cap(0,7]= (0,5)\). \([-2,5)\cup(0,7]=[-2,7]\).

Example 15 — Triangle inequality numeric

\(|3+(-5)|=2\le |3|+|-5|=8\). Tightness fails when signs differ. Equality in \(|a+b|=|a|+|b|\) holds when \(ab\ge 0\) (same sign or zero).

Example 16 — Two-sided bound from absolute error

If \(|x-10|\le 0.3\), then \(9.7\le x\le 10.3\). If also \(|y-4|\le 0.1\), then \(|(x+y)-14|\le 0.4\) and \(13.6\le x+y\le 14.4\).

Example 17 — Case-split multiply by \(x\)

Solve \(x(x-2)>0\). Critical points \(0,2\). Sign chart: positive on \((-\infty,0)\cup(2,\infty)\). (Do not divide by \(x\) without cases.)

Example 18 — Compound absolute

\(|x+1|+|x-1|\ge 2\) for all \(x\) (triangle / geometric: sum of distances to \(-1\) and \(1\) is at least the gap \(2\)). Equality on \([-1,1]\).

Example 19 — Integer loop range

\(i\) runs from \(0\) inclusive to \(n\) exclusive” is \(0\le i\le n-1\) for \(i\in\mathbb{Z}\), equivalently \(i\in\{0,1,\ldots,n-1\}\). Count: \(n\) values if \(n\ge 0\).

Example 20 — Reciprocal on negatives

If \(a<b<0\), then \(\frac{1}{a}>\frac{1}{b}\) still holds (both negative; e.g. \(a=-4\), \(b=-2\): \(-\frac14>-\frac12\)). Same formal proof: \(a-b<0\) and \(ab>0\) imply \(\frac{1}{a}-\frac{1}{b}=\frac{b-a}{ab}>0\).

Exercises

Easy

  1. Solve \(5x-3<12\); write interval.
  2. Solve \(-4x\ge 8\).
  3. Write in interval notation: \(x\le 2\), \(x> -1\), \(-3\le x<0\).
  4. Solve \(|x|\le 4\).
  5. Solve \(|x|>3\).

Medium

  1. Solve \(-3\le 1-2x<5\); interval.
  2. Solve \(|3x+2|<8\).
  3. Solve \(|2x-5|\ge 7\).
  4. System: \(x\ge -1\) and \(x<3\) and \(x\neq 0\).
  5. Solve \(\dfrac{2x+1}{3}\le x-1\).
  6. For which \(x\) is \(3-x>0\)? Write as interval.
  7. Express “error at most \(10^{-3}\) from \(2\)” as absolute inequality and interval.
  8. Solve \(|x+4|\le -2\) and \(|x+4|\ge -2\).

Hard / proof

  1. Prove: if \(c<0\) and \(a\le b\) then \(ac\ge bc\).
  2. Prove \(|A|\le k\Leftrightarrow -k\le A\le k\) for \(k\ge 0\).
  3. Prove: if \(0<a<b\) then \(\frac{1}{a}>\frac{1}{b}\).
  4. Solve \(|x-1|+|x+1|\le 4\) by cases on \(x\) relative to \(-1\) and \(1\).
  5. For which \(a\) is \(|x|\ge a\) true for all \(x\)? For no \(x\)?
  6. Show that \(x^2>0\) for all \(x\neq 0\); write solution set of \(x^2\ge 0\).
  7. Disprove: \(a<b\Rightarrow a^2<b^2\) (find counterexample with negatives).

Challenge / CS-flavored

  1. Array indices valid iff \(0\le i<n\). Write as compound inequality.
  2. Binary search invariant idea: \(L\le R\) while searching—when does loop stop as inequality?
  3. Throughput \(t\) must satisfy \(t\ge 100\) and \(t\le 500\). Interval.
  4. Clamp function: project \(x\) onto \([a,b]\). Describe piecewise using inequalities.
  5. Off-by-one: difference between \(i\le n\) and \(i<n\) for integer loops \(i=1,2,\ldots\).

Number-line calculus of sets

Solution sets combine with \(\cap\) (and) and \(\cup\) (or).
De Morgan: complement of \(x<a\) is \(x\ge a\) (over \(\mathbb{R}\)).
Unbounded rays: \((-\infty,a)\), \([b,\infty)\).

Absolute value as distance

\(|x-a|\) is distance between \(x\) and \(a\).
\(|x-a|<r\) open ball (interval) center \(a\) radius \(r\).
\(|x-a|>r\) exterior.

Chained inequalities

\(a\le b\le c\) means \(a\le b\) and \(b\le c\); transitivity gives \(a\le c\).
You may add inequalities in the same direction: \(a\le b\) and \(c\le d\Rightarrow a+c\le b+d\).
Not multiply inequalities by negatives without flipping each.

Sign chart teaser

For \(\frac{x-1}{x+2}>0\), critical points \(x=1,-2\) split the line; test signs on intervals. Full rational inequalities pair with Day 17 domains.

Extra exercises

  1. Solve \(3-|2x+1|\ge 0\).
  2. Express \(\{x: |x|\ge 2\}\cap \{x: x<5\}\) in interval unions.
  3. Prove: if \(a\le b\) and \(c>0\) then \(ac\le bc\).
  4. Solve \(\frac{2x-1}{5}<\frac{x+1}{2}\) carefully.
  5. Integer solutions only: \(x\in\mathbb{Z}\) and \(|x-3|\le 2\) — list them.

CS connection

Assertions assert(0 <= i && i < n), rate limiters, and timeout bounds are inequalities. Absolute tolerances |err| <= eps match numerical tests. Interval arithmetic and range analysis estimate bounds without executing all paths.

Common pitfalls

Pitfall What to do instead
Forgetting to flip Always check sign of multiplier
Writing \([-\infty, 2]\) Use \((-\infty,2]\)
\(|A|\ge k\) as one interval Split into or
Multiplying by variable sign unknown Case-split or avoid
Strict vs nonstrict at endpoints Match \(<\) with (
Assuming \(a<b\Rightarrow a^2<b^2\) False if negatives

Fully worked extra examples

E15 — Absolute compound.
\(1\le |x-2|<4\). Right: \(|x-2|<4\Rightarrow -2<x<6\). Left: \(|x-2|\ge 1\Rightarrow x\le 1\) or \(x\ge 3\). Intersect: \((-2,1]\cup[3,6)\).

E16 — Flip twice.
\(-\frac{1}{2}x+3>7\). \(-\frac12 x>4\). Multiply by \(-2\) (flip): \(x<-8\).

E17 — All reals identity inequality.
\(2x+1<2x+5\) always true; solution \(\mathbb{R}\).
\(2x+5\le 2x+1\) never; \(\emptyset\).

E18 — Interval algebra.
\([-3,2)\cup(0,5]=[-3,5]\). \([-3,2)\cap(0,5]=(0,2)\).

End-of-day synthesis problems

S1. Solve \(-5<1-2x\le 7\); graph on a number line; interval.

S2. Solve \(|3x+6|\ge 9\); write in interval union form.

S3. Prove \(|A|\le k\Leftrightarrow -k\le A\le k\) for \(k\ge 0\).

S4. System: \(x\ge -2\), \(x<5\), \(|x|\ge 1\). Express solution as union of intervals.

S5. Solve \(\frac{x}{2}+1>\frac{x}{3}-2\) without mistakes on operations.

S6. Integer solutions of \(|x-4|<2.5\).

S7. For which \(k\) is \(|x|\le k\) empty? All of \(\mathbb{R}\)?

S8. Distance: all reals within \(0.01\) of \(2\) as absolute inequality and interval.

Deep dive — Solving \(|ax+b|\le |cx+d|\)

Square both sides only when both sides are nonnegative, which absolute values always are. So \[|ax+b|\le |cx+d|\quad\Leftrightarrow\quad (ax+b)^2\le (cx+d)^2\] \[\Leftrightarrow\quad (ax+b)^2-(cx+d)^2\le 0\quad\Leftrightarrow\quad \bigl((ax+b)-(cx+d)\bigr)\bigl((ax+b)+(cx+d)\bigr)\le 0.\] Factor and use a sign chart.
Example: \(|x|\le |x-2|\). Then \(x^2\le (x-2)^2\Rightarrow 0\le -4x+4\Rightarrow x\le 1\). Check: for \(x=0\), \(0\le 2\) true; for \(x=2\), \(2\le 0\) false.

Synthesis

Inequalities are equations with direction. The only new global rule is flip under negative scale. Absolute value converts distance statements into compound linear inequalities. Solution sets live on the line as intervals and unions; systems are intersections. Integer restriction is a final filter, not a different algebra.

S9. Prove the reverse triangle \(\bigl||a|-|b|\bigr|\le |a-b|\).

S10. Solve \(|2x-1|\le |x+3|\) by squaring; give interval answer.

S11. Find all integers \(n\) with \(|2n-5|<7\).

S12. If \(0<a\le b\) and \(c\le d<0\), what can you say about \(ac\) vs \(bd\)? (Careful with signs.)

Checkpoint

  • Flip correctly when multiplying/dividing by negative
  • Solve compound inequalities; write interval notation
  • Solve \(|A|\le k\) and \(|A|\ge k\)
  • Intersect 1D inequality systems on a number line
  • Prove the flip rule once cleanly
  • Write S3 as a formal short proof

Write two takeaways in your own words.

Tomorrow

Day 14 — Systems \(2\times 2\). Substitution/elimination; geometric cases; determinant; matrix form \(Ax=b\); Cramer’s rule; inverse of \(2\times 2\).