Write and evaluate a piecewise function
Quick review (2 minutes)
Picture a parking sign with different prices for different lengths of stay.
Choose the condition your input satisfies, then use that piece's formula.
The whole domain is the union of the pieces' domains; each allowed input must receive one output.
1. Identify what the input measures and where the rule changes.
2. Write a formula for each region and state its condition with the boundary ownership explicit.
3. Include any context limits, such as positive whole-number people counts.
4. To evaluate, compare the input with all conditions before using a formula.
5. Substitute into the selected formula and follow the order of operations.
6. At a boundary, check which condition includes equality. Do not add the outputs of different pieces.
A data plan has C(g) = 25 for 0 < g < 2, and C(g) = 25 + 10(g − 2) for g ≥ 2. Here g is gigabytes and C is dollars. Find C(1.5) and C(4).
C(1.5) = $25.
C(4) = $45.
Using a formula because it is familiar before reading its condition. At g = 2 the data plan uses the g ≥ 2 piece. At g = 0 neither piece applies.
1. Identify what the input measures and where the rule changes.
2. Write a formula for each region and state its condition with the boundary ownership explicit.
3. Include any context limits, such as positive whole-number people counts.
4. To evaluate, compare the input with all conditions before using a formula.
5. Substitute into the selected formula and follow the order of operations.
6. At a boundary, check which condition includes equality. Do not add the outputs of different pieces.
Function
A rule assigning exactly one output to each allowed input. Different inputs may share an output.
Input
The value you choose or supply to a function before its rule calculates an output.
Output
The result a function produces from a chosen allowed input.
Formula
A mathematical recipe describing how quantities are related or how to calculate a result.
Domain
The set of all inputs allowed for a function, considering its arithmetic and any stated context or restrictions.
Range
The set of all outputs a function actually produces from its allowed inputs.
Coordinate
One number describing a point's position along an axis. In (x, y), x is horizontal and y is vertical.
Discrete function
A function with separate allowed inputs, such as whole-number counts. Its graph has isolated points rather than every intervening input.
Continuous function
A function with no break at its domain points. On an interval, its graph has no jumps or holes between allowed inputs.
Undefined
Having no assigned value in the number system or function being used. Division by zero is undefined in real arithmetic.
Inequality
A comparison using <, >, ≤ or >=. It describes which amount is smaller or larger and whether equality is allowed.
Nonnegative
Greater than or equal to 0. It includes positive numbers and 0, but excludes negative numbers.
Positive
Strictly greater than 0. Zero is excluded.
Negative
Strictly less than 0. Negative numbers lie to the left of 0 on a number line.
Number line
A straight line placing real numbers in order, with smaller numbers left and greater numbers right.
Interval
A set containing every real number between its limits, with endpoints included or excluded as specified. It may extend without bound.
Bracket
The interval symbols [ and ], indicating that the adjacent finite endpoint belongs to the set.
Graph
A picture of points representing input and output pairs, usually with inputs horizontal and outputs vertical.
Magnitude
A real number's size without its sign, measured by its absolute value or distance from 0.
Modulus
Another name for the absolute value of a real number, its nonnegative distance from 0.
Piecewise function
A function using different formulas on specified parts of its domain. Each allowed input must have exactly one output.
Piece
One formula together with the input condition telling you where it is used in a piecewise function.
Boundary
An input where an interval starts or ends, or where a piecewise condition changes. Check which condition includes it.
Tax bracket
An income interval with its assigned tax rule. In a marginal model, a higher rate applies only to income within its bracket.
1 In plain words
Picture a parking sign with different prices for different lengths of stay. You first read which time interval your stay belongs to. Only then do you calculate its price. A piecewise function works this way: one rule applies on one part of its domain, and another rule applies somewhere else. Each part is called a piece. The conditions beside the formulas tell you which lane to choose. A boundary is the input where a lane starts or stops. Look carefully at whether equality is allowed there. The price rule for the next lane may be different, even though the two inputs are very close.
2 Picture it
C(g) = 25 if 0 < g < 2
C(g) = 25 + 10(g − 2) if g ≥ 2
Choose the condition first
Reminder
Reminder: Order of operations, Percentages, Negating a negative
- Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
- Percentages. 10% of 10000 is × 10000 = 1000.
- Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
3 Why
A function must give one output for each allowed input. Several formulas can work together if their conditions tell you which formula supplies that output. The domain is the union of the allowed branch inputs because an input may belong to any available piece. Boundary conditions show which inputs are assigned or omitted, and help you spot two conflicting outputs. A deliberate gap is allowed outside the domain. Some rules meet at the same height, like the data plan at its threshold. Other rules jump to a new height. Meeting is not required; a single assigned output is required.
4 The rule
Choose the condition your input satisfies, then use that piece's formula.
The whole domain is the union of the pieces' domains; each allowed input must receive one output.
The same idea, five ways
Say choose the condition, then calculate its formula.
A piecewise function assigns different formulas to specified parts of its domain.
- C(g) = 25 if 0 < g < 2
- C(g) = 25 + 10(g − 2) if g ≥ 2
- Domain: {g | g > 0} = (0, ∞)
- Graph words: each formula is used only on its own input interval
A price sign routes your purchase to the rate for its size.
C(g) = 25 if 0 < g < 2
C(g) = 25 + 10(g − 2) if g ≥ 2
Choose the condition first
The same idea, other ways
A museum sign can say $5 per person for a small group and $50 for a larger group. The group size chooses the rule. You do not pay both listed prices.
Send the input to the condition it satisfies, then let that branch calculate the output. A boundary value belongs wherever equality is included.
|−11| uses the rule −x because its input is negative, giving 11. |11| uses x because its input is nonnegative, also giving 11. Two processes produce the same kind of distance.
If an input receives different answers from overlapping conditions, the rule is not a function at that input. Usual piecewise notation avoids this by assigning each input to one branch. If overlapping formulas agree, they still give only one output.
Part 1: Absolute value as two formulas
Absolute value measures how far a number is from zero. This distance is also called its magnitude or modulus. A nonnegative number already tells its distance. A negative number needs its opposite, so the two sides of zero use different formulas.
- |x| = x when x ≥ 0.
- |x| = −x when x < 0.
- −x is positive when x is negative; it does not mean the output is always negative.
- The domain is (−∞, ∞) and the range is [0, ∞).
Reminder
Reminder: Order of operations, Percentages, Negating a negative
- Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
- Percentages. 10% of 10000 is × 10000 = 1000.
- Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say keep a nonnegative input; take the opposite of a negative input.
Absolute value uses the formula matching the input’s sign.
- |x| = x if x ≥ 0
- |x| = −x if x < 0
- Domain: (−∞, ∞)
- Range: [0, ∞)
Your distance from home is nonnegative. At home it is zero; walking either way makes it positive.
Worked example
Absolute value uses the negative-input piece
Write |x| as a piecewise rule and use it to find |−11|.
Show the steps and the answer
|x| = x if x ≥ 0.
|x| = −x if x < 0.
- We need one formula for nonnegative inputs, another for negative inputs, then the output at .Absolute value measures distance from zero, so an input’s sign determines which formula returns that distance.
- For , use .A nonnegative coordinate is already its own distance from zero.
- For x < 0, use .The distance to zero is positive, so negating a negative coordinate gives its length.
- The input satisfies x < 0, so choose .The input's sign selects the piece; you do not use both rules.
- Evaluate .Taking the opposite of a negative number produces the positive distance.
- |x| = x if x ≥ 0.
- |x| = −x if x < 0.
Counterexamples
What it is not, and the tempting wrong moves.
Tips and tricks
- Substitute the whole negative input in parentheses.
Part 2: A museum group discount
For a small tour group, adding one person adds $5 to the bill. At ten people, the group pays a fixed $50. A discrete function here uses whole-number people counts. For the exercise, you extend the rule to real inputs between counts. This particular extension is a continuous function because its graph has no jumps or holes, including at ten.
- Actual small-group charge: 5n for n in {1, 2, …, 9}.
- Actual larger-group charge: 50 for integers n ≥ 10.
- For the textbook continuous drawing, use 0 < n < 10 and n ≥ 10, with domain (0, ∞).
- The actual count domain is {1, 2, 3, …}; a fractional person is not a real group member.
Small group: $5 × n
At least 10 people: $50
Actual n is a positive whole number
Reminder
Reminder: Order of operations, Percentages, Negating a negative
- Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
- Percentages. 10% of 10000 is × 10000 = 1000.
- Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say small groups pay per person; larger groups pay one fixed fee.
Actual groups use positive integer counts; the textbook drawing extends the rule to every positive real input.
- M(n) = 5n if 0 < n < 10
- M(n) = 50 if n ≥ 10
- Actual domain: {1, 2, 3, …}
- Continuous domain: (0, ∞)
- Continuous range: (0, 50]
A cash register switches from per-person pricing to one fixed group fee.
Small group: $5 × n
At least 10 people: $50
Actual n is a positive whole number
Worked example
Textbook: write a museum group-pricing function
A museum charges $5 per person for groups of 1 to 9 people and a fixed $50 for groups of 10 or more. Write the actual pricing rule and the textbook continuous exercise model.
Show the steps and the answer
- We need a pricing formula on each group-size condition, then the actual and continuous input and output sets.The price changes its calculation at a group size of 10; the actual visitor counts and the continuous exercise model use different input sets.
- Use 5n when n is a whole number from 1 through 9.Per person means multiply the number of people by $5.
- Use 50 when n is a whole number at least 10.A fixed group fee stays $50 even when the group is larger.
- The actual domain is {1, 2, 3, …}.A group contains a positive whole-number count of people.
- For a continuous drawing, use 5n on 0 < n < 10 and 50 on .The source asks for a continuous drawing; here we extend the small-group rule over every real input strictly between 0 and 10 so it forms a line segment with an open point at (0, 0).
- The actual range is {5, 10, 15, 20, 25, 30, 35, 40, 45, 50}; the continuous range is (0, 50].Positive integer counts give separate actual prices. In the continuous model, positive inputs can approach 0 without reaching it, so their costs can approach $0 without attaining it. The first branch approaches $50 and the second branch supplies $50 itself.
- Actual rule: M(n) = 5n for n in {1, …, 9}.
- Actual rule: M(n) = 50 for integers n ≥ 10.
- Actual domain: {1, 2, 3, …}.
- Actual range: {5, 10, 15, 20, 25, 30, 35, 40, 45, 50}.
- Textbook continuous model: M(n) = 5n if 0 < n < 10.
- Textbook continuous model: M(n) = 50 if n ≥ 10.
- Continuous domain: (0, ∞).
- Continuous range: (0, 50].
Counterexamples
What it is not, and the tempting wrong moves.
Tips and tricks
- State whether you are using the real counting rule or the continuous exercise model.
Part 3: A fictional marginal tax model
Imagine placing the first portion of income in one basket and the excess in a second basket. The baskets have different percentage charges. Crossing the boundary puts only the added income into the second basket. This is a fictional teaching model, not a statement about a current tax law.
- A tax bracket is an income interval with a specified tax rate in this model.
- For income through $10000, use 10% of that income.
- Above $10000, retain $1000 on the first portion and add 20% of only the excess.
- At $10000 the first branch includes the boundary; the second branch starts above it.
First $10000: 10%
Income above $10000: 20%
Keep the first portion's $1000 tax
Reminder
Reminder: Order of operations, Percentages, Negating a negative
- Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
- Percentages. 10% of 10000 is × 10000 = 1000.
- Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say the first portion and the excess have separate rates.
Only income above the threshold gets the higher rate in this fictional tax model.
- T(i) = 0.10i if 0 ≤ i ≤ 10000
- T(i) = 1000 + 0.20(i − 10000) if i > 10000
- Domain: [0, ∞)
Put the first portion of income and the excess into two baskets with different rates.
First $10000: 10%
Income above $10000: 20%
Keep the first portion's $1000 tax
Worked example
A fictional tax bracket charges only the excess at the higher rate
In this fictional model, income through $10000 is taxed at 10%, and only additional income is taxed at 20%. Write T(i) for i ≥ 0 and find T(15000).
Show the steps and the answer
T(i) = 0.10i if 0 ≤ i ≤ 10000.
T(i) = 1000 + 0.20(i − 10000) if i > 10000.
T(15000) = $2000.
- We need the tax formula in each income bracket and its value at $15000.The lower rate covers the first $10000, and only the excess uses the higher rate.
- For , write .Ten percent is = 0.10 of the income in this first bracket.
- The tax on the first $10000 is .This charge remains part of the total when income enters the second bracket.
- For i > 10000, write .The second rate applies to the income above $10000, not to the whole income.
- At , excess income is .Subtracting the threshold isolates the amount charged at 20%.
- Compute .The total includes tax from both portions of the income.
- T(i) = 0.10i if 0 ≤ i ≤ 10000.
- T(i) = 1000 + 0.20(i − 10000) if i > 10000.
- T(15000) = $2000.
Counterexamples
What it is not, and the tempting wrong moves.
Tips and tricks
- Find the excess amount before applying the second rate.
Part 4: A data plan with a threshold
The plan charges a base amount for usage below two gigabytes. Beyond that threshold, it adds a price for excess usage. The given formula includes two gigabytes in the second branch. It does not assign a price to zero usage, so do not invent one.
- C(g) = 25 for 0 < g < 2.
- C(g) = 25 + 10(g − 2) for g ≥ 2.
- Domain: (0, 2) ∪ [2, ∞) = (0, ∞).
- Range: [25, ∞), because the base charge is reached and arbitrary nonnegative excess charges can be added.
g = 2 belongs to g ≥ 2
C(2) = 25 + 10 × 0 = 25
g = 0 belongs to neither piece
Reminder
Reminder: Order of operations, Percentages, Negating a negative
- Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
- Percentages. 10% of 10000 is × 10000 = 1000.
- Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say a base price plus an extra charge above two gigabytes.
The conditions assign one formula to each positive usage input.
- C(g) = 25 if 0 < g < 2
- C(g) = 25 + 10(g − 2) if g ≥ 2
- Domain: (0, ∞)
- Range: [25, ∞)
Pay a base entrance price, then pay for extra usage beyond what it includes.
g = 2 belongs to g ≥ 2
C(2) = 25 + 10 × 0 = 25
g = 0 belongs to neither piece
Worked example
Piecewise ladder 3: the threshold itself
For the same data-plan rule, find C(2) and decide whether C(0) is defined.
Show the steps and the answer
- We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
- At , the condition 0 < g < 2 is false.A strict inequality excludes its boundary.
- The condition is true, so .The second condition includes equality, and the excess usage is zero.
- At , neither condition is true.Zero is not strictly positive and is not at least 2.
- Report C(0) as undefined for this given rule.No branch assigns an output to zero; a real provider's policy would require a separately supplied rule.
- C(2) = $25.
- C(0) is undefined for the stated function.
Counterexamples
What it is not, and the tempting wrong moves.
Tips and tricks
- Check zero in the given conditions instead of guessing a policy.
5 How
- Identify what the input measures and where the rule changes.
- Write a formula for each region and state its condition with the boundary ownership explicit.
- Include any context limits, such as positive whole-number people counts.
- To evaluate, compare the input with all conditions before using a formula.
- Substitute into the selected formula and follow the order of operations.
- At a boundary, check which condition includes equality. Do not add the outputs of different pieces.
Write or evaluate a piecewise rule
- Identify what the input measures and where the rule changes.
- Write a formula for each region and state its condition with the boundary ownership explicit.
- Include any context limits, such as positive whole-number people counts.
- To evaluate, compare the input with all conditions before using a formula.
- Substitute into the selected formula and follow the order of operations.
- At a boundary, check which condition includes equality. Do not add the outputs of different pieces.
6 Worked example
Worked example
Evaluate a data-plan function
A data plan has C(g) = 25 for 0 < g < 2, and C(g) = 25 + 10(g − 2) for g ≥ 2. Here g is gigabytes and C is dollars. Find C(1.5) and C(4).
Show the steps and the answer
- We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
- For , test 0 < 1.5 < 2.The condition decides which formula applies before any calculation.
- Use the first formula: .Every input strictly between 0 and 2 has the flat charge.
- For , test .This input belongs to the second piece.
- Subtract the included 2 gigabytes: .Only usage above the threshold is charged at the extra rate.
- Calculate .The base charge and the charge for two excess gigabytes must both be paid.
- C(1.5) = $25.
- C(4) = $45.
Ladder: from easy to exam-hard
Try each rung before you open its steps.
Rung 1 of 5
Absolute value uses the negative-input piece
Write |x| as a piecewise rule and use it to find |−11|.
Show the steps and the answer
|x| = x if x ≥ 0.
|x| = −x if x < 0.
- We need one formula for nonnegative inputs, another for negative inputs, then the output at .Absolute value measures distance from zero, so an input’s sign determines which formula returns that distance.
- For , use .A nonnegative coordinate is already its own distance from zero.
- For x < 0, use .The distance to zero is positive, so negating a negative coordinate gives its length.
- The input satisfies x < 0, so choose .The input's sign selects the piece; you do not use both rules.
- Evaluate .Taking the opposite of a negative number produces the positive distance.
- |x| = x if x ≥ 0.
- |x| = −x if x < 0.
Rung 2 of 5
Piecewise ladder 2: a flat-charge input
For C(g) = 25 if 0 < g < 2 and C(g) = 25 + 10(g − 2) if g ≥ 2, find C(1).
Show the steps and the answer
- We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
- Check 0 < 1 < 2.The input fits the condition of the first branch.
- Use .This branch has no variable in its formula, so every input in it has the same cost.
Rung 3 of 5
Piecewise ladder 3: the threshold itself
For the same data-plan rule, find C(2) and decide whether C(0) is defined.
Show the steps and the answer
- We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
- At , the condition 0 < g < 2 is false.A strict inequality excludes its boundary.
- The condition is true, so .The second condition includes equality, and the excess usage is zero.
- At , neither condition is true.Zero is not strictly positive and is not at least 2.
- Report C(0) as undefined for this given rule.No branch assigns an output to zero; a real provider's policy would require a separately supplied rule.
- C(2) = $25.
- C(0) is undefined for the stated function.
Rung 4 of 5
Piecewise ladder 4: usage above the threshold
For the same data plan, find C(6.5).
Show the steps and the answer
- We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
- Since , choose .The input belongs to the excess-usage branch.
- Calculate gigabytes above the included amount.The first two gigabytes are accounted for by the base charge.
- Calculate , then add 25 to get 70.The excess amount is charged at $10 per gigabyte, on top of the base charge.
Rung 5 of 5
Piecewise ladder 5: two boundary owners
Let P(x) = x + 6 if x < −2, P(x) = 7 if −2 ≤ x ≤ 4, and P(x) = 3x − 5 if x > 4. Find P(−5), P(−2), P(4), and P(6).
Show the steps and the answer
- We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
- For , use and get .−5 satisfies the first condition x < −2.
- For , use the constant 7.Equality at −2 is included in the middle condition, not the first.
- For 4, also use the constant 7.Equality at 4 is included in the middle condition, not the last.
- For 6, use and get .6 satisfies x > 4.
- P(4) = 7.
- P(6) = 13.
Counterexamples
What it is not, and the tempting wrong moves.
Tips and tricks
- Memory device: choose the lane, then calculate.
- Underline the condition that contains the boundary's equality sign.
- For a threshold charge, write excess = input − threshold before multiplying by the extra rate.
7 The trap
Using a formula because it is familiar before reading its condition. At g = 2 the data plan uses the g ≥ 2 piece. At g = 0 neither piece applies.
Comes back in
Problems marked OpenStax come from Precalculus 2e by Jay Abramson, published by OpenStax, under the CC BY-NC-SA 4.0 licence. Access for free at https://openstax.org/books/precalculus-2e/pages/1-introduction-to-functions.