Piecewise Functions Examples- From Basic to Advanced

What Are Piecewise Functions?

A piecewise function is just what it sounds like—a function made up of different pieces, each applying to a specific part of its domain. Instead of one formula that works everywhere, you get multiple formulas for different intervals.

Think of it like your phone bill. One rate for the first 500 minutes, a different rate after that. That's a piecewise function in real life.

The notation looks like this:

f(x) = { formula1 if condition1, formula2 if condition2, formula3 otherwise }

Simple enough. Let's look at actual examples.

Basic Piecewise Functions

Example 1: The Absolute Value

The absolute value function is the classic beginner piecewise function.

f(x) = { x if x ≥ 0, -x if x < 0 }

When x is positive, you get x back. When x is negative, you flip the sign. That's it. The graph looks like a V pointing up at the origin.

Example 2: A Simple Step Function

f(x) = { 0 if x < 0, 1 if x ≥ 0 }

This jumps from 0 to 1 at x = 0. It's called the Heaviside step function. Useful in signal processing and control systems.

Example 3: Basic Cost Function

Imagine a parking garage:

C(x) = { 3 if 0 ≤ x ≤ 1, 5 if 1 < x ≤ 3, 8 if x > 3 }

Where x is hours parked. First hour costs $3, up to 3 hours costs $5, anything beyond that is $8 flat.

Intermediate Piecewise Functions

Example 4: Tax Bracket Function

Here's a simplified income tax structure:

T(x) = { 0.10x if 0 ≤ x ≤ 10000, 1000 + 0.20(x - 10000) if 10000 < x ≤ 50000, 9000 + 0.30(x - 50000) if x > 50000 }

Each bracket applies a different rate only to income within that range. The math builds on previous brackets, not starting fresh.

Example 5: Shipping Cost Calculator

S(w) = { 5.99 if 0 < w ≤ 1, 8.99 if 1 < w ≤ 5, 12.99 if 5 < w ≤ 10, 15.99 + 0.50(w - 10) if w > 10 }

Where w is weight in pounds. The last tier charges per pound beyond 10, so a 15-pound package costs $15.99 + $2.50 = $18.49.

Example 6: Temperature Conversion with Discontinuity

F(C) = { (9/5)C + 32 if C < -40, -40 if C ≥ -40 }

This weird function represents a point where Celsius and Fahrenheit scales intersect (−40°). Below that point, it follows normal conversion. At and above −40°, it stays flat.

Advanced Piecewise Functions

Example 7: Periodic Piecewise with Different Amplitudes

f(x) = { sin(x) if sin(x) ≥ 0, 2sin(x) if sin(x) < 0 }

This doubles the amplitude of negative portions. The graph shows normal sine waves above the x-axis, but they're stretched vertically below it.

Example 8: Non-Linear Boundary Function

f(x) = { x² if x ≤ 2, 4 if 2 < x ≤ 4, 8 - x if x > 4 }

First piece is a parabola opening up. Second piece is a flat horizontal line. Third piece is a declining line. This creates an interesting shape with a plateau in the middle.

Example 9: Conditional Continuity Function

f(x) = { x² if x ≠ 2, 5 if x = 2 }

The function follows x² everywhere except at x = 2, where it jumps to 5. This is a removable discontinuity—you can "fix" it by redefining the point, but mathematically it exists.

Example 10: Three-Variable Dependent Function

f(x) = { |x| if |x| ≤ 1, 1/x² if |x| > 1 }

This uses absolute value to create symmetry. The function behaves one way within the unit interval, another way outside it. Graphically, you get a V shape capped at y=1 in the middle, and hyperbolic decay on the sides.

How to Graph Piecewise Functions

Graphing these takes three steps:

That endpoint handling trips people up constantly. If the condition says "x < 3", x=3 is not included. Open circle. If it says "x ≤ 3", x=3 is included. Closed circle.

Quick Example

Graph f(x) = { 2x if x < 1, x² if x ≥ 1 }

For x < 1: draw the line y = 2x, but stop before x = 1. Put an open circle at (1, 2).

For x ≥ 1: draw the parabola y = x² starting at x = 1. Put a closed circle at (1, 1).

The graph shows a line approaching (1,2) from the left, and a parabola starting at (1,1) on the right. There's a visible jump.

Common Mistakes to Avoid

Piecewise functions don't automatically connect at boundaries. You have to check if the function is continuous by comparing the left-hand limit and right-hand limit at each boundary point.

Comparing Piecewise Function Types

TypeCharacteristicsCommon Uses
Constant segmentsFlat horizontal piecesPricing tiers, step functions
Linear segmentsStraight lines with different slopesTax brackets, shipping rates
Non-linear segmentsCurves like parabolas, hyperbolasPhysics, optimization problems
Mixed segmentsCombines linear and non-linearReal-world modeling
DiscontinuousGaps or jumps at boundariesStep functions, signal processing
ContinuousNo gaps, pieces connect smoothlySmoothing functions, transitions

Practice Problems

Try these to test your understanding:

  1. Write a piecewise function for cell phone plans: $30 for up to 2GB, $0.015 per MB after that
  2. Graph f(x) = { -x if x < 0, x² if 0 ≤ x < 2, 4 if x ≥ 2 } and identify discontinuities
  3. Find f(3) for f(x) = { (x-1)² if x < 2, 2x + 1 if x ≥ 2 }

Answers: 1) f(x) = { 30 if x ≤ 2, 30 + 0.015(1000)(x-2) if x > 2 } (converting GB to MB), 2) jump at x=2, 3) f(3) = 7

Piecewise functions aren't complicated once you stop treating them like one big formula. They're just several small formulas with instructions on when to use each one. Read the conditions first, pick the right piece, plug in your number. That's the whole process.