College Algebra

Piecewise-Defined Functions

Last updated: March 2026 · Advanced
Before you start

You should be comfortable with:

Real-world applications
💰
Retail & Finance

Discounts, tax, tips, profit margins

A piecewise-defined function uses different formulas on different intervals of the domain. These functions model situations where the rule changes depending on the input — tax brackets, shipping rates, overtime pay, and utility billing all follow piecewise patterns.

Evaluating Piecewise Functions

To evaluate a piecewise function at a specific input, first determine which piece contains that input, then apply the corresponding formula.

Worked Example 1: Three-Piece Function

f(x)={x2+1if x<13if 1x25x7if x>2f(x) = \begin{cases} x^2 + 1 & \text{if } x < -1 \\ 3 & \text{if } -1 \leq x \leq 2 \\ 5x - 7 & \text{if } x > 2 \end{cases}

Evaluate at several inputs:

  • f(3)f(-3): Since 3<1-3 < -1, use the first piece: f(3)=(3)2+1=10f(-3) = (-3)^2 + 1 = 10
  • f(1)f(-1): Since 112-1 \leq -1 \leq 2, use the second piece: f(1)=3f(-1) = 3
  • f(0)f(0): Since 102-1 \leq 0 \leq 2, use the second piece: f(0)=3f(0) = 3
  • f(2)f(2): Since 122-1 \leq 2 \leq 2, use the second piece: f(2)=3f(2) = 3
  • f(5)f(5): Since 5>25 > 2, use the third piece: f(5)=5(5)7=18f(5) = 5(5) - 7 = 18

Common mistake: At boundary points (like x=1x = -1 and x=2x = 2), pay close attention to whether the inequality is strict (<<, >>) or non-strict (\leq, \geq). Each xx-value belongs to exactly one piece.

Graphing Piecewise Functions

To graph a piecewise function:

  1. Graph each piece on its restricted interval
  2. Use a filled dot at endpoints included in the piece (\leq or \geq)
  3. Use an open dot at endpoints excluded from the piece (<< or >>)
  4. Check whether the pieces connect at boundary points

Continuity at Boundaries

A piecewise function is continuous at a boundary if the left and right pieces meet at the same point — no gap, no jump. If they do not meet, there is a jump discontinuity.

For the function f(x)f(x) above:

  • At x=1x = -1: Left piece gives (1)2+1=2(-1)^2 + 1 = 2, but the value from the middle piece is 33. Since 232 \neq 3, there is a jump discontinuity.
  • At x=2x = 2: Middle piece gives 33, right piece approaches 5(2)7=35(2) - 7 = 3. Since both equal 33, the function is continuous here.

Worked Example 2: Graphing a Continuous Piecewise Function

g(x)={x+4if x2x22x+2if x>2g(x) = \begin{cases} -x + 4 & \text{if } x \leq 2 \\ x^2 - 2x + 2 & \text{if } x > 2 \end{cases}

At the boundary x=2x = 2: left piece gives 2+4=2-2 + 4 = 2, right piece gives 44+2=24 - 4 + 2 = 2. Both match, so gg is continuous at x=2x = 2.

  • For x2x \leq 2: graph the line y=x+4y = -x + 4 with a filled dot at (2,2)(2, 2)
  • For x>2x > 2: graph the parabola y=x22x+2y = x^2 - 2x + 2 starting just right of x=2x = 2 (open dot not needed since pieces connect)

Absolute Value as a Piecewise Function

The absolute value function is the most common piecewise function:

x={xif x0xif x<0|x| = \begin{cases} x & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases}

More generally, for any expression inside:

f(x)={f(x)if f(x)0f(x)if f(x)<0|f(x)| = \begin{cases} f(x) & \text{if } f(x) \geq 0 \\ -f(x) & \text{if } f(x) < 0 \end{cases}

Worked Example 3: Rewriting Absolute Value

Rewrite h(x)=2x6h(x) = |2x - 6| as a piecewise function.

Find where the expression inside changes sign: 2x6=0    x=32x - 6 = 0 \implies x = 3.

  • When x3x \geq 3: 2x602x - 6 \geq 0, so h(x)=2x6h(x) = 2x - 6
  • When x<3x < 3: 2x6<02x - 6 < 0, so h(x)=(2x6)=2x+6h(x) = -(2x - 6) = -2x + 6

h(x)={2x6if x32x+6if x<3h(x) = \begin{cases} 2x - 6 & \text{if } x \geq 3 \\ -2x + 6 & \text{if } x < 3 \end{cases}

Worked Example 4: Solving an Absolute Value Equation via Piecewise

Solve 3x+1=7|3x + 1| = 7.

By the piecewise definition: either 3x+1=73x + 1 = 7 or 3x+1=73x + 1 = -7.

Case 1: 3x+1=7    3x=6    x=23x + 1 = 7 \implies 3x = 6 \implies x = 2

Case 2: 3x+1=7    3x=8    x=833x + 1 = -7 \implies 3x = -8 \implies x = -\frac{8}{3}

Solutions: x=2x = 2 or x=83x = -\frac{8}{3}.

The Greatest Integer (Floor) Function

The greatest integer function (also called the floor function) is written x\lfloor x \rfloor or [[x]][[x]]. It returns the largest integer that is less than or equal to xx.

xxx\lfloor x \rfloor
3.73.733
3333
1.2-1.22-2
4-44-4
0.990.9900

Warning: For negative numbers, the floor is not simply truncation. 1.2=2\lfloor -1.2 \rfloor = -2, not 1-1, because 2-2 is the largest integer 1.2\leq -1.2.

The graph of y=xy = \lfloor x \rfloor is a step function — horizontal segments with jumps at every integer. Each segment is closed on the left and open on the right: on the interval [n,n+1)[n, n+1), the output is nn.

Worked Example 5: Floor Function Application

A parking garage charges $3 per hour, rounded up to the next full hour. The cost function is:

C(t)=3t=3(t)C(t) = 3\lceil t \rceil = 3(-\lfloor -t \rfloor)

where t\lceil t \rceil is the ceiling function. For t=2.5t = 2.5 hours: C(2.5)=3(3)=9C(2.5) = 3(3) = 9. You pay for 3 full hours even though you only used 2.5.

Real-World Piecewise Models

Tax Brackets

Federal income tax (simplified example) uses a piecewise structure:

T(x)={0.10xif 0x110001100+0.12(x11000)if 11000<x447255147+0.22(x44725)if 44725<x95375T(x) = \begin{cases} 0.10x & \text{if } 0 \leq x \leq 11000 \\ 1100 + 0.12(x - 11000) & \text{if } 11000 < x \leq 44725 \\ 5147 + 0.22(x - 44725) & \text{if } 44725 < x \leq 95375 \end{cases}

This is a marginal tax system: you do not pay 22 cents on every dollar if you earn more than $44,725 — only on the dollars above that threshold.

For taxable income of $60,000:

T(60000)=5147+0.22(6000044725)=5147+0.22(15275)=5147+3360.50=8507.50T(60000) = 5147 + 0.22(60000 - 44725) = 5147 + 0.22(15275) = 5147 + 3360.50 = 8507.50

Utility Billing (Engineering Application)

An electric utility charges:

  • First 500 kWh at $0.08/kWh
  • Next 500 kWh at $0.12/kWh
  • Over 1000 kWh at $0.18/kWh

C(x)={0.08xif 0x50040+0.12(x500)if 500<x1000100+0.18(x1000)if x>1000C(x) = \begin{cases} 0.08x & \text{if } 0 \leq x \leq 500 \\ 40 + 0.12(x - 500) & \text{if } 500 < x \leq 1000 \\ 100 + 0.18(x - 1000) & \text{if } x > 1000 \end{cases}

For 1200 kWh: C(1200)=100+0.18(200)=100+36=136C(1200) = 100 + 0.18(200) = 100 + 36 = 136.

Postage Rates (Retail Application)

A shipping company charges by weight:

S(w)={4.50if 0<w14.50+1.25w1if w>1S(w) = \begin{cases} 4.50 & \text{if } 0 < w \leq 1 \\ 4.50 + 1.25\lceil w - 1 \rceil & \text{if } w > 1 \end{cases}

where ww is weight in pounds and \lceil \cdot \rceil rounds up. A 3.2-pound package: S(3.2)=4.50+1.25(3)=4.50+3.75=8.25S(3.2) = 4.50 + 1.25(3) = 4.50 + 3.75 = 8.25.

Analyzing Domain and Range of Piecewise Functions

For the tax function above:

  • Domain: [0,95375][0, 95375] (this simplified model covers incomes up to $95,375)
  • Range: [0,T(95375)][0, T(95375)] — since each piece is increasing, the range is [0,16290][0, 16290]

To find the range of a general piecewise function, find the range of each piece on its restricted interval, then take the union.

Practice Problems

Test your understanding with these problems. Click to reveal each answer.

Problem 1: Evaluate f(x)={2x+5if x<0x21if 0x312if x>3f(x) = \begin{cases} 2x + 5 & \text{if } x < 0 \\ x^2 - 1 & \text{if } 0 \leq x \leq 3 \\ 12 & \text{if } x > 3 \end{cases} at x=2x = -2, x=0x = 0, x=3x = 3, and x=7x = 7.

f(2)=2(2)+5=1f(-2) = 2(-2) + 5 = 1 (since 2<0-2 < 0)

f(0)=(0)21=1f(0) = (0)^2 - 1 = -1 (since 0030 \leq 0 \leq 3)

f(3)=(3)21=8f(3) = (3)^2 - 1 = 8 (since 0330 \leq 3 \leq 3)

f(7)=12f(7) = 12 (since 7>37 > 3)

Answer: f(2)=1f(-2) = 1, f(0)=1f(0) = -1, f(3)=8f(3) = 8, f(7)=12f(7) = 12.

Problem 2: Rewrite g(x)=4x+8g(x) = |4x + 8| as a piecewise function and evaluate at x=5x = -5 and x=1x = 1.

Find the split point: 4x+8=0    x=24x + 8 = 0 \implies x = -2.

g(x)={4x+8if x2(4x+8)if x<2={4x+8if x24x8if x<2g(x) = \begin{cases} 4x + 8 & \text{if } x \geq -2 \\ -(4x + 8) & \text{if } x < -2 \end{cases} = \begin{cases} 4x + 8 & \text{if } x \geq -2 \\ -4x - 8 & \text{if } x < -2 \end{cases}

g(5)=4(5)8=208=12g(-5) = -4(-5) - 8 = 20 - 8 = 12 (since 5<2-5 < -2)

g(1)=4(1)+8=12g(1) = 4(1) + 8 = 12 (since 121 \geq -2)

Answer: g(5)=12g(-5) = 12, g(1)=12g(1) = 12.

Problem 3: Determine whether h(x)={3x1if x2x2+1if x>2h(x) = \begin{cases} 3x - 1 & \text{if } x \leq 2 \\ x^2 + 1 & \text{if } x > 2 \end{cases} is continuous at x=2x = 2.

Left piece at x=2x = 2: 3(2)1=53(2) - 1 = 5.

Right piece as xx approaches 22 from the right: (2)2+1=5(2)^2 + 1 = 5.

Since both values are 55, the function is continuous at x=2x = 2.

Answer: Continuous at x=2x = 2 because both pieces give the value 55.

Problem 4: Evaluate 4.9\lfloor 4.9 \rfloor, 3.1\lfloor -3.1 \rfloor, and 7\lfloor 7 \rfloor.

4.9=4\lfloor 4.9 \rfloor = 4 (largest integer 4.9\leq 4.9)

3.1=4\lfloor -3.1 \rfloor = -4 (largest integer 3.1\leq -3.1 is 4-4, not 3-3)

7=7\lfloor 7 \rfloor = 7 (already an integer)

Answer: 44, 4-4, 77.

Problem 5: A cell phone plan charges $30 for the first 2 GB, then $10 per GB (or fraction thereof) after that. Write the cost function C(g)C(g) for gg GB of data and find the cost for 3.5 GB.

C(g)={30if 0<g230+10g2if g>2C(g) = \begin{cases} 30 & \text{if } 0 < g \leq 2 \\ 30 + 10\lceil g - 2 \rceil & \text{if } g > 2 \end{cases}

For g=3.5g = 3.5: 3.52=1.5=2\lceil 3.5 - 2 \rceil = \lceil 1.5 \rceil = 2, so C(3.5)=30+10(2)=50C(3.5) = 30 + 10(2) = 50.

Answer: The cost for 3.5 GB is $50.

Key Takeaways

  • A piecewise function uses different rules on different parts of the domain — each input belongs to exactly one piece
  • At boundary points, the inequality determines which piece applies
  • The function is continuous at a boundary only if the left and right pieces produce the same output there
  • The absolute value function is piecewise: f(x)=f(x)|f(x)| = f(x) when f(x)0f(x) \geq 0 and f(x)-f(x) otherwise
  • The floor function x\lfloor x \rfloor returns the greatest integer x\leq x — watch out for negative values
  • Real-world piecewise models include tax brackets, tiered pricing, shipping rates, and utility billing
  • To find the domain or range, analyze each piece on its interval and combine results

Return to College Algebra for more topics in this section.

Last updated: March 29, 2026