Quarry School

Write and evaluate a piecewise function

Explain it like I am five

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.

C(g) = 25 if 0 < g < 2
C(g) = 25 + 10(g − 2) if g ≥ 2
Choose the condition first
The conditions route an input to one formula.
Reminder
  • Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
  • Percentages. 10% of 10000 is 10100 × 10000 = 1000.
  • Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
Why it works. 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.
RuleChoose 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 it

Say choose the condition, then calculate its formula.

Write it

A piecewise function assigns different formulas to specified parts of its domain.

In math
  • 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
Like

A price sign routes your purchase to the rate for its size.

See it
C(g) = 25 if 0 < g < 2
C(g) = 25 + 10(g − 2) if g ≥ 2
Choose the condition first
The conditions route an input to one formula.
The same idea, other ways
As a price sign

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.

As a routing machine

Send the input to the condition it satisfies, then let that branch calculate the output. A boundary value belongs wherever equality is included.

g = 4g >= 2: 25 + 10(g −2)$45inputoutput
An input of 4 is routed to the excess-usage branch.
With a distance

|−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.

Why the conditions matter

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.

.1Absolute 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, ∞).
−4−224246domainrange(0, 0)
Both sides rise away from zero because distance is nonnegative.
Reminder
  • Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
  • Percentages. 10% of 10000 is 10100 × 10000 = 1000.
  • Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say it

Say keep a nonnegative input; take the opposite of a negative input.

Write it

Absolute value uses the formula matching the input’s sign.

In math
  • |x| = x if x ≥ 0
  • |x| = −x if x < 0
  • Domain: (−∞, ∞)
  • Range: [0, ∞)
Like

Your distance from home is nonnegative. At home it is zero; walking either way makes it positive.

See it
−4−224246domainrange(0, 0)
Both sides rise away from zero because distance is nonnegative.
Worked exampleAbsolute value uses the negative-input piece

Write |x| as a piecewise rule and use it to find |−11|.

|x| = x if x ≥ 0.
|x| = −x if x < 0.
|−11| = 11.
These lines record the calculated results and their boundary choices.
  1. We need one formula for nonnegative inputs, another for negative inputs, then the output at −11.Absolute value measures distance from zero, so an input’s sign determines which formula returns that distance.
  2. For x ≥ 0, use |x| = x.A nonnegative coordinate is already its own distance from zero.
  3. For x < 0, use |x| = −x.The distance to zero is positive, so negating a negative coordinate gives its length.
  4. The input −11 satisfies x < 0, so choose −x.The input's sign selects the piece; you do not use both rules.
  5. Evaluate −(−11) = 11.Taking the opposite of a negative number produces the positive distance.
Answer
  • |x| = x if x ≥ 0.
  • |x| = −x if x < 0.
  • |−11| = 11.
Check Both 11 and −11 are eleven units from zero on the number line. At zero the nonnegative branch gives |0| = 0.
Counterexamples: what it is not, and the tempting wrong moves
✗ Not this: The formula −x always gives a negative output.
If x is negative, −x is its positive opposite.
✓ Instead: At x = −11, the branch −x gives −(−11) = 11.
Tips and tricks
  • Substitute the whole negative input in parentheses.
.2A 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
The change in the pricing rule occurs at a count of ten.
Reminder
  • Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
  • Percentages. 10% of 10000 is 10100 × 10000 = 1000.
  • Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say it

Say small groups pay per person; larger groups pay one fixed fee.

Write it

Actual groups use positive integer counts; the textbook drawing extends the rule to every positive real input.

In math
  • 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]
Like

A cash register switches from per-person pricing to one fixed group fee.

See it
Small group: $5 × n
At least 10 people: $50
Actual n is a positive whole number
The change in the pricing rule occurs at a count of ten.
Worked exampleTextbook: 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.

input actual group size noutput M(n), dollars1594510501250↓ evaluate: input given, read the output below it
Whole-number groups choose the per-person or fixed-fee rule; sizes 10 and 12 both have output 50.
0(0, ∞)
The textbook continuous model uses every positive real input; real groups use only positive integer counts.
  1. 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.
  2. Use 5n when n is a whole number from 1 through 9.Per person means multiply the number of people by $5.
  3. Use 50 when n is a whole number at least 10.A fixed group fee stays $50 even when the group is larger.
  4. The actual domain is {1, 2, 3, …}.A group contains a positive whole-number count of people.
  5. For a continuous drawing, use 5n on 0 < n < 10 and 50 on n ≥ 10.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).
  6. 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.
Answer
  • 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].
Check M(9) = $45 and M(10) = $50. The continuous formula would give M(9.5) = $47.50, which explains the drawing but is not a real group size.
Counterexamples: what it is not, and the tempting wrong moves
✗ Not this: A group of 9.5 people is an actual allowed input.
An actual head count must be a whole number, even if the exercise drawing interpolates between counts.
✓ Instead: Actual inputs are positive integers; 9.5 appears only in the chosen continuous drawing.
Tips and tricks
  • State whether you are using the real counting rule or the continuous exercise model.
.3A 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
The higher rate applies to the excess portion rather than to the whole income.
Reminder
  • Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
  • Percentages. 10% of 10000 is 10100 × 10000 = 1000.
  • Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say it

Say the first portion and the excess have separate rates.

Write it

Only income above the threshold gets the higher rate in this fictional tax model.

In math
  • T(i) = 0.10i if 0 ≤ i ≤ 10000
  • T(i) = 1000 + 0.20(i − 10000) if i > 10000
  • Domain: [0, ∞)
Like

Put the first portion of income and the excess into two baskets with different rates.

See it
First $10000: 10%
Income above $10000: 20%
Keep the first portion's $1000 tax
The higher rate applies to the excess portion rather than to the whole income.
Worked exampleA 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).

T(i) = 0.10i if 0 ≤ i ≤ 10000.
T(i) = 1000 + 0.20(i − 10000) if i > 10000.
T(15000) = $2000.
These lines record the calculated results and their boundary choices.
  1. 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.
  2. For 0 ≤ i ≤ 10000, write T(i) = 0.10i.Ten percent is 10100 = 0.10 of the income in this first bracket.
  3. The tax on the first $10000 is 0.10 × 10000 = 1000.This charge remains part of the total when income enters the second bracket.
  4. For i > 10000, write T(i) = 1000 + 0.20(i − 10000).The second rate applies to the income above $10000, not to the whole income.
  5. At i = 15000, excess income is 15000 − 10000 = 5000.Subtracting the threshold isolates the amount charged at 20%.
  6. Compute T(15000) = 1000 + 0.20 × 5000 = 1000 + 1000 = 2000.The total includes tax from both portions of the income.
Answer
  • T(i) = 0.10i if 0 ≤ i ≤ 10000.
  • T(i) = 1000 + 0.20(i − 10000) if i > 10000.
  • T(15000) = $2000.
Check At the threshold, both formulas would produce $1000, so the total does not suddenly jump to 20% of all income. Taxing all $15000 at 20% would incorrectly give $3000.
Counterexamples: what it is not, and the tempting wrong moves
✗ Not this: Charge 20% of the entire $15000 income.
The higher bracket applies only to $5000 above the threshold.
✓ Instead: Keep $1000 on the first $10000 and add $1000 on the excess, for $2000.
Tips and tricks
  • Find the excess amount before applying the second rate.
.4A 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
Equality at the threshold chooses the second branch.
Reminder
  • Order of operations. 25 + 10(4 − 2) means subtract first, multiply next, then add: 25 + 20 = 45.
  • Percentages. 10% of 10000 is 10100 × 10000 = 1000.
  • Negating a negative. −(−11) = 11, so the negative-input absolute value branch gives a positive distance.
The same idea, five ways
Say it

Say a base price plus an extra charge above two gigabytes.

Write it

The conditions assign one formula to each positive usage input.

In math
  • C(g) = 25 if 0 < g < 2
  • C(g) = 25 + 10(g − 2) if g ≥ 2
  • Domain: (0, ∞)
  • Range: [25, ∞)
Like

Pay a base entrance price, then pay for extra usage beyond what it includes.

See it
g = 2 belongs to g ≥ 2
C(2) = 25 + 10 × 0 = 25
g = 0 belongs to neither piece
Equality at the threshold chooses the second branch.
Worked examplePiecewise ladder 3: the threshold itself

For the same data-plan rule, find C(2) and decide whether C(0) is defined.

input goutput C(g), dollars125225445↓ evaluate: input given, read the output below it
Each input column gives the output from the formula assigned to that input; read the branch conditions before using these values.
  1. We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
  2. At g = 2, the condition 0 < g < 2 is false.A strict inequality excludes its boundary.
  3. The condition g ≥ 2 is true, so C(2) = 25 + 10(2 − 2) = 25.The second condition includes equality, and the excess usage is zero.
  4. At g = 0, neither condition is true.Zero is not strictly positive and is not at least 2.
  5. 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.
Answer
  • C(2) = $25.
  • C(0) is undefined for the stated function.
Check The branch domains (0, 2) and [2, ∞) join to (0, ∞). The threshold belongs, while zero does not.
Counterexamples: what it is not, and the tempting wrong moves
✗ Not this: The stated data plan assigns a cost to zero usage.
Neither 0 < g < 2 nor g ≥ 2 includes zero.
✓ Instead: Its domain is (0, ∞), and C(0) is undefined.
Tips and tricks
  • Check zero in the given conditions instead of guessing a policy.
Strategy: step by step
  1. 1. Identify what the input measures and where the rule changes.
  2. 2. Write a formula for each region and state its condition with the boundary ownership explicit.
  3. 3. Include any context limits, such as positive whole-number people counts.
  4. 4. To evaluate, compare the input with all conditions before using a formula.
  5. 5. Substitute into the selected formula and follow the order of operations.
  6. 6. At a boundary, check which condition includes equality. Do not add the outputs of different pieces.
Strategy
Write or evaluate a piecewise rule
1
Does the input satisfy this branch's condition?
YesUse that branch's formula.
NoCheck the next condition.
↓
2
Is the input exactly a boundary?
YesChoose the condition that includes equality.
NoUse the interval containing the input.
↓
3
Does no branch assign an output?
YesThe input is outside the given domain.
NoCalculate the one assigned output.
  1. 1. Identify what the input measures and where the rule changes.
  2. 2. Write a formula for each region and state its condition with the boundary ownership explicit.
  3. 3. Include any context limits, such as positive whole-number people counts.
  4. 4. To evaluate, compare the input with all conditions before using a formula.
  5. 5. Substitute into the selected formula and follow the order of operations.
  6. 6. At a boundary, check which condition includes equality. Do not add the outputs of different pieces.
Worked exampleevaluate 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).

input goutput C(g), dollars1.525225445↓ evaluate: input given, read the output below it
Each input column gives the output from the formula assigned to that input; read the branch conditions before using these values.
  1. We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
  2. For g = 1.5, test 0 < 1.5 < 2.The condition decides which formula applies before any calculation.
  3. Use the first formula: C(1.5) = 25.Every input strictly between 0 and 2 has the flat charge.
  4. For g = 4, test 4 ≥ 2.This input belongs to the second piece.
  5. Subtract the included 2 gigabytes: 4 − 2 = 2.Only usage above the threshold is charged at the extra rate.
  6. Calculate C(4) = 25 + 10 × 2 = 25 + 20 = 45.The base charge and the charge for two excess gigabytes must both be paid.
Answer
  • C(1.5) = $25.
  • C(4) = $45.
Check The second input uses two gigabytes above the threshold, so its $20 excess charge explains why the total is $20 above the flat $25 charge.
Ladder: from easy to exam-hard. Press Try it first on any rung to hide its steps and use them as hints.
Rung 1Absolute value uses the negative-input piece

Write |x| as a piecewise rule and use it to find |−11|.

|x| = x if x ≥ 0.
|x| = −x if x < 0.
|−11| = 11.
These lines record the calculated results and their boundary choices.
  1. We need one formula for nonnegative inputs, another for negative inputs, then the output at −11.Absolute value measures distance from zero, so an input’s sign determines which formula returns that distance.
  2. For x ≥ 0, use |x| = x.A nonnegative coordinate is already its own distance from zero.
  3. For x < 0, use |x| = −x.The distance to zero is positive, so negating a negative coordinate gives its length.
  4. The input −11 satisfies x < 0, so choose −x.The input's sign selects the piece; you do not use both rules.
  5. Evaluate −(−11) = 11.Taking the opposite of a negative number produces the positive distance.
Answer
  • |x| = x if x ≥ 0.
  • |x| = −x if x < 0.
  • |−11| = 11.
Check Both 11 and −11 are eleven units from zero on the number line. At zero the nonnegative branch gives |0| = 0.
Rung 2Piecewise 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).

input goutput C(g), dollars1251.525225↓ evaluate: input given, read the output below it
Each input column gives the output from the formula assigned to that input; read the branch conditions before using these values.
  1. We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
  2. Check 0 < 1 < 2.The input fits the condition of the first branch.
  3. Use C(1) = 25.This branch has no variable in its formula, so every input in it has the same cost.
Answer
C(1) = $25.
Check Do not substitute 1 into the second formula: it is not assigned to this input.
Rung 3Piecewise ladder 3: the threshold itself

For the same data-plan rule, find C(2) and decide whether C(0) is defined.

input goutput C(g), dollars125225445↓ evaluate: input given, read the output below it
Each input column gives the output from the formula assigned to that input; read the branch conditions before using these values.
  1. We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
  2. At g = 2, the condition 0 < g < 2 is false.A strict inequality excludes its boundary.
  3. The condition g ≥ 2 is true, so C(2) = 25 + 10(2 − 2) = 25.The second condition includes equality, and the excess usage is zero.
  4. At g = 0, neither condition is true.Zero is not strictly positive and is not at least 2.
  5. 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.
Answer
  • C(2) = $25.
  • C(0) is undefined for the stated function.
Check The branch domains (0, 2) and [2, ∞) join to (0, ∞). The threshold belongs, while zero does not.
Rung 4Piecewise ladder 4: usage above the threshold

For the same data plan, find C(6.5).

input goutput C(g), dollars2254456.570↓ evaluate: input given, read the output below it
Each input column gives the output from the formula assigned to that input; read the branch conditions before using these values.
  1. We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
  2. Since 6.5 ≥ 2, choose C(g) = 25 + 10(g − 2).The input belongs to the excess-usage branch.
  3. Calculate 6.5 − 2 = 4.5 gigabytes above the included amount.The first two gigabytes are accounted for by the base charge.
  4. Calculate 10 × 4.5 = 45, then add 25 to get 70.The excess amount is charged at $10 per gigabyte, on top of the base charge.
Answer
C(6.5) = $70.
Check Compared with C(4) = $45, the extra 2.5 gigabytes add $25. The difference $70 − $45 = $25 agrees.
Rung 5Piecewise 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).

input xoutput P(x)−51−2747613↓ evaluate: input given, read the output below it
Each input column gives the output from the formula assigned to that input; read the branch conditions before using these values.
  1. We need the outputs for the given inputs, choosing a condition before calculating.State what is being found before choosing the calculation.
  2. For −5, use x + 6 and get −5 + 6 = 1.−5 satisfies the first condition x < −2.
  3. For −2, use the constant 7.Equality at −2 is included in the middle condition, not the first.
  4. For 4, also use the constant 7.Equality at 4 is included in the middle condition, not the last.
  5. For 6, use 3x − 5 and get 3 × 6 − 5 = 18 − 5 = 13.6 satisfies x > 4.
Answer
  • P(−5) = 1.
  • P(−2) = 7.
  • P(4) = 7.
  • P(6) = 13.
Check The middle interval [−2, 4] owns both its endpoints, so −2 and 4 each belong to exactly one branch. On a number line, −5 sits left of −2 and 6 sits right of 4, so each of those uses an outer branch.
Counterexamples: what it is not, and the tempting wrong moves
✗ Not this: At g = 4, use the flat $25 data-plan rule.
The flat branch is assigned only to 0 < g < 2. Four gigabytes belongs to g ≥ 2.
✓ Instead: C(4) = 25 + 10(4 − 2) = $45.
✗ Not this: The given data plan assigns C(0) = $25.
Zero satisfies neither 0 < g < 2 nor g ≥ 2. A missing branch cannot be supplied from a guess.
✓ Instead: C(0) is undefined for the stated rule.
✗ Not this: In the fictional second tax bracket, charge 20% of all $15000.
Only the $5000 excess is assigned the higher rate; the first $10000 retains its 10% charge.
✓ Instead: Tax is $1000 + $1000 = $2000.
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.
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.