Piecewise function grapher
A piecewise function uses different formulas on different parts of its domain. Write each piece with its condition inside braces and the calculator draws exactly the right formula on each interval, breaking the graph where it jumps.
How to use the piecewise function grapher
- 1Write the function with its pieces in braces:
y = {x < 0: -x, x^2}means −x when x < 0 and x² otherwise. - 2Add as many pieces as you need. They are checked in order and the first true condition wins:
y = {x < -1: -x - 1, x < 1: x^2 - 1, 2 - x}. - 3Leave out the final value to make the function undefined elsewhere, or restrict any graph by appending a condition:
y = x^2 {0 < x < 2}. - 4To check whether the pieces meet, define the function as
f(x) = {x < 1: x^2, 2 - x}and typef(1), or evaluate each piece at the breakpoint.
Writing piecewise functions
Each piece has the form condition: value, and pieces are separated by commas. Conditions can use <, ≤ (type <=), >, ≥ and compound ranges such as -1 < x < 1. A last entry without a condition is the “otherwise” value.
The textbook notation
is read as “f(x) equals −x if x is negative, and x² otherwise”. That is the absolute value function on the left joined to a parabola on the right.
Continuity at the breakpoints
A piecewise function is continuous at a breakpoint when the pieces agree there. In the example above, at x = −1 the line gives −(−1) − 1 = 0 and the parabola gives (−1)² − 1 = 0, so the graph joins up. At x = 1 the parabola gives 0 but the last line gives 1, so the graph jumps.
The calculator samples each piece adaptively and breaks the curve at a jump rather than joining the two sides with a vertical line. It does not draw open and closed dots at the ends of pieces, so check your inequality signs to know which side includes the breakpoint.
Where piecewise functions show up
- Tax brackets and tiered pricing, where the rate changes past a threshold.
- Shipping costs and parking fees, which jump in steps.
- Physics: a ball’s height before and after it lands, or a force that switches on at a time.
- Absolute value, floor and sign functions, which are piecewise in disguise.
Examples to try
y = x^2 {0 < x < 2}y = {x < 3: 2x, x < 6: 6 + x, 12}Frequently asked questions
How do I graph a piecewise function?
How do I restrict the domain of a graph?
Does it show open and closed dots at the breakpoints?
How do I check if a piecewise function is continuous?
Related tools and guides
It opens instantly, with no account and nothing to install.