Mathematics · Public reading · 6 min

Piecewise Functions Explained with a Worked Example

Some relationships use one calculation for small quantities and another when the quantity becomes larger. A piecewise function records those rules and states exactly when each rule applies.

Try it before the worked example

Aha! Predict what changes at four labels

At a fictional craft table, the first four complete printed labels each cost 3 tokens. Every complete label after the fourth adds only 2 tokens. What happens to the total as you cross the boundary?

Need a hint before you predict?

Draw four boxes and put 3 tokens inside each. What happens if you add a fifth box that holds 2 more tokens? Do the first four boxes disappear?

The values and graph remain hidden until you make both predictions. If your first attempt is incorrect, you get a helpful hint and one more try before the solution appears.

More piecewise-functions practice with saved progress is coming soon. This free exploration requires no account, stores no answers and never awards mastery or a score.

Understand the idea

The key idea is that each allowed input must match exactly one rule. To interpret a piecewise function correctly, always check the domain, the threshold and the units. A piecewise function is defined using different expressions for different parts of its input domain. The expressions may be simple, but their conditions matter just as much as the arithmetic.

Whole-number input and output values
Input (whole items)Output (model units)
00
13
39
412
514
718
Six separate points show whole labels 0, 1, 3, 4, 5 and 7 with total token costs 0, 3, 9, 12, 14 and 18. There are no defined fractional label inputs.

How to think about it

  • Identify allowed nonnegative whole-number inputs and the units of a contextual quantity.
  • Assign exactly one rule to every allowed input and locate the boundary correctly.
  • Retain accumulated cost when a lower additional-item rate begins.
  • Represent the same piecewise rule with expressions, a table, and a clear verbal explanation.
  • Check input values immediately on either side of a threshold.

Worked example: designing a tiered count rule

Imagine a fictional craft table that produces printed labels. The first four labels each cost 3 tokens. Any label after the fourth costs another 2 tokens. The number n represents a nonnegative whole count of labels, and C(n) is the total cost in tokens.

  1. Define the valid inputs

    For a whole-number count, we should not automatically connect table points with a continuous graph. A model for counting physical items may allow only 0, 1, 2 and so on.

  2. Build two mathematical rules

    For n from 0 through 4, the cost is 3n. For n greater than 4, the first four labels already cost 12 tokens, so the total is 12 + 2(n − 4). C(n) = 3n for nonnegative whole n ≤ 4; C(n) = 12 + 2(n − 4) for whole n > 4

  3. Check the exact change

    At n = 4, use only the first rule: C(4) = 3 × 4 = 12 tokens. At n = 5, use the second: C(5) = 12 + 2(5 − 4) = 14 tokens. The phrase 'after four' means the later rate begins with the fifth item. Do not place n = 4 in both conditions.

  4. Test the resulting table

    A labeled input/output table makes the threshold visible. Use whole-number values on both sides of the change, and keep the original domain restriction. The sample input-output pairs are 0 → 0, 1 → 3, 3 → 9, 4 → 12, 5 → 14, 7 → 18. The model is for whole labels only.

Result: At n = 4 the cost is 12 tokens; at n = 5 it is 14 tokens. The later rate adds to the first-four-label base rather than replacing it.

A common mistake

A common error is to use 2n for every count after four. That forgets the 12 tokens already paid for the first four items. Keep the accumulated base when the additional-item rate starts. Another error is overlapping the two conditions at n = 4. The model must give exactly one cost at each permitted input. Finally, a fractional number of complete labels is outside this particular model.

Try it yourself

Before looking back at the table, calculate the cost for eleven whole labels (one beyond the interactive explorer's 0 to 10 table). Identify the later branch, retain the first-four-label base and add seven extra labels.

Show the worked answer

Answer: C(11) = 12 + 2 × (11 − 4) = 26 tokens.

Eleven is greater than four, so use the later branch. Keep the 12 tokens for the first four whole labels, then add 2 tokens for each of the seven extra labels. The total is 26 tokens.

What comes next?

Apply piecewise functions to compare alternatives. For additional practice, write your own fictional tiered rule, state a whole-number domain, and explain what happens at your chosen threshold. The private learning app can later provide guided exercises and individual feedback after an authorized release.

More reviewed topics will be linked here when available.

Interactive practice is coming later

You can read this complete lesson and check your answer now, for free. Personal accounts and saved progress are not available yet.

No registration is open. This page does not save your answers.