Day 13 — 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\):
- \(a<b\Rightarrow a+c<b+c\)
- If \(c>0\) and \(a<b\), then \(ac<bc\)
- If \(c<0\) and \(a<b\), then \(ac>bc\) (flip)
- Transitivity: \(a<b\) and \(b<c\Rightarrow a<c\)
- 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.
- \(|A|\le k\) with \(k\ge 0\) \(\Leftrightarrow\) \(-k\le A\le k\)
- \(|A|\ge k\) with \(k\ge 0\) \(\Leftrightarrow\) \(A\le -k\) or \(A\ge k\)
- 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
- Solve \(5x-3<12\); write interval.
- Solve \(-4x\ge 8\).
- Write in interval notation: \(x\le 2\), \(x> -1\), \(-3\le x<0\).
- Solve \(|x|\le 4\).
- Solve \(|x|>3\).
Medium
- Solve \(-3\le 1-2x<5\); interval.
- Solve \(|3x+2|<8\).
- Solve \(|2x-5|\ge 7\).
- System: \(x\ge -1\) and \(x<3\) and \(x\neq 0\).
- Solve \(\dfrac{2x+1}{3}\le x-1\).
- For which \(x\) is \(3-x>0\)? Write as interval.
- Express “error at most \(10^{-3}\) from \(2\)” as absolute inequality and interval.
- Solve \(|x+4|\le -2\) and \(|x+4|\ge -2\).
Hard / proof
- Prove: if \(c<0\) and \(a\le b\) then \(ac\ge bc\).
- Prove \(|A|\le k\Leftrightarrow -k\le A\le k\) for \(k\ge 0\).
- Prove: if \(0<a<b\) then \(\frac{1}{a}>\frac{1}{b}\).
- Solve \(|x-1|+|x+1|\le 4\) by cases on \(x\) relative to \(-1\) and \(1\).
- For which \(a\) is \(|x|\ge a\) true for all \(x\)? For no \(x\)?
- Show that \(x^2>0\) for all \(x\neq 0\); write solution set of \(x^2\ge 0\).
- Disprove: \(a<b\Rightarrow a^2<b^2\) (find counterexample with negatives).
Challenge / CS-flavored
- Array indices valid iff \(0\le i<n\). Write as compound inequality.
- Binary search invariant idea: \(L\le R\) while searching—when does loop stop as inequality?
- Throughput \(t\) must satisfy \(t\ge 100\) and \(t\le 500\). Interval.
- Clamp function: project \(x\) onto \([a,b]\). Describe piecewise using inequalities.
- 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.
Extra exercises
- Solve \(3-|2x+1|\ge 0\).
- Express \(\{x: |x|\ge 2\}\cap \{x: x<5\}\) in interval unions.
- Prove: if \(a\le b\) and \(c>0\) then \(ac\le bc\).
- Solve \(\frac{2x-1}{5}<\frac{x+1}{2}\) carefully.
- 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\).