What is a piecewise function?
A piecewise function is one function built from two or more rules. Each rule works on its own interval (a part of the x-axis). The intervals must not overlap, so every x gets exactly one output.
We write it with a big brace:
f(x) = x + 2, if x < 1
f(x) = 5 − x, if x ≥ 1
The number where the rule changes (here x = 1) is called the break point or split point.
Evaluating a piecewise function
Two steps, always in this order:
- Where? Look at the conditions and find the interval that contains x.
- What? Put x into that rule only.
For the function above: f(−2): −2 < 1, so use x + 2 → 0. f(1): 1 ≥ 1, so use 5 − x → 4. f(3): 3 ≥ 1 → 2.
Be careful at the break point: check whether the sign is < or ≤.
Graphing: open and closed dots, jumps
Graph each rule only over its own interval, like cutting a piece from a full line. At each end point:
- Closed dot ● – the end point belongs to this piece (≤ or ≥).
- Open dot ○ – the end point does not belong (< or >).
If the pieces meet at the same height, the graph is continuous (no gap). If they end at different heights, the graph has a jump. Each x may have only one closed dot above it, otherwise it is not a function (vertical line test).
Domain and range
Read the domain from the intervals and the range from the heights the pieces reach, using the dots to decide if an end value is included.
Absolute value functions
The absolute value |x| is the distance of x from 0, so it is never negative: |−3| = 3, |3| = 3.
As a piecewise function: |x| = −x if x < 0, and x if x ≥ 0. The graph is a V with its corner (vertex) at (0, 0).
Transformations: y = a|x − h| + k
- h moves the V right (h > 0) or left.
- k moves it up (k > 0) or down.
- a changes the steepness (slopes are a and −a); if a < 0 the V opens downward.
The vertex is (h, k). To solve |x − 2| = 3, split it: x − 2 = 3 or x − 2 = −3, so x = 5 or x = −1.
Step functions
A step function is a piecewise function whose pieces are flat (constant). Its graph looks like stairs.
- Floor / greatest integer ⌊x⌋: the largest whole number ≤ x. ⌊2.7⌋ = 2, ⌊−1.2⌋ = −2.
- Ceiling ⌈x⌉: the smallest whole number ≥ x. ⌈2.1⌉ = 3.
Real step functions: postage by weight band, parking per started hour, mobile plans by GB used. Parking at ₹20 per started hour is fee = 20⌈t⌉ for t > 0.
Try it: a fare table at home
Pick a real tariff, such as a taxi or auto fare (fixed charge for the first 2 km, then a rate per km) or your home electricity slab rates. Write it as a piecewise function. Make a table for 5 values, plot the points on squared paper and mark open and closed dots at the break points. Then check one bill with your rule. In the 3D, set the V in step 6 and predict f(x) before sliding x.
Key formulas and definitions
- f(x) = rule 1 if x in interval 1; rule 2 if x in interval 2 …
- |x| = −x if x < 0; x if x ≥ 0
- y = a|x − h| + k: vertex (h, k), slopes ±a
- ⌊x⌋ = greatest integer ≤ x; ⌈x⌉ = smallest integer ≥ x
- |x − h| = c (c ≥ 0) ⇒ x = h + c or x = h − c
Worked examples
1. f(x) = 3x if x < 2, and x + 4 if x ≥ 2. Find f(0), f(2) and f(5).
f(0): 0 < 2 → 3·0 = 0. f(2): 2 ≥ 2 → 2 + 4 = 6. f(5): 5 ≥ 2 → 5 + 4 = 9.
2. g(x) = 1 if x ≤ 0, and −x if x > 0. Find g(0) and g(0.5).
g(0): 0 ≤ 0 → 1. g(0.5): 0.5 > 0 → −0.5.
3. Find the vertex and the direction of y = −2|x + 1| + 3.
Write it as −2|x − (−1)| + 3, so h = −1, k = 3. Vertex (−1, 3). a = −2 < 0, so the V opens downward and (−1, 3) is the highest point.
4. Is f(x) = x + 1 (x < 2), 3 (x ≥ 2) continuous at x = 2?
Left piece ends at 2 + 1 = 3 (open dot). Right piece starts at 3 (closed dot). Same height, so there is no jump: it is continuous at x = 2.
5. Solve |2x − 1| = 7.
Split: 2x − 1 = 7 → x = 4, or 2x − 1 = −7 → x = −3. Check: |7| = 7, |−7| = 7. Answer x = 4 or x = −3.
6. Electricity costs ₹5 per unit for the first 100 units and ₹7 per unit after that. Write the bill B(u) and find B(160).
B(u) = 5u if 0 ≤ u ≤ 100; B(u) = 500 + 7(u − 100) if u > 100. B(160) = 500 + 7·60 = 500 + 420 = ₹920.
7. Parking costs ₹20 per started hour. Find the fee for 2 h 10 min and for exactly 3 h.
Fee = 20⌈t⌉. 2 h 10 min ≈ 2.17 h → ⌈2.17⌉ = 3 → ₹60. Exactly 3 h → ⌈3⌉ = 3 → ₹60.
Common mistakes
- Putting x into every rule. Use only the rule whose condition x satisfies.
- Getting the dot wrong at a break point: < and > give an open dot, ≤ and ≥ give a closed dot.
- Reading y = |x + 3| as moving right. x + 3 = x − (−3), so the V moves 3 units LEFT.
- Thinking ⌊−1.5⌋ = −1. The floor goes DOWN to the next integer: ⌊−1.5⌋ = −2.