Piecewise Behavior Examples in Math

Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Piecewise Behavior.

This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in Math.

Concept Recap

Piecewise behavior refers to a function that exhibits qualitatively different characteristics in different regions of its domain, like having a different slope or curvature in each region.

Think of the behavior as shifting gears — the function follows one rule until it hits a boundary, then switches to a different rule for the next region.

Read the full concept explanation →

How to Use These Examples

  • Read the first worked example with the solution open so the structure is clear.
  • Try the practice problems before revealing each solution.
  • Use the related concepts and background knowledge badges if you feel stuck.

What to Focus On

Core idea: A function shows piecewise behavior when it follows one rule until a boundary, then switches to a qualitatively different rule.

Common stuck point: The procedure for piecewise behavior is the easy part; the trap is assuming continuity for free. Asking "Does the function switch to a different rule depending on which region of the domain the input is in?" first is what keeps a correct-looking calculation from being attached to the wrong concept.

Sense of Study hint: Ask: Does the function switch to a different rule depending on which region of the domain the input is in?

Worked Examples

Example 1

easy
Write x|x| as an explicit piecewise function, evaluate 4|-4|, 0|0|, and 7|7|, and sketch its graph.

Answer

4=4|-4|=4, 0=0|0|=0, 7=7|7|=7; V-shaped graph with vertex at origin

First step

1
Definition: x={xif x0xif x<0|x| = \begin{cases} x & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases}.

Full solution

  1. 2
    Evaluate: 4=(4)=4|-4| = -(-4) = 4; 0=0|0| = 0; 7=7|7| = 7.
  2. 3
    Graph: two rays meeting at the origin (0,0)(0,0), slope 1-1 for x<0x<0 and slope +1+1 for x0x\geq0, forming a 'V' shape.
The absolute value function is the simplest and most important piecewise function. It measures distance from zero, always returning a non-negative value. Its V-shape has slope ±1\pm1 and vertex at the origin.

Example 2

medium
Solve the equation 2x5=7|2x - 5| = 7 and the inequality 2x5<7|2x - 5| < 7.

Example 3

medium
Solve 3x6=9|3x - 6| = 9.

Example 4

medium
Solve x+24|x + 2| \le 4 and express as an interval.

Example 5

hard
Express f(x)=x21f(x) = |x^2 - 1| as a piecewise function.

Example 6

hard
Find constants aa and bb so that f(x)={x2x<2ax+bx2f(x) = \begin{cases} x^2 & x < 2 \\ ax + b & x \ge 2 \end{cases} is BOTH continuous AND has a matching slope at x=2x = 2.

Example 7

challenge
Express f(x)=max(x,3x)f(x) = \max(x, 3 - x) as a piecewise function and find its minimum.

Practice Problems

Try these problems on your own first, then open the solution to compare your method.

Example 1

easy
Simplify x3+x+1|x-3| + |x+1| for x=2x = -2, x=1x = 1, and x=5x = 5.

Example 2

hard
Express f(x)=x24f(x) = |x^2 - 4| as a piecewise function (without absolute value bars) and identify where f(x)=0f(x) = 0.

Example 3

easy
For f(x)={xx<02xx0f(x)=\begin{cases}x & x<0\\ 2x & x\ge0\end{cases}, find f(3)f(-3).

Example 4

easy
For the same ff, find f(4)f(4).

Example 5

easy
Which piece applies to x=0x=0 in f(x)={1x<05x0f(x)=\begin{cases}1 & x<0\\ 5 & x\ge0\end{cases}?

Example 6

easy
Does a piecewise function have to be continuous?

Example 7

easy
How many rules does a 3-piece function use?

Example 8

easy
For f(x)={x2x<2x+1x2f(x)=\begin{cases}x^2 & x<2\\ x+1 & x\ge2\end{cases}, find f(1)f(1).

Example 9

easy
For the same ff, find f(2)f(2).

Example 10

easy
Does each region of a piecewise function need the same kind of formula?

Example 11

medium
Is f(x)={x+1x<12xx1f(x)=\begin{cases}x+1 & x<1\\ 2x & x\ge1\end{cases} continuous at x=1x=1?

Example 12

medium
Is f(x)={x+1x<12x+3x1f(x)=\begin{cases}x+1 & x<1\\ 2x+3 & x\ge1\end{cases} continuous at x=1x=1?

Example 13

medium
For f(x)={xx<0xx0f(x)=\begin{cases}-x & x<0\\ x & x\ge0\end{cases}, simplify f(x)f(x).

Example 14

medium
Evaluate f(2)+f(3)f(-2)+f(3) for f(x)={x2x<02x1x0f(x)=\begin{cases}x^2 & x<0\\ 2x-1 & x\ge0\end{cases}.

Example 15

medium
A function is f(x)=x2f(x)=x^2 for x1x\le1 and a line for x>1x>1. If the line continues the value smoothly with f(1)=1f(1)=1, what is f(1)f(1)?

Example 16

medium
For f(x)={3x<2x+1x2f(x)=\begin{cases}3 & x<2\\ x+1 & x\ge2\end{cases}, on which region is ff constant?

Example 17

medium
For f(x)={2xx<3x2x3f(x)=\begin{cases}2x & x<3\\ x^2 & x\ge3\end{cases}, is the rate constant on x<3x<3?

Example 18

medium
Find the domain region where f(x)={1/xx<0xx0f(x)=\begin{cases}1/x & x<0\\ \sqrt{x} & x\ge0\end{cases} uses x\sqrt{x}.

Example 19

challenge
Choose aa so that f(x)={ax+1x<2x2x2f(x)=\begin{cases}ax+1 & x<2\\ x^2 & x\ge2\end{cases} is continuous at x=2x=2.

Example 20

challenge
For f(x)={x+kx<13xx1f(x)=\begin{cases}x+k & x<1\\ 3x & x\ge1\end{cases}, find kk making it continuous, then compute f(0)f(0).

Example 21

challenge
A piecewise function is x2x^2 for x<0x<0, 00 for 0x10\le x\le1, and x1x-1 for x>1x>1. Where is it NOT continuous?

Example 22

medium
For f(x)={2x<0x2x0f(x)=\begin{cases}2 & x<0\\ x^2 & x\ge0\end{cases}, find f(5)+f(2)f(-5)+f(2).

Example 23

easy
Evaluate x2|x - 2| at x=5x = 5.

Example 24

easy
Evaluate x2|x - 2| at x=1x = -1.

Example 25

easy
Write 2x+1|2x + 1| as a piecewise function (no absolute value).

Example 26

easy
For f(x)={x+1x<32xx3f(x) = \begin{cases} x+1 & x < 3 \\ 2x & x \ge 3 \end{cases}, find f(3)f(3).

Example 27

easy
Find x+x3|x| + |x - 3| when x=1x = 1.

Example 28

medium
For f(x)={1xx<0x20x23x>2f(x) = \begin{cases} 1-x & x < 0 \\ x^2 & 0 \le x \le 2 \\ 3 & x > 2 \end{cases}, compute f(1)+f(2)+f(5)f(-1) + f(2) + f(5).

Example 29

medium
Is f(x)={x2x<12x1x1f(x) = \begin{cases} x^2 & x < 1 \\ 2x - 1 & x \ge 1 \end{cases} continuous at x=1x = 1?

Example 30

medium
Find aa so that f(x)={ax2x<12x+1x1f(x) = \begin{cases} ax^2 & x < 1 \\ 2x + 1 & x \ge 1 \end{cases} is continuous at x=1x = 1.

Example 31

medium
Find 2.5\lfloor -2.5 \rfloor (floor of 2.5-2.5).

Example 32

medium
Express f(x)=x+xf(x) = |x| + x as a piecewise function.

Example 33

medium
For what xx does x4|x - 4| equal x|x|?

Example 34

hard
For f(x)=x+x4f(x) = |x| + |x - 4|, find the MINIMUM value of ff and where it occurs.

Example 35

hard
For f(x)={2x+1x<0x2+1x0f(x) = \begin{cases} 2x + 1 & x < 0 \\ x^2 + 1 & x \ge 0 \end{cases}, sketch its key features and identify any jump at x=0x = 0.

Example 36

hard
Solve x1=2x5|x - 1| = 2x - 5 (be careful — check both branches and the validity).

Example 37

hard
Sketch the rate of change of f(x)=x3f(x) = |x - 3|. Where is the rate +1+1, and where is it 1-1?

Example 38

challenge
For f(x)=xf(x) = \lfloor x \rfloor, find all xx where f(x)=2f(x) = 2.

Example 39

challenge
Solve x+x2=6|x| + |x - 2| = 6.

Background Knowledge

These ideas may be useful before you work through the harder examples.

piecewise function