On this concept: Formula

Not sure which lesson to do first? Find your level and get a plan →

Math · Advanced Functions · Grade 9-12

Piecewise Function

A piecewise function applies different formulas on different non-overlapping pieces of the domain.

f(x)={f1(x)if x∈D1f2(x)if x∈D2

Quick Answer

A piecewise function applies different formulas on different non-overlapping pieces of the domain. Use one when a rule switches at a threshold: income tax brackets, postage by weight band, a phone plan that charges extra after 5 GB, or absolute value, which negates negative inputs and leaves the rest alone. To evaluate, find which interval the input falls in and use only that piece. The inequality signs at each boundary say which piece owns the endpoint, and neighbouring pieces may join up or jump.

Why This Matters

Many real rules are several formulas stitched together. A phone bill of $20 for up to 5 GB plus $8 per extra GB cannot be one straight line, because the cost is flat at first and then climbs. Reading pieces and boundaries correctly lets you compute charges, graph jumps honestly, and later test whether a function is continuous where its pieces meet.

Intuitive Explanation

A phone plan costs $20 a month for up to 5 GB of data, then $8 for each extra GB. For g gigabytes, C(g)=20 when 0≤g≤5, and C(g)=20+8(g−5) when g>5. Using 3 GB costs $20; using 7 GB costs 20+8(2)=36 dollars. The bill follows two different rules, and which rule applies depends only on where g falls.

Brace notation lists each formula with its condition. To evaluate, locate the input first, then use that piece alone. The conditions must not overlap, or one input would get two outputs. At each boundary exactly one piece includes the endpoint (≤ or ≥) and its neighbour excludes it (< or >); on a graph that is a closed dot on one side and an open dot on the other.

Pieces can join or jump. In the phone plan both rules give $20 at g=5, so the graph is unbroken, with a corner. Postage priced at $1.50 up to 20 g and $2.80 above leaps upward at 20 g. A graph that merely bends, such as x2, is not piecewise, since one formula draws the whole curve. Piecewise means the rule itself changes at a threshold.

Think of it like this. 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.

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


When to Use

Use a piecewise function when a rule changes at a threshold: 'up to 5 GB', 'for income over $50,000', 'the first hour costs…, each additional hour…', or any absolute value. Write one piece per interval, with no overlaps, and decide which piece owns each boundary. If one formula describes every input, it is a single-formula function; if every piece is a constant, it is a step function, such as postage bands or rounding.

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

How to Recognize It

Before writing or evaluating a piecewise rule, find the threshold values where the situation changes and decide which side owns each one.

  1. Does the price, rate or rule change once a quantity passes a certain value?

    Yes means one piece per stretch, split at that value, as with a plan charging $10 per GB beyond 5 GB. If one rule covers every input, a single-formula function is enough.

  2. Is the output constant within each stretch, jumping only at the breaks?

    Yes means a step function, the flat-pieces special case: postage by weight band, or parking charged per started hour. If any piece slopes, it is a general piecewise function.

  3. Is the input exactly at a boundary, like x=2 in a rule split at 2?

    Yes means read the inequality signs: the piece with ≤ or ≥ owns that input, and the piece with < or > does not. Away from boundaries, only one piece can apply.

  4. Does the formula contain an absolute value, like ∣x−3∣?

    Yes means a hidden piecewise rule split where the inside is zero: ∣x−3∣ is 3−x for x<3 and x−3 for x≥3. Rewriting it this way is how you solve or graph it.

Piecewise Function compared with Single-formula function, Step function, and Absolute value function

Every row is a way to write a rule for outputs, and step and absolute value functions are themselves piecewise, so the labels overlap. Ask how many formulas the domain needs and what they look like: one formula, flat pieces, a split at zero by sign, or general pieces.

Piecewise Function

Meaning
Use this when the rule for the output changes depending on which interval the input falls in.
Key test
Does the formula used depend on which interval the input falls into?
Formula
f(x)={f1(x)if x∈D1f2(x)if x∈D2
Example
For f(x)={x+1x<23xx≥2, find f(2) and f(0).

Single-formula function

Meaning
One rule covers the whole domain, with no interval switching.
Key test
Use when the same expression applies for every input.
Example
f(x)=2x+1 uses one rule everywhere; a piecewise uses several

Step function

Meaning
A piecewise function whose pieces are all constant, jumping between flat levels.
Key test
Use when each interval maps to a single fixed value.
Formula
⌊x⌋
Example
Postage that is $1 up to 1 oz, $2 up to 2 oz is a step function

Absolute value function

Meaning
A specific piecewise function: one rule for negatives, another for non-negatives.
Key test
Use when the split is exactly at 0 by sign.
Formula
∣x∣={xx≥0−xx<0
Example
∣x∣ is the canonical two-piece function

Formula & Notation

f(x)={f1(x)if x∈D1f2(x)if x∈D2
f(x)={f1(x)x∈D1f2(x)x∈D2⋮ where D1∪D2∪⋯=Dom(f) and Di∩Dj=∅ for i≠j

How to read it: f(x)={expr1if condition1expr2if condition2 uses brace notation to define each piece.

Worked Examples

Example 1 — Evaluate a piecewise function

Easy

For f(x)={x+1x<23xx≥2, find f(2) and f(0).
Show the steps and the answer
  1. Locate x=2: it fails x<2 and satisfies x≥2, so it belongs to the second piece.

    A boundary value goes to the piece whose inequality includes equality.

  2. Evaluate there: f(2)=3(2)=6.

    Only the owning piece is used; the first piece would wrongly give 2+1=3.

  3. Locate x=0: 0<2, so use the first piece, f(0)=0+1=1.

    Each input is checked against the conditions before any arithmetic is done.

  4. Notice the jump: just left of 2 the outputs approach 3, but f(2)=6.

    The pieces need not meet, so the graph has an open dot at (2,3) and a closed dot at (2,6).

Answer: f(2)=6 and f(0)=1

Takeaway: Find which condition the input satisfies first, then use only that piece; at a boundary, the ≤ or ≥ decides.

Example 2 — One rule throughout

Standard

Is f(x)=2x+1 a piecewise function?
Show the steps and the answer
  1. Look for conditions: f(x)=2x+1 has one formula and no 'if' clauses.

    A piecewise definition is recognised by its cases, and this rule treats every input the same way.

  2. Test inputs far apart: f(−3)=−5, f(0)=1, f(5)=11, all from the same rule with slope 2.

    The rate never switches, so there is no threshold where the behaviour changes.

  3. Contrast with ∣x∣, which is x for x≥0 and −x for x<0, so its slope switches from −1 to 1 at 0.

    A genuine piecewise function changes its rule at a threshold.

Answer: No — it is a single-formula function

Takeaway: One formula with one behaviour everywhere is not piecewise; look for a threshold where the rule switches.

Example 3 — Find the mistake: who owns the boundary?

Application

Postage for a letter weighing w grams is P(w)={1.500<w≤202.8020<w≤100 dollars. Ana says a letter of exactly 20 g costs $2.80 "because 20 is where the second price starts." Find the mistake and correct it.
Show the steps and the answer
  1. Test w=20 against each condition: 0<20≤20 is true, and 20<20 is false.

    The first piece's ≤ includes 20, and the second piece's strict < leaves it out.

  2. Use the owning piece: P(20)=1.50.

    Each input belongs to exactly one piece, and the inequality signs, not the look of the numbers, decide which.

  3. Check a weight just over the line: P(20.5)=2.80.

    The higher price starts immediately after 20 g, not at 20 g itself.

  4. On a graph, draw a closed dot at (20,1.50) and an open dot at (20,2.80).

    Closed and open dots record which piece owns the boundary.

Answer: A 20 g letter costs $1.50; any weight over 20 g, up to 100 g, costs $2.80.

Takeaway: At a boundary, read the inequality signs: the piece with ≤ or ≥ owns the endpoint, and the piece with < or > does not.

Where You'll See It

  • Income tax with a tax-free allowance

    Suppose income up to $10,000 is untaxed and income above it is taxed at 20%. Then T(x)=0 for x≤10000 and T(x)=0.2(x−10000) for x>10000. Someone earning $25,000 pays 20% of $15,000, which is $3000: only the part above the threshold is taxed.

  • Overtime pay

    A worker earns $18 an hour for the first 40 hours a week and $27 an hour beyond that. Pay is 18h for h≤40 and 720+27(h−40) for h>40, so a 45-hour week earns 720+135=855 dollars.

  • A parking garage sign

    A garage charges $3 for the first hour, $2 for each further hour or part of an hour, and at most $15 a day. A 3.5-hour stay costs 3+2(3)=9 dollars, and from 7 hours on the price stays at $15. Each clause of the sign is one piece of the function.

Common Mistakes

  1. The slip: Evaluating with the wrong piece

    Instead: first locate which interval the input falls in, then use only that formula.

  2. The slip: Ignoring the endpoint inequality

    Instead: ≤ versus < decides which piece owns a boundary value.

  3. The slip: Letting intervals overlap

    Instead: each input must belong to exactly one piece, or it is not a function.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. Let f(x)={2x−1x<3x2x≥3. Find f(1), f(3) and f(4).

    Hint: For each input, decide which interval it is in before computing.

  2. Parking costs C(t)={50<t≤25+3(t−2)t>2 dollars for t hours. Find C(1.5) and C(5).

    Hint: Which piece does each time fall in?

  3. Let g(x)={−xx<040≤x≤2x+1x>2. Find g(−3)+g(2)+g(5).

    Hint: Find each value separately, checking the endpoint at 2 carefully.

  4. Let f(x)={x+4x≤23x−2x>2. Solve f(x)=10.

    Hint: Solve each piece, then check that the answer lies in that piece's interval.

  5. A post office charges $1.00 for letters up to 1 oz, $1.25 for over 1 up to 2 oz, and $1.50 for over 2 up to 3 oz. Is this a step function or a piecewise function with slanted pieces?

    Hint: Within each weight interval, does the price change?

  6. For f(x)={x2x<15−xx≥1, a student says f(1)=1. Find and correct the mistake.

    Hint: Does the input 1 satisfy x<1 or x≥1?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

How do I choose the value of k that makes two pieces join up?

Set the two pieces equal at the boundary. If f(x)=x2f(x)=x^2 for x<2x<2 and f(x)=3x+kf(x)=3x+k for x≥2x\ge 2, the first piece approaches 22=42^2=4 at the boundary and the second gives 6+k6+k there. Solving 6+k=46+k=4 gives k=−2k=-2. With any other kk, the graph jumps at x=2x=2 and the function is not continuous there.

Can moving into a higher tax bracket lower my take-home pay?

Not with marginal brackets, which are a piecewise function whose pieces join up. Only the dollars above each threshold are taxed at the higher rate. If the rate is 10% up to $40,000 and 20% beyond, a salary of $41,000 pays 0.1(40000)+0.2(1000)=42000.1(40000)+0.2(1000)=4200 dollars in tax, just $200 more than a salary of $40,000 does. The extra $1,000 still leaves $800 more in your pocket.

When do I draw an open dot and when a closed dot?

Graph each piece only over its own interval, as if the rest of its line were erased. At each boundary, use a closed dot for the piece whose inequality includes the endpoint, with ≤\le or ≥\ge, and an open dot for the piece that excludes it, with << or >>. If both pieces arrive at the same point, the dots overlap and the graph looks unbroken.

Can a piecewise function have more than two pieces, or pieces that are curves?

Yes to both. A tax system may have five brackets, and a piece can be any formula: a skateboard ramp might be modelled as the curve 0.1x20.1x^2 for 0≤x<100\le x<10 followed by a flat deck at height 10 for 10≤x≤2010\le x\le 20. The only rules are that the intervals do not overlap and that every input in the domain belongs to some piece.

Learning Path

← Before

FunctionDomain
Piecewise Function

You are here

You need Function and Domain, because each piece is a rule on part of the domain. Piecewise functions add conditions, boundary ownership and graphs that can join or jump. Next, Absolute Value is the most-used piecewise function, ∣x∣=x or −x, and Step Function Intuition covers rules that stay flat and then jump, like parking fees.

See Also