Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Piecewise Functions






Different Rules for Different Regions

Not every function follows a single formula across its entire domain. Tax rates change at income thresholds. Shipping costs jump at weight limits. A ball's height follows one equation while rising and another while falling. These situations demand functions that switch rules depending on where the input lands.

A piecewise function divides its domain into intervals, assigning a different formula to each piece. The function is defined everywhere it needs to be, but no single expression covers all cases. Instead, a collection of expressions — each with its own territory — combines to form one coherent function.



What is a Piecewise Function

A piecewise function is defined by multiple formulas, each applying to a different part of the domain. Rather than one rule governing all inputs, separate rules govern separate intervals.

The function remains a function — each input still produces exactly one output. But which formula produces that output depends on where the input falls.

A simple example:

f(x)={x+1if x<0x2if x0f(x) = \begin{cases} x + 1 & \text{if } x < 0 \\ x^2 & \text{if } x \geq 0 \end{cases}


For negative inputs, use x+1x + 1. For non-negative inputs, use x2x^2. At x=3x = -3, the output is 3+1=2-3 + 1 = -2. At x=2x = 2, the output is 22=42^2 = 4. At x=0x = 0, the boundary, the condition x0x \geq 0 applies, giving 02=00^2 = 0.

Each piece can be any type of function — linear, quadratic, constant, radical, or otherwise. The pieces join together at boundary points, sometimes connecting smoothly, sometimes jumping abruptly.

Notation

Piecewise functions use brace notation to display all pieces together. Each line shows a formula paired with its condition:

f(x)={formula1if condition1formula2if condition2formula3if condition3f(x) = \begin{cases} \text{formula}_1 & \text{if condition}_1 \\ \text{formula}_2 & \text{if condition}_2 \\ \text{formula}_3 & \text{if condition}_3 \end{cases}


The conditions specify which inputs use which formula. They typically involve inequalities: x<0x < 0, x3x \geq 3, 1x<41 \leq x < 4.

The conditions must be mutually exclusive — no input should satisfy more than one condition. Otherwise, the function would have two outputs for some inputs, violating the definition of a function.

The conditions should cover the entire intended domain — every input should satisfy exactly one condition. Gaps in coverage leave the function undefined at some points.

At boundary points, one condition includes the boundary (with \leq or \geq) and the adjacent condition excludes it (with << or >>). This ensures the boundary belongs to exactly one piece.

Example with three pieces:

g(x)={2xif x<1x2+1if 1x25if x>2g(x) = \begin{cases} 2x & \text{if } x < -1 \\ x^2 + 1 & \text{if } -1 \leq x \leq 2 \\ 5 & \text{if } x > 2 \end{cases}

Evaluating Piecewise Functions

To evaluate a piecewise function at a specific input:

Step 1: Determine which condition the input satisfies.

Step 2: Use the corresponding formula to compute the output.

Only one piece applies to each input. The other formulas are irrelevant for that evaluation.

Let f(x)={3x+2if x<1x21if x1f(x) = \begin{cases} 3x + 2 & \text{if } x < 1 \\ x^2 - 1 & \text{if } x \geq 1 \end{cases}

Find f(2)f(-2): Since 2<1-2 < 1, use 3x+23x + 2. f(2)=3(2)+2=4f(-2) = 3(-2) + 2 = -4.

Find f(1)f(1): Since 111 \geq 1, use x21x^2 - 1. f(1)=11=0f(1) = 1 - 1 = 0.

Find f(4)f(4): Since 414 \geq 1, use x21x^2 - 1. f(4)=161=15f(4) = 16 - 1 = 15.

Boundary points require attention. The condition that includes the boundary (with \leq or \geq) determines which formula to use. At x=1x = 1 above, the condition x1x \geq 1 applies, not x<1x < 1.

Errors often occur at boundaries when the wrong piece is selected. Always check the inequality symbols carefully.

Graphing Piecewise Functions

To graph a piecewise function, graph each piece on its designated interval, then combine them.

Step 1: Identify each piece and its interval.

Step 2: Graph each piece as if it were defined everywhere, but only draw the portion within its interval.

Step 3: Mark endpoints appropriately — solid dot for included endpoints, open dot for excluded endpoints.

For f(x)={x+3if x<12x1if x1f(x) = \begin{cases} x + 3 & \text{if } x < 1 \\ 2x - 1 & \text{if } x \geq 1 \end{cases}:

The first piece is a line with slope 11, drawn for x<1x < 1. At x=1x = 1, this piece gives 1+3=41 + 3 = 4, but x=1x = 1 is excluded, so place an open dot at (1,4)(1, 4).

The second piece is a line with slope 22, drawn for x1x \geq 1. At x=1x = 1, this piece gives 2(1)1=12(1) - 1 = 1, and x=1x = 1 is included, so place a solid dot at (1,1)(1, 1).

The graph shows two line segments that do not connect — there is a jump at x=1x = 1 from height 11 to (approaching) height 44.

The visual reveals discontinuities. Pieces that connect smoothly indicate continuity at that boundary. Pieces that don't connect indicate a jump.

Domain of Piecewise Functions

The domain of a piecewise function is the union of all intervals covered by its pieces.

If the pieces cover all real numbers without gaps, the domain is (,)(-\infty, \infty).

If the pieces leave gaps, the domain excludes those intervals.

For f(x)={x2if x1xif x0f(x) = \begin{cases} x^2 & \text{if } x \leq -1 \\ \sqrt{x} & \text{if } x \geq 0 \end{cases}:

The first piece covers (,1](-\infty, -1]. The second covers [0,)[0, \infty). The interval (1,0)(-1, 0) is not covered by either piece.

Domain: (,1][0,)(-\infty, -1] \cup [0, \infty).

Additionally, each piece must be valid on its interval. A piece involving x3\sqrt{x - 3} on [0,5][0, 5] would require x3x \geq 3 for the formula to work, potentially reducing the effective domain of that piece to [3,5][3, 5].

The domain is determined by both the stated conditions and the natural restrictions of each formula. Both must be satisfied.

Range of Piecewise Functions

The range of a piecewise function is the union of the ranges of all pieces, restricted to their respective intervals.

Each piece contributes outputs from its portion of the domain. The combined range collects all these outputs.

For f(x)={2if x<0x+1if x0f(x) = \begin{cases} 2 & \text{if } x < 0 \\ x + 1 & \text{if } x \geq 0 \end{cases}:

The first piece is constant at 22 for all x<0x < 0. It contributes {2}\{2\} to the range.

The second piece is linear starting at x=0x = 0. At x=0x = 0, output is 11. As xx \to \infty, output \to \infty. This piece contributes [1,)[1, \infty) to the range.

Combined range: {2}[1,)=[1,)\{2\} \cup [1, \infty) = [1, \infty) (since 22 is already in [1,)[1, \infty)).

Finding the range may require analyzing each piece separately — finding minima, maxima, and behavior on each interval — then combining results.

Discontinuities can create gaps in the range if no piece produces certain values, or they can be invisible in the range if different pieces cover those values.

Continuity of Piecewise Functions

A piecewise function is continuous at a boundary point if the two pieces meeting there produce the same value. The graph connects without a jump.

For continuity at x=cx = c where two pieces meet:

limxcf(x)=limxc+f(x)=f(c)\lim_{x \to c^-} f(x) = \lim_{x \to c^+} f(x) = f(c)


The left piece's limit, the right piece's limit, and the actual value at cc must all agree.

For f(x)={x2if x24x4if x>2f(x) = \begin{cases} x^2 & \text{if } x \leq 2 \\ 4x - 4 & \text{if } x > 2 \end{cases}:

At x=2x = 2: Left piece gives 22=42^2 = 4. Right piece as x2+x \to 2^+ gives 4(2)4=44(2) - 4 = 4. Both equal 44.

The function is continuous at x=2x = 2. The pieces connect.

For g(x)={x+1if x<32x3if x3g(x) = \begin{cases} x + 1 & \text{if } x < 3 \\ 2x - 3 & \text{if } x \geq 3 \end{cases}:

At x=3x = 3: Left piece as x3x \to 3^- gives 3+1=43 + 1 = 4. Right piece gives 2(3)3=32(3) - 3 = 3.

The limits differ (434 \neq 3), so the function is discontinuous at x=3x = 3. There is a jump.

Absolute Value as Piecewise

The absolute value function is the most familiar piecewise function:

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


For non-negative inputs, the output equals the input. For negative inputs, the output equals the negation of the input (making it positive).

The graph is V-shaped with vertex at the origin. The right arm has slope 11; the left arm has slope 1-1. The pieces meet at (0,0)(0, 0) and connect continuously — both pieces give 00 at x=0x = 0.

Transformed absolute value functions shift the V:

f(x)=x3+2={(x3)+2if x3(x3)+2if x<3={x1if x3x+5if x<3f(x) = |x - 3| + 2 = \begin{cases} (x - 3) + 2 & \text{if } x \geq 3 \\ -(x - 3) + 2 & \text{if } x < 3 \end{cases} = \begin{cases} x - 1 & \text{if } x \geq 3 \\ -x + 5 & \text{if } x < 3 \end{cases}


The vertex moves to (3,2)(3, 2).

Equations involving absolute values often require piecewise analysis. Solving x2=5|x - 2| = 5 means considering both pieces: x2=5x - 2 = 5 (giving x=7x = 7) and (x2)=5-(x - 2) = 5 (giving x=3x = -3).

Step Functions

Step functions are piecewise functions where each piece is constant. The graph consists of horizontal segments with jumps between them — like a staircase.

The floor function x\lfloor x \rfloor returns the greatest integer less than or equal to xx:

2.7=2,1.3=2,5=5\lfloor 2.7 \rfloor = 2, \quad \lfloor -1.3 \rfloor = -2, \quad \lfloor 5 \rfloor = 5


The graph has horizontal segments at each integer height, jumping up at each integer input. The segment at height nn covers [n,n+1)[n, n+1) — closed on the left, open on the right.

The ceiling function x\lceil x \rceil returns the least integer greater than or equal to xx:

2.7=3,1.3=1,5=5\lceil 2.7 \rceil = 3, \quad \lceil -1.3 \rceil = -1, \quad \lceil 5 \rceil = 5


The segments cover (n1,n](n-1, n] — open on the left, closed on the right.

Both functions have jump discontinuities at every integer. The domain is all real numbers; the range is all integers Z\mathbb{Z}.

Step functions model situations with discrete jumps: postage rates by weight, tax brackets, rounding rules.

Real-World Applications

Piecewise functions naturally model situations where rules change at thresholds.

Tax brackets: Income tax rates increase at certain income levels. Income below \10{,}000mightbetaxedat might be taxed at 10\%,incomefrom, income from \10,00010{,}000 to \40{,}000at at 20\%,andincomeabove, and income above \40,00040{,}000 at 30%30\%.

T(x)={0.10xif x100001000+0.20(x10000)if 10000<x400007000+0.30(x40000)if x>40000T(x) = \begin{cases} 0.10x & \text{if } x \leq 10000 \\ 1000 + 0.20(x - 10000) & \text{if } 10000 < x \leq 40000 \\ 7000 + 0.30(x - 40000) & \text{if } x > 40000 \end{cases}


Shipping costs: Packages under 11 pound cost \5.Packagesfrom. Packages from 1to to 5poundscost pounds cost \55 plus \2peradditionalpound.Packagesover per additional pound. Packages over 5poundscost pounds cost \1313 plus \1.50$ per additional pound.

Utility rates: Electricity might cost one rate for the first 500500 kWh and a higher rate beyond that threshold.

Parking fees: First hour free, next two hours at one rate, additional hours at another rate.

In each case, the rule changes at specific boundaries, and the piecewise function captures this structure mathematically.

Writing Piecewise Functions

Constructing a piecewise function from a description or graph requires identifying the pieces and their intervals.

From a graph:

Step 1: Identify distinct segments or curves.

Step 2: Determine the formula for each segment (line, parabola, constant, etc.).

Step 3: Identify the interval each segment covers, noting open or closed endpoints.

Step 4: Write the piecewise notation with each formula and its condition.

From a verbal description:

Step 1: Identify the thresholds where rules change.

Step 2: Write the formula for each region between thresholds.

Step 3: Specify conditions using inequalities.

Example: "A plumber charges \50forthefirsthourand for the first hour and \3030 for each additional hour."

Let C(t)C(t) be the cost for tt hours of work (t>0t > 0):

C(t)={50if 0<t150+30(t1)if t>1C(t) = \begin{cases} 50 & \text{if } 0 < t \leq 1 \\ 50 + 30(t - 1) & \text{if } t > 1 \end{cases}


Simplifying the second piece: 50+30t30=30t+2050 + 30t - 30 = 30t + 20.

C(t)={50if 0<t130t+20if t>1C(t) = \begin{cases} 50 & \text{if } 0 < t \leq 1 \\ 30t + 20 & \text{if } t > 1 \end{cases}

Common Mistakes

Several errors recur when working with piecewise functions.

Using the wrong piece at a boundary: At x=3x = 3 with conditions x<3x < 3 and x3x \geq 3, the second piece applies, not the first. The inequality symbols determine which piece owns the boundary.

Overlapping conditions: Writing x2x \leq 2 and x2x \geq 2 creates overlap at x=2x = 2. Both pieces claim this input, making the function ambiguous. Use x<2x < 2 and x2x \geq 2, or x2x \leq 2 and x>2x > 2.

Gaps in conditions: Writing x<1x < 1 and x>3x > 3 leaves [1,3][1, 3] undefined. Unless this gap is intentional (limiting the domain), conditions should cover all intended inputs.

Assuming continuity: Not all piecewise functions are continuous. Checking whether pieces connect at boundaries is essential — do not assume they do.

Forgetting endpoint markers when graphing: Open and closed dots distinguish included from excluded endpoints. Without them, the graph is incomplete and potentially misleading.

Evaluating all pieces instead of one: Only the piece whose condition the input satisfies should be used. The other formulas do not apply to that input.