Piecewise Function Examples: 43 Problems with Answers

Worked examples of Piecewise Function to try before you open each solution, then practice problems with answers.

Worked Examples

Example 1

easy
Evaluate f(x)={x2x<02x+1x≥0 at x=−3, x=0, and x=4.
Show solution

Answer

f(−3)=9,  f(0)=1,  f(4)=9

First step

1.
For x=−3: since −3<0, use f(x)=x2. So f(−3)=(−3)2=9.

Full solution

  1. 2.
    For x=0: since 0≥0, use f(x)=2x+1. So f(0)=2(0)+1=1.
  2. 3.
    For x=4: since 4≥0, use f(x)=2x+1. So f(4)=2(4)+1=9.
In a piecewise function, the domain is partitioned into intervals, each with its own rule. The key skill is identifying which interval the input belongs to before applying the corresponding formula.

Example 2

medium
Determine whether f(x)={x+1x<23x=22x−1x>2 is continuous at x=2.

Example 3

medium
Find the value of a that makes f(x)={ax+1x≤2x2−1x>2 continuous at x=2.

Example 4

medium
Determine whether f(x)={x2+1x<12xx≥1 is continuous at x=1.

Example 5

medium
For what value of k is f(x)={kx+1x≤13x−1x>1 continuous at x=1?

Example 6

medium
A shipping company charges $5 for packages up to 2 lb, $8 for packages over 2 lb but at most 10 lb, and $12 for packages over 10 lb. Write the cost C(w) as a piecewise function.

Example 7

hard
Find a and b so that f(x)={ax+bx<1x21≤x≤2bx+2x>2 is continuous everywhere.

Example 8

hard
The greatest integer (floor) function is ⌊x⌋. Express ⌊x⌋ on [0,3) as a piecewise function.

Example 9

hard
Find all values of c such that f(x)={cx2+1x≤12cx+3x>1 is continuous at x=1.

Example 10

challenge
Find a and b so that f(x)={x2+ax≤1bx+21<x<35x≥3 is continuous everywhere.

Practice Problems

Try each one, then open the solution to compare your method.

Example 1

easy
Given g(x)={−xx<−1x2−1≤x≤25x>2, evaluate g(−2), g(1), and g(3).

Example 2

hard
Find the value of c so that f(x)={cx+1x≤3x2−2x>3 is continuous at x=3.

Example 3

easy
For f(x)={xx<0x+1x≥0, find f(−2).

Example 4

easy
For the same f, find f(3).

Example 5

easy
For f(x)={5x≤12xx>1, find f(1).

Example 6

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

Example 7

easy
In the absolute value ∣x∣={xx≥0−xx<0, find ∣−5∣.

Example 8

easy
How many pieces does f(x)={1x<020≤x<33x≥3 have?

Example 9

easy
Should the intervals of a piecewise function overlap?

Example 10

easy
For f(x)={x2x≤210x>2, find f(2).

Example 11

medium
For f(x)={x+1x<2x2x≥2, is f continuous at x=2?

Example 12

medium
For f(x)={2xx<1x+1x≥1, is f continuous at x=1?

Example 13

medium
Evaluate f(−1)+f(2) for f(x)={3xx<0x2x≥0.

Example 14

medium
A taxi charges $3 for the first mile and $2 per mile after. Write the cost for m>1 miles.

Example 15

medium
For f(x)={−xx<0x20≤x≤24x>2, find f(0) and f(2).

Example 16

medium
The step function f(x)=⌊x⌋ (greatest integer). Find f(2.7) and f(−1.2).

Example 17

medium
Find the domain of f(x)={x0≤x≤48−xx>4.

Example 18

medium
Does f(x)={1x≤0x+1x>0 have a jump at x=0?

Example 19

medium
For f(x)={x2x<05x=02xx>0, find f(0).

Example 20

challenge
Find a so that f(x)={ax+1x<2x2x≥2 is continuous at x=2.

Example 21

challenge
Express f(x)=∣x−3∣ as a piecewise function and find f(1).

Example 22

challenge
For f(x)={x2x<12x−1x≥1, find all x with f(x)=1.

Example 23

easy
For f(x)={2xx<1x+3x≥1, find f(0).

Example 24

easy
For the same f above, find f(5).

Example 25

easy
A function is f(x)=1 on x<0, f(x)=2 on 0≤x<5, and f(x)=3 on x≥5. Find f(5).

Example 26

easy
For f(x)={x+2x≤03xx>0, find f(0).

Example 27

medium
A taxi charges $3 base plus $0.50 per mile for the first 5 miles and $0.30 per additional mile. Write the fare as a piecewise function of miles m.

Example 28

medium
For f(x)={x+3x<0x20≤x≤39x>3, find f(−1)+f(2)+f(4).

Example 29

medium
Solve f(x)=4 for f(x)={2x+6x<0x2x≥0.

Example 30

medium
Sketch (describe) the graph of f(x)={−1x<00x=01x>0.

Example 31

medium
For f(x)={3−xx<12x=1x2+1x>1, find the limits lim⁡x→1− and lim⁡x→1+.

Example 32

hard
Solve f(x)=5 for f(x)={x+2x<3x2−4x≥3.

Example 33

hard
For f(x)={2x+1x<0x2−3x≥0, find the range on [−2,2].

What to focus on

Core idea: A piecewise function uses different formulas on different input intervals; the input decides which one applies.

Common stuck point: The procedure for piecewise function is the easy part; the trap is evaluating with the wrong piece. Asking "Does the formula used depend on which interval the input falls into?" first is what keeps a correct-looking calculation from being attached to the wrong concept.

Ask yourself: Does the formula used depend on which interval the input falls into?

Concept recap

A piecewise function is defined by different formulas on different non-overlapping intervals of its domain, with the applicable formula determined by the input value.

A piecewise function is like the speed-limit zones along a road: your position decides which limit applies, and only one sign governs any stretch. Where two zones meet, the limits may match or change abruptly, just as pieces can join or jump.

Read the full lesson on Piecewise Function

Piecewise Function is covered with related ideas in the guide Functions and Graphs: Complete Foundations for Algebra and Calculus.

Background knowledge

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

function definitiondomain