Guides / Functions

Piecewise functions: evaluate, graph, and decide which piece owns the boundary

One function, two or three rules, and a condition that says which rule applies. The points get lost at the boundary value, when the input is plugged into every piece, and when a solution is kept even though it came from a piece that doesn't apply to it.

Short answer

Look at the input first. Find the one condition it satisfies, and use only that piece's rule. At a boundary, the piece with ≤ or ≥ owns the value and gets the closed dot; the piece with < or > gets the open dot. To solve f(x) = 5, solve it separately in each piece, then keep only the answers that satisfy that piece's condition.

Why it works

A piecewise function is still a function: every input gets exactly one output. The conditions are written so that they don't overlap and don't leave gaps, which is what makes "exactly one" true. So f(0) for

f(x) = 2x + 1 if x < 0, and f(x) = x2 − 3 if x ≥ 0

can't be both 1 and −3. The condition x < 0 is strict, so 0 isn't in the first piece; it belongs to the second, and f(0) = −3. The same logic draws the graph: at x = 0 the second piece has a solid dot at (0, −3) and the first piece stops just short with an open circle at (0, 1).

Example 1: evaluating

Using the function above, find f(−2), f(0), and f(3).

  1. f(−2) = 2(−2) + 1 = −3−2 < 0, so use the first rule.
  2. f(0) = 02 − 3 = −30 is not less than 0; it satisfies x ≥ 0, so use the second rule. It happens to give the same value as f(−2); that's a coincidence, not a rule.
  3. f(3) = 32 − 3 = 63 ≥ 0, second rule.

Example 2: graphing, with the dots at the jump

Graph g(x) = −x + 1 if x ≤ 2, and g(x) = 2x − 3 if x > 2. Then give the range.

  1. Left piece: (−2, 3), (0, 1), (2, −1)A line with slope −1. The condition includes 2, so (2, −1) gets a closed dot. Draw the line to the left from there.
  2. Right piece: (2, 1) open, (3, 3), (4, 5)Plug x = 2 into 2x − 3 to find where the piece would start: 1. It isn't included, so open circle at (2, 1). Draw the line to the right from there.
  3. Jump at x = 2 from −1 up to 1One closed dot, one open dot, at the same x. A vertical line at x = 2 hits the graph exactly once, at the closed dot.
  4. Range: [−1, ∞)The left piece climbs as x goes left, bottoming out at −1 (included). The right piece climbs from just above 1. Together: everything from −1 up.

Example 3: solving f(x) = 5

Using f from Example 1, solve f(x) = 5.

  1. First piece: 2x + 1 = 5, so x = 2Solve it as usual.
  2. Is 2 < 0? No. Reject.The first rule only applies to negative inputs. x = 2 is an input the first rule never sees, so it isn't a solution.
  3. Second piece: x2 − 3 = 5, so x2 = 8, x = ±2√2Two candidates.
  4. x = 2√22√2 ≈ 2.83 ≥ 0, keep. −2√2 ≈ −2.83 is not ≥ 0, reject. Check: (2√2)² − 3 = 8 − 3 = 5.

The rejected candidates aren't arithmetic errors. They are correct solutions of the wrong equation: for a negative input the function doesn't use x2 − 3, so −2√2 actually gives f(−2√2) = 2(−2√2) + 1 ≈ −4.66, not 5.

Example 4: writing one from a word problem

A phone plan costs $20 per month for up to 2 GB of data, then $8 for each additional GB. Write the cost C(g) for g gigabytes and find C(5).

  1. C(g) = 20 for 0 ≤ g ≤ 2Flat rate. The 2 GB itself is still included in the flat rate, so this condition is ≤.
  2. C(g) = 20 + 8(g − 2) for g > 2The $8 applies only to the gigabytes beyond 2, so the overage is g − 2, not g. The base $20 is still paid.
  3. C(5) = 20 + 8(3) = 445 > 2, so the second piece. Three extra gigabytes at $8 each. Check the boundary: the second formula at g = 2 gives 20 + 0 = 20, matching the flat piece, so this function has no jump.

Common mistakes, and the exact line they happen on

1. Using the wrong piece at the boundary

Find f(0) for the function in Example 1.

  1. f(0) = 2(0) + 1 = 1This is the mistake. The first piece is for x < 0, and 0 isn't less than 0. The second piece's condition, x ≥ 0, is the one that includes it.
  2. f(0) = 02 − 3 = −3Strict inequality: the boundary goes to the other piece.

Exactly one of the two conditions includes the boundary number. Check for the ≤ or ≥, and remember that in the graph it's the piece with the closed dot.

2. Plugging the input into every piece

Find f(3).

  1. f(3) = 7 and f(3) = 6This is the mistake. Both rules were used. 2(3) + 1 = 7 is correct arithmetic for a rule that doesn't apply to 3. A function gives one output; f(3) = 6.

Decide the piece before you compute anything. Write the condition check as its own line, "3 ≥ 0, so second piece," and it stops happening.

3. Two closed dots, or two open dots, at the jump

Graph g from Example 2.

  1. Closed dots at (2, −1) and (2, 1)This is the mistake. Now g(2) has two values and the graph fails the vertical line test. It isn't a function anymore.
  2. Open dots at (2, −1) and (2, 1)The other version. Now g(2) has no value, but the condition x ≤ 2 clearly includes 2. The graph has a hole the function doesn't.

At every boundary, one dot is closed and one is open, matching the ≤ and the < in the conditions. If the two pieces meet at the same height, as in Example 4, the open dot is covered by the closed one and the graph is simply connected.

4. Keeping the solution from the wrong piece

Solve f(x) = 5 (Example 3).

  1. 2x + 1 = 5, x = 2 ✓   x2 − 3 = 5, x = ±2√2 ✓This is the mistake. Three answers reported, two of them from pieces that don't contain them. Plug x = 2 into the actual function: f(2) = 2² − 3 = 1, not 5.
  2. x = 2√2 onlyEach candidate has to satisfy the condition of the piece it came from.

Practice

For 1–3, use g(x) = x2 if x < −1; g(x) = 3 if −1 ≤ x < 2; g(x) = x − 4 if x ≥ 2.

  1. Find g(−3), g(−1), g(2), and g(5).

    Show answer

    g(−3) = 9, g(−1) = 3 (−1 belongs to the middle piece), g(2) = −2 (2 belongs to the last piece), g(5) = 1.

  2. Which dots go at x = −1 and x = 2 on the graph of g?

    Show answer

    At x = −1: open at (−1, 1) from x2, closed at (−1, 3). At x = 2: open at (2, 3), closed at (2, −2).

  3. Solve g(x) = 1.

    Show answer

    First piece: x2 = 1 gives ±1, but neither is less than −1; reject both. Middle piece: 3 = 1, never. Last piece: x − 4 = 1, x = 5, and 5 ≥ 2. Answer: x = 5.

  4. Write h(x) = |x| − 2 as a piecewise function.

    Show answer

    h(x) = x − 2 if x ≥ 0; h(x) = −x − 2 if x < 0. Check x = −3: |−3| − 2 = 1 and −(−3) − 2 = 1.

  5. A taxi charges $3 for any trip up to 1 mile and $2.50 for each additional mile. Write T(m) and find T(4).

    Show answer

    T(m) = 3 if 0 < m ≤ 1; T(m) = 3 + 2.5(m − 1) if m > 1. T(4) = 3 + 2.5(3) = 10.50.