What is a piecewise function?
A piecewise function is a function defined by two or more formulas, each used on its own interval of the domain. To find an output, first check which interval the input belongs to, then use that piece’s formula. Absolute value, step functions and tiered prices are common examples.
Piecewise Function in a picture
Formal definition and notation
A piecewise function f is defined by a list of pairs (formula, condition), where the conditions describe disjoint subsets of the domain whose union is the whole domain. For each input x, f(x) is given by the one formula whose condition x satisfies. Because the conditions do not overlap, each input still has exactly one output.
| Symbol | Read it as | Meaning |
|---|---|---|
| f(x) = { | f of x equals, in cases | a large left brace groups the pieces; each line is a formula, then its condition |
| 2x + 1, if x < 1 | 2 x plus 1 if x is less than 1 | one piece: the formula and where it applies |
| open dot | open circle | endpoint not included (condition uses < or >) |
| closed dot | filled circle | endpoint included (condition uses ≤ or ≥) |
Key facts
- The absolute value function is piecewise: |x| = x if x ≥ 0 and |x| = −x if x < 0.
- A graph may jump at a boundary (as in the picture) or connect smoothly; both are allowed.
- The conditions must not overlap. If an input fit two pieces with different outputs, the rule would not be a function.
- Step functions, such as postage that rises at each ounce, are piecewise functions made of horizontal pieces.
- Graph each piece only on its own interval, then mark endpoints with open or closed dots.
How to evaluate a piecewise function
- 1. Locate
- compare the input with each condition, paying attention to < versus ≤ at the boundary
- 2. Substitute
- put the input into that piece’s formula
- 3. Ignore
- the other pieces do not apply to this input
At a boundary such as x = 1, the piece with ≤ or ≥ owns the point. The other piece ends there with an open dot.
Piecewise Function examples, step by step
Example 1: Evaluate at three inputs
For f(x) = x2 if x < 0 and f(x) = 3x + 2 if x ≥ 0, find f(−4), f(0) and f(5).
- −4 < 0: use x2, so f(−4) = 16.
- 0 ≥ 0: use 3x + 2, so f(0) = 2.
- 5 ≥ 0: use 3x + 2, so f(5) = 17.
Answer: f(-4) = 16, f(0) = 2, f(5) = 17.
Example 2: Write absolute value in pieces
Write g(x) = |x − 3| as a piecewise function and find g(1).
- The inside x − 3 is nonnegative when x ≥ 3; then g(x) = x − 3.
- When x < 3, the inside is negative, so take its opposite: g(x) = −(x − 3) = 3 − x.
- 1 < 3, so g(1) = 3 − 1 = 2.
Answer: g(x) = x – 3 if x ≥ 3, and 3 – x if x < 3; g(1) = 2.
Example 3: A tiered price
A parking garage charges 6 dollars for up to 2 hours, then 4 dollars for each hour after that: C(h) = 6 if 0 < h ≤ 2, and C(h) = 6 + 4(h − 2) if h > 2. What do 2 hours and 5 hours cost?
- h = 2 satisfies 0 < h ≤ 2, so C(2) = 6.
- h = 5 satisfies h > 2, so C(5) = 6 + 4(3).
- 6 + 12 = 18.
Answer: 2 hours cost 6 dollars and 5 hours cost 18 dollars.
Common mistakes
At a boundary, read the inequality signs. Only the piece with ≤ or ≥ includes the endpoint.
Each formula is in charge of its own interval only. Outside it, that piece does not exist.
Overlapping conditions can give one input two outputs. Each boundary point belongs to exactly one piece.
Not to be confused with
A system lists equations that must all be true at once. A piecewise function lists formulas, and only one applies for each input.
A step function is one kind of piecewise function whose pieces are all horizontal, like postage prices. A piecewise function can have slanted or curved pieces.
Quick check: 3 questions
f(x) = 4 − x if x ≤ 3, and f(x) = 2x if x > 3. What is f(3)?
Answer: B. 3 satisfies x ≤ 3, so f(3) = 4 − 3 = 1. 6 used the wrong piece, 7 added 4 and 3, and −1 subtracted in the wrong order.Show answer and explanation
Using the same f, what is f(5)?
Answer: D. 5 > 3, so use 2x: f(5) = 10. −1 used the first piece, 9 added 4 and 5, and 7 added 2 and 5 instead of multiplying.Show answer and explanation
On the graph of a piecewise function, the first piece ends at (2, 5) with an open dot, and the second starts at (2, 1) with a closed dot. What is f(2)?
Answer: A. Only the closed dot is part of the graph, so f(2) = 1. The open dot at 5 is excluded. A function cannot have two outputs, and the closed dot shows f(2) is defined.Show answer and explanation
Piecewise Function: frequently asked questions
How do you graph a piecewise function?
Graph each piece only on its own interval. Make a short table for each formula using inputs from its interval, including the boundary. Draw that part of the graph, then mark each boundary with a closed dot if the condition includes it (≤, ≥) or an open dot if it does not (<, >). Finally, check that no vertical line hits two points.
Is absolute value a piecewise function?
Yes. |x| equals x when x ≥ 0 and −x when x < 0. The two pieces meet at the origin to form a V. Writing absolute value in pieces is often the easiest way to solve or graph equations with absolute values, because each piece is an ordinary linear expression.
Can a piecewise function be continuous?
Yes. If the pieces meet at each boundary, the graph has no jump. For example, f(x) = x + 1 if x < 2 and f(x) = 5 − x if x ≥ 2 both give 3 at x = 2, so the graph connects. Pieces that give different values at a boundary make a jump.
Practice and tools
Sources
- Common Core State Standards, High School Functions: Interpreting Functions (HSF-IF.C.7.b)
- OpenStax, College Algebra 2e, 3.2 Domain and Range (piecewise-defined functions)
Updated November 2026·Reviewed by the Effortless Math team·Standards: CCSS HSF-IF.C.7.b
Cite this entry
Effortless Math Team. “Piecewise Function.” Effortless Math Dictionary. Updated November 2026. https://www.effortlessmath.com/math-dictionary/piecewise-function/
Flashcard
Browse all terms in the Math Dictionary · More functions terms · Random term