A piecewise-defined function uses different formulas on different intervals of the domain. These functions model situations where the rule changes depending on the input — tax brackets, shipping rates, overtime pay, and utility billing all follow piecewise patterns.
Evaluating Piecewise Functions
To evaluate a piecewise function at a specific input, first determine which piece contains that input, then apply the corresponding formula.
Worked Example 1: Three-Piece Function
f(x)=⎩⎨⎧x2+135x−7if x<−1if −1≤x≤2if x>2
Evaluate at several inputs:
f(−3): Since −3<−1, use the first piece: f(−3)=(−3)2+1=10
f(−1): Since −1≤−1≤2, use the second piece: f(−1)=3
f(0): Since −1≤0≤2, use the second piece: f(0)=3
f(2): Since −1≤2≤2, use the second piece: f(2)=3
f(5): Since 5>2, use the third piece: f(5)=5(5)−7=18
Common mistake: At boundary points (like x=−1 and x=2), pay close attention to whether the inequality is strict (<, >) or non-strict (≤, ≥). Each x-value belongs to exactly one piece.
Graphing Piecewise Functions
To graph a piecewise function:
Graph each piece on its restricted interval
Use a filled dot at endpoints included in the piece (≤ or ≥)
Use an open dot at endpoints excluded from the piece (< or >)
Check whether the pieces connect at boundary points
Continuity at Boundaries
A piecewise function is continuous at a boundary if the left and right pieces meet at the same point — no gap, no jump. If they do not meet, there is a jump discontinuity.
For the function f(x) above:
At x=−1: Left piece gives (−1)2+1=2, but the value from the middle piece is 3. Since 2=3, there is a jump discontinuity.
At x=2: Middle piece gives 3, right piece approaches 5(2)−7=3. Since both equal 3, the function is continuous here.
Worked Example 2: Graphing a Continuous Piecewise Function
g(x)={−x+4x2−2x+2if x≤2if x>2
At the boundary x=2: left piece gives −2+4=2, right piece gives 4−4+2=2. Both match, so g is continuous at x=2.
For x≤2: graph the line y=−x+4 with a filled dot at (2,2)
For x>2: graph the parabola y=x2−2x+2 starting just right of x=2 (open dot not needed since pieces connect)
Absolute Value as a Piecewise Function
The absolute value function is the most common piecewise function:
∣x∣={x−xif x≥0if x<0
More generally, for any expression inside:
∣f(x)∣={f(x)−f(x)if f(x)≥0if f(x)<0
Worked Example 3: Rewriting Absolute Value
Rewrite h(x)=∣2x−6∣ as a piecewise function.
Find where the expression inside changes sign: 2x−6=0⟹x=3.
When x≥3: 2x−6≥0, so h(x)=2x−6
When x<3: 2x−6<0, so h(x)=−(2x−6)=−2x+6
h(x)={2x−6−2x+6if x≥3if x<3
Worked Example 4: Solving an Absolute Value Equation via Piecewise
Solve ∣3x+1∣=7.
By the piecewise definition: either 3x+1=7 or 3x+1=−7.
Case 1:3x+1=7⟹3x=6⟹x=2
Case 2:3x+1=−7⟹3x=−8⟹x=−38
Solutions:x=2 or x=−38.
The Greatest Integer (Floor) Function
The greatest integer function (also called the floor function) is written ⌊x⌋ or [[x]]. It returns the largest integer that is less than or equal to x.
x
⌊x⌋
3.7
3
3
3
−1.2
−2
−4
−4
0.99
0
Warning: For negative numbers, the floor is not simply truncation. ⌊−1.2⌋=−2, not −1, because −2 is the largest integer ≤−1.2.
The graph of y=⌊x⌋ is a step function — horizontal segments with jumps at every integer. Each segment is closed on the left and open on the right: on the interval [n,n+1), the output is n.
Worked Example 5: Floor Function Application
A parking garage charges $3 per hour, rounded up to the next full hour. The cost function is:
C(t)=3⌈t⌉=3(−⌊−t⌋)
where ⌈t⌉ is the ceiling function. For t=2.5 hours: C(2.5)=3(3)=9. You pay for 3 full hours even though you only used 2.5.
Real-World Piecewise Models
Tax Brackets
Federal income tax (simplified example) uses a piecewise structure:
Problem 3: Determine whether h(x)={3x−1x2+1if x≤2if x>2 is continuous at x=2.
Left piece at x=2: 3(2)−1=5.
Right piece as x approaches 2 from the right: (2)2+1=5.
Since both values are 5, the function is continuous at x=2.
Answer: Continuous at x=2 because both pieces give the value 5.
Problem 4: Evaluate ⌊4.9⌋, ⌊−3.1⌋, and ⌊7⌋.
⌊4.9⌋=4 (largest integer ≤4.9)
⌊−3.1⌋=−4 (largest integer ≤−3.1 is −4, not −3)
⌊7⌋=7 (already an integer)
Answer:4, −4, 7.
Problem 5: A cell phone plan charges $30 for the first 2 GB, then $10 per GB (or fraction thereof) after that. Write the cost function C(g) for g GB of data and find the cost for 3.5 GB.
C(g)={3030+10⌈g−2⌉if 0<g≤2if g>2
For g=3.5: ⌈3.5−2⌉=⌈1.5⌉=2, so C(3.5)=30+10(2)=50.
Answer: The cost for 3.5 GB is $50.
Key Takeaways
A piecewise function uses different rules on different parts of the domain — each input belongs to exactly one piece
At boundary points, the inequality determines which piece applies
The function is continuous at a boundary only if the left and right pieces produce the same output there
The absolute value function is piecewise: ∣f(x)∣=f(x) when f(x)≥0 and −f(x) otherwise
The floor function ⌊x⌋ returns the greatest integer ≤x — watch out for negative values
Real-world piecewise models include tax brackets, tiered pricing, shipping rates, and utility billing
To find the domain or range, analyze each piece on its interval and combine results