Not every function follows a single formula across its entire domain. Tax rates change at income thresholds. Shipping costs jump at weight limits. A ball's height follows one equation while rising and another while falling. These situations demand functions that switch rules depending on where the input lands.
A piecewise function divides its domain into intervals, assigning a different formula to each piece. The function is defined everywhere it needs to be, but no single expression covers all cases. Instead, a collection of expressions — each with its own territory — combines to form one coherent function.
What is a Piecewise Function
A piecewise function is defined by multiple formulas, each applying to a different part of the domain. Rather than one rule governing all inputs, separate rules govern separate intervals.
The function remains a function — each input still produces exactly one output. But which formula produces that output depends on where the input falls.
A simple example:
f(x)={x+1x2if x<0if x≥0
For negative inputs, use x+1. For non-negative inputs, use x2. At x=−3, the output is −3+1=−2. At x=2, the output is 22=4. At x=0, the boundary, the condition x≥0 applies, giving 02=0.
Each piece can be any type of function — linear, quadratic, constant, radical, or otherwise. The pieces join together at boundary points, sometimes connecting smoothly, sometimes jumping abruptly.
Notation
Piecewise functions use brace notation to display all pieces together. Each line shows a formula paired with its condition:
The conditions specify which inputs use which formula. They typically involve inequalities: x<0, x≥3, 1≤x<4.
The conditions must be mutually exclusive — no input should satisfy more than one condition. Otherwise, the function would have two outputs for some inputs, violating the definition of a function.
The conditions should cover the entire intended domain — every input should satisfy exactly one condition. Gaps in coverage leave the function undefined at some points.
At boundary points, one condition includes the boundary (with ≤ or ≥) and the adjacent condition excludes it (with < or >). This ensures the boundary belongs to exactly one piece.
Example with three pieces:
g(x)=⎩⎨⎧2xx2+15if x<−1if −1≤x≤2if x>2
Evaluating Piecewise Functions
To evaluate a piecewise function at a specific input:
Step 1: Determine which condition the input satisfies.
Step 2: Use the corresponding formula to compute the output.
Only one piece applies to each input. The other formulas are irrelevant for that evaluation.
Let f(x)={3x+2x2−1if x<1if x≥1
Find f(−2): Since −2<1, use 3x+2. f(−2)=3(−2)+2=−4.
Find f(1): Since 1≥1, use x2−1. f(1)=1−1=0.
Find f(4): Since 4≥1, use x2−1. f(4)=16−1=15.
Boundary points require attention. The condition that includes the boundary (with ≤ or ≥) determines which formula to use. At x=1 above, the condition x≥1 applies, not x<1.
Errors often occur at boundaries when the wrong piece is selected. Always check the inequality symbols carefully.
Graphing Piecewise Functions
To graph a piecewise function, graph each piece on its designated interval, then combine them.
Step 1: Identify each piece and its interval.
Step 2: Graph each piece as if it were defined everywhere, but only draw the portion within its interval.
Step 3: Mark endpoints appropriately — solid dot for included endpoints, open dot for excluded endpoints.
For f(x)={x+32x−1if x<1if x≥1:
The first piece is a line with slope 1, drawn for x<1. At x=1, this piece gives 1+3=4, but x=1 is excluded, so place an open dot at (1,4).
The second piece is a line with slope 2, drawn for x≥1. At x=1, this piece gives 2(1)−1=1, and x=1 is included, so place a solid dot at (1,1).
The graph shows two line segments that do not connect — there is a jump at x=1 from height 1 to (approaching) height 4.
The visual reveals discontinuities. Pieces that connect smoothly indicate continuity at that boundary. Pieces that don't connect indicate a jump.
Domain of Piecewise Functions
The domain of a piecewise function is the union of all intervals covered by its pieces.
If the pieces cover all real numbers without gaps, the domain is (−∞,∞).
If the pieces leave gaps, the domain excludes those intervals.
For f(x)={x2xif x≤−1if x≥0:
The first piece covers (−∞,−1]. The second covers [0,∞). The interval (−1,0) is not covered by either piece.
Domain: (−∞,−1]∪[0,∞).
Additionally, each piece must be valid on its interval. A piece involving x−3 on [0,5] would require x≥3 for the formula to work, potentially reducing the effective domain of that piece to [3,5].
The domain is determined by both the stated conditions and the natural restrictions of each formula. Both must be satisfied.
Range of Piecewise Functions
The range of a piecewise function is the union of the ranges of all pieces, restricted to their respective intervals.
Each piece contributes outputs from its portion of the domain. The combined range collects all these outputs.
For f(x)={2x+1if x<0if x≥0:
The first piece is constant at 2 for all x<0. It contributes {2} to the range.
The second piece is linear starting at x=0. At x=0, output is 1. As x→∞, output →∞. This piece contributes [1,∞) to the range.
Combined range: {2}∪[1,∞)=[1,∞) (since 2 is already in [1,∞)).
Finding the range may require analyzing each piece separately — finding minima, maxima, and behavior on each interval — then combining results.
Discontinuities can create gaps in the range if no piece produces certain values, or they can be invisible in the range if different pieces cover those values.
Continuity of Piecewise Functions
A piecewise function is continuous at a boundary point if the two pieces meeting there produce the same value. The graph connects without a jump.
For continuity at x=c where two pieces meet:
x→c−limf(x)=x→c+limf(x)=f(c)
The left piece's limit, the right piece's limit, and the actual value at c must all agree.
For f(x)={x24x−4if x≤2if x>2:
At x=2: Left piece gives 22=4. Right piece as x→2+ gives 4(2)−4=4. Both equal 4.
The function is continuous at x=2. The pieces connect.
For g(x)={x+12x−3if x<3if x≥3:
At x=3: Left piece as x→3− gives 3+1=4. Right piece gives 2(3)−3=3.
The limits differ (4=3), so the function is discontinuous at x=3. There is a jump.
Absolute Value as Piecewise
The absolute value function is the most familiar piecewise function:
∣x∣={x−xif x≥0if x<0
For non-negative inputs, the output equals the input. For negative inputs, the output equals the negation of the input (making it positive).
The graph is V-shaped with vertex at the origin. The right arm has slope 1; the left arm has slope −1. The pieces meet at (0,0) and connect continuously — both pieces give 0 at x=0.
Equations involving absolute values often require piecewise analysis. Solving ∣x−2∣=5 means considering both pieces: x−2=5 (giving x=7) and −(x−2)=5 (giving x=−3).
Step Functions
Step functions are piecewise functions where each piece is constant. The graph consists of horizontal segments with jumps between them — like a staircase.
The floor function ⌊x⌋ returns the greatest integer less than or equal to x:
⌊2.7⌋=2,⌊−1.3⌋=−2,⌊5⌋=5
The graph has horizontal segments at each integer height, jumping up at each integer input. The segment at height n covers [n,n+1) — closed on the left, open on the right.
The ceiling function ⌈x⌉ returns the least integer greater than or equal to x:
⌈2.7⌉=3,⌈−1.3⌉=−1,⌈5⌉=5
The segments cover (n−1,n] — open on the left, closed on the right.
Both functions have jump discontinuities at every integer. The domain is all real numbers; the range is all integers Z.
Step functions model situations with discrete jumps: postage rates by weight, tax brackets, rounding rules.
Real-World Applications
Piecewise functions naturally model situations where rules change at thresholds.
Tax brackets: Income tax rates increase at certain income levels. Income below \10{,}000mightbetaxedat10\%,incomefrom\10,000 to \40{,}000at20\%,andincomeabove\40,000 at 30%.
Shipping costs: Packages under 1 pound cost \5.Packagesfrom1to5poundscost\5 plus \2peradditionalpound.Packagesover5poundscost\13 plus \1.50$ per additional pound.
Utility rates: Electricity might cost one rate for the first 500 kWh and a higher rate beyond that threshold.
Parking fees: First hour free, next two hours at one rate, additional hours at another rate.
In each case, the rule changes at specific boundaries, and the piecewise function captures this structure mathematically.
Writing Piecewise Functions
Constructing a piecewise function from a description or graph requires identifying the pieces and their intervals.
From a graph:
Step 1: Identify distinct segments or curves.
Step 2: Determine the formula for each segment (line, parabola, constant, etc.).
Step 3: Identify the interval each segment covers, noting open or closed endpoints.
Step 4: Write the piecewise notation with each formula and its condition.
From a verbal description:
Step 1: Identify the thresholds where rules change.
Step 2: Write the formula for each region between thresholds.
Step 3: Specify conditions using inequalities.
Example: "A plumber charges \50forthefirsthourand\30 for each additional hour."
Let C(t) be the cost for t hours of work (t>0):
C(t)={5050+30(t−1)if 0<t≤1if t>1
Simplifying the second piece: 50+30t−30=30t+20.
C(t)={5030t+20if 0<t≤1if t>1
Common Mistakes
Several errors recur when working with piecewise functions.
Using the wrong piece at a boundary: At x=3 with conditions x<3 and x≥3, the second piece applies, not the first. The inequality symbols determine which piece owns the boundary.
Overlapping conditions: Writing x≤2 and x≥2 creates overlap at x=2. Both pieces claim this input, making the function ambiguous. Use x<2 and x≥2, or x≤2 and x>2.
Gaps in conditions: Writing x<1 and x>3 leaves [1,3] undefined. Unless this gap is intentional (limiting the domain), conditions should cover all intended inputs.
Assuming continuity: Not all piecewise functions are continuous. Checking whether pieces connect at boundaries is essential — do not assume they do.
Forgetting endpoint markers when graphing: Open and closed dots distinguish included from excluded endpoints. Without them, the graph is incomplete and potentially misleading.
Evaluating all pieces instead of one: Only the piece whose condition the input satisfies should be used. The other formulas do not apply to that input.