Piecewise functions
Different rules for different inputs.
A piecewise function uses different formulas on different parts of its domain. To evaluate it, first decide which piece the input belongs to by checking the conditions, then use only that piece’s formula.
Example: f(x) = 2x + 1 if x < 3, and x² if x ≥ 3. Find f(3).
- 3 ≥ 3 — So use the second piece
- 3² = 9 — f(3) = 9
Why it works: Each piece only works on its own part of the inputs. Find which part your x belongs to, then use that piece.
Tip: Watch the boundary: x < 3 and x ≥ 3 treat the value 3 differently.