Back to homeMathematics · Integrated Math II · Change subject
Start for free
Math II · Mathematics
Functions · Elementary functions

Piecewise Functions

An online store ships orders for $\$5$ if the total is under $\$50$, and for free if the total is $\$50$ or more. Can a single formula describe the shipping cost? What happens to the cost at exactly $\$50$? Many real situations, such as fees, taxes, and speeds, change their rule at a certain point. Functions that work this way are called piecewise functions.

What is a piecewise function?

Graph of a piecewise function with three pieces: two horizontal segments and a sloped segment, separated by dashed vertical lines piece 1 piece 2 piece 3

Each rule only works inside its own interval. The intervals must cover the domain without overlapping, so every $x$ belongs to exactly one piece. A solid dot means the point is part of the graph. An open circle means it is not.

Practice★☆☆Not started
Match the following description with the structure of a piecewise function: "An oven is turned on and its temperature rises at a constant rate for 10 minutes until it…

Match the following description with the structure of a piecewise function: "An oven is turned on and its temperature rises at a constant rate for 10 minutes until it reaches 200°F. It is kept at that temperature for 40 minutes to bake a pizza and, finally, it is turned off, with its temperature dropping to room temperature (20°F) at a constant rate over 30 minutes."

Write the time intervals that would define the three sections of the temperature function $T(t)$.

Solve

Evaluating a piecewise function

To find $f(a)$, always do two steps in this order. First, decide which interval contains $a$. Then substitute $a$ into the rule of that piece only.

Graph of a piecewise function with a line rising to the point (-1, 3), a horizontal segment from x = -1 to x = 2, and a descending line starting at an open circle at x = 2 x < −1 −1 ≤ x ≤ 2 x > 2
Practice★☆☆Not started
Given the following piecewise function: $f(x) = \begin{cases} 2x+1 & \text{if } x < 0 \\ x^2-3 & \text{if } x \ge 0 \end{cases}$ Calculate the value of the function at…

Given the following piecewise function:

$f(x) = \begin{cases} 2x+1 & \text{if } x < 0 \\ x^2-3 & \text{if } x \ge 0 \end{cases}$

Calculate the value of the function at the points $x = -2$, $x = 0$ and $x = 3$.

Solve

Graphing a piecewise function

Graph each piece only on its own interval, then look at the endpoints.

  1. Make a small table for each piece, using $x$-values from its interval and the breakpoint.

  2. Draw each piece with a ruler or smooth curve, stopping at the breakpoints.

  3. At each endpoint, use a solid dot if the inequality includes it ($\le$ or $\ge$) and an open circle if it does not ($<$ or $>$).

Graph of a piecewise function with a jump at x = 2: a line ending at an open circle at (2, 3) and another line starting at a solid dot at (2, 4) y = x + 1 y = −x + 6 (2, 4) (2, 3)
Practice★☆☆Not started
Plot the following piecewise function in your notebook: $f(x) = \begin{cases} -2 & \text{if } x \le 1 \\ 2x-4 & \text{if } x > 1 \end{cases}$

Plot the following piecewise function in your notebook:

$f(x) = \begin{cases} -2 & \text{if } x \le 1 \\ 2x-4 & \text{if } x > 1 \end{cases}$

Solve

Reading a graph: domain, range, and the rule

The domain is every $x$-value where the graph exists, and the range is every $y$-value the graph reaches. Read the endpoints carefully: an open circle is not included, and a solid dot is.

To write the rule from a graph:

  1. Split the graph at the breakpoints. Each piece is a ray or segment, a parabola arc, or a horizontal line.

  2. Find the equation of each piece. For a line, use two points to get the slope $m = \dfrac{y_2 - y_1}{x_2 - x_1}$, then $y = mx + b$. For a horizontal line, $y = c$. For a parabola arc, read the vertex $(h, k)$ and use $y = a(x - h)^2 + k$, finding $a$ from one other point.

  3. Write each interval from the $x$-coordinates of the ends, using the open and solid dots to choose $<$ or $\le$.

Some problems ask for the equation of a graph made of rays, written as a piecewise rule with its intervals. That is exactly the three steps above.

Graph of two line segments: one from (-2, -3) to (1, 3) with solid dots, and one from an open circle at (1, 1) to a solid dot at (3, -1) (1, 3) (1, 1) (−2, −3) (3, −1)
Practice★☆☆Not started
Observe the graph of the function $f(x)$ and determine its domain and range.

Observe the graph of the function $f(x)$ and determine its domain and range.

X Y 0 3 −3 3 −2 f(x)
Solve
Practice★☆☆Not started
From the graph of the function $g(x)$, determine its analytical expression knowing that it is formed by two half-lines.

From the graph of the function $g(x)$, determine its analytical expression knowing that it is formed by two half-lines.

X Y 0 2 4 g(x)
Solve
Practice★★☆Not started
From the graph of the function $h(x)$, which is composed of an arc of a parabola and a half-line, find its analytical expression.

From the graph of the function $h(x)$, which is composed of an arc of a parabola and a half-line, find its analytical expression.

X Y 0 2 −3 h(x)
Solve

Continuity at a breakpoint

A graph is continuous if you can draw it without lifting your pencil. For a piecewise function made of lines and parabolas, each piece is already smooth, so the only places to worry about are the breakpoints.

Graph of shipping cost: constant 5 for order totals above 0 and below 50 dollars ending at an open circle, then constant 0 starting at a solid dot at 50, with a dashed vertical jump S = 5 S = 0 jump 50 order total (dollars)

If a problem has two unknowns, such as $a$ and $b$, you need two equations. One comes from continuity at a breakpoint and the other from a point the graph must pass through. Plug the point into the correct piece, then solve the system by substitution or elimination. After finding the values, check the other breakpoints too.

Practice★☆☆Not started
Find the breakpoint of the following function and determine if it is continuous at that point:…

Find the breakpoint of the following function and determine if it is continuous at that point:

$f(x) = \begin{cases} 3x-2 & \text{if } x < 2 \\ 5-x & \text{if } x \ge 2 \end{cases}$

Solve
Practice★★☆Not started
Determine the value of the parameter $k$ so that the following piecewise function is continuous throughout its domain:…

Determine the value of the parameter $k$ so that the following piecewise function is continuous throughout its domain:

$f(x) = \begin{cases} x^2 - 1 & \text{if } x \le 2 \\ kx + 3 & \text{if } x > 2 \end{cases}$

Solve
Practice★★★Not started
Determine the values of the parameters $a$ and $b$ so that the function $f(x)$ is continuous at $x=1$ and passes through the point $(4, 9)$.…

Determine the values of the parameters $a$ and $b$ so that the function $f(x)$ is continuous at $x=1$ and passes through the point $(4, 9)$.

$f(x) = \begin{cases} ax^2 + b & \text{if } x < 1 \\ 3x - 2 & \text{if } 1 \le x \le 3 \\ ax - b & \text{if } x > 3 \end{cases}$

Once $a$ and $b$ have been found, check mathematically if the function is also continuous at $x=3$.

Solve

Jumps, holes, and relative maxima and minima

There are different ways a graph can fail to be continuous at a point.

Type What you see
Jump The two sides stop at different heights.
Hole (removable) Both sides head to the same height, but the point there is missing, or the solid dot sits at a different height.
Infinite The graph shoots up or down along a vertical asymptote, like $y = \dfrac{1}{x}$ at $x = 0$.

A relative maximum is a point that is higher than all the points near it on both sides. A relative minimum is lower than all the points near it. At a breakpoint, compare the value $f(p)$ with the values just to the left and just to the right.

Graph of a parabola arc with relative minimum at (1, -1) joined at (3, 3) to a descending line, where the corner is a relative maximum relative min relative max
Practice★★☆Not started
Given the piecewise function: $f(x) = \begin{cases} -x^2+4x & \text{if } x < 3 \\ x-2 & \text{if } x \ge 3 \end{cases}$ Plot it graphically and determine its relative…

Given the piecewise function:

$f(x) = \begin{cases} -x^2+4x & \text{if } x < 3 \\ x-2 & \text{if } x \ge 3 \end{cases}$

Plot it graphically and determine its relative maxima and minima, if it has any.

Solve
Practice★★★Not started
Observe the following graph of the function $p(x)$ and determine its complete analytical expression. From it, indicate its domain, its range and classify the…

Observe the following graph of the function $p(x)$ and determine its complete analytical expression. From it, indicate its domain, its range and classify the discontinuities it presents.

X Y 0 −3 3 4 p(x)
Solve

Absolute value as a piecewise function

For example, for $|2x + 6|$, the inside is $0$ at $x = -3$. For $x \ge -3$, $|2x + 6| = 2x + 6$. For $x < -3$, $|2x + 6| = -(2x + 6)$.

With two absolute values, mark both breakpoints on a number line. They split the line into three intervals, and you simplify on each.

Number line with breakpoints at -2 and 1, dividing it into three regions with the simplified rule for each −2 1 x < −2 −2 ≤ x < 1 x ≥ 1 −2x − 1 3 2x + 1
Practice★☆☆Not started
Express the absolute value function $f(x) = |3x - 6|$ as a piecewise function.

Express the absolute value function $f(x) = |3x - 6|$ as a piecewise function.

Solve
Practice★★☆Not started
Express the function $f(x) = |x - 2| + 3x$ as a piecewise function without using the absolute value and calculate the values of $f(0)$ and $f(5)$.

Express the function $f(x) = |x - 2| + 3x$ as a piecewise function without using the absolute value and calculate the values of $f(0)$ and $f(5)$.

Solve
Practice★★★Not started
Express the function $f(x) = |x + 3| - |2x - 4|$ as a piecewise function, eliminating the absolute values, and simplify the expression of each of the resulting sections.

Express the function $f(x) = |x + 3| - |2x - 4|$ as a piecewise function, eliminating the absolute values, and simplify the expression of each of the resulting sections.

Solve

Modeling fees and rates

Piecewise functions are a natural model for any price that changes after a threshold. To write the model:

  1. Find the thresholds. They are your breakpoints.

  2. Write the rule for the first piece.

  3. At each threshold, work out the amount you have already accumulated, then add the new rate times the extra amount.

Graph of scooter rental cost: a line from 1 dollar rising to 6 dollars at 20 minutes, then a steeper line reaching 10 dollars at 30 minutes 1 + 0.25t 0.4t − 2 20 30 t (min) C (dollars)

When the first part is a flat fee (like "$\$2$ for the first hour or any part of it"), that piece is a constant, a horizontal segment. The domain of the real situation, such as $x > 0$ for time, tells you where the first piece starts.

Practice★☆☆Not started
A downtown parking lot charges a rate of $\$2$ for the first hour of stay (or fraction thereof). After the first hour, it charges at a rate of $\$1.50$ for each…

A downtown parking lot charges a rate of $\$2$ for the first hour of stay (or fraction thereof). After the first hour, it charges at a rate of $\$1.50$ for each additional hour, billing the extra time proportionally to the exact minutes of the stay. Write the piecewise function $C(x)$ that represents the total cost as a function of the hours $x$ the car remains in the parking lot.

Solve
Practice★★☆Not started
A cell phone company offers a data plan that works as follows: a fixed monthly fee of $\$15$ is paid, which includes the first $5…

A cell phone company offers a data plan that works as follows: a fixed monthly fee of $\$15$ is paid, which includes the first $5$ GB of download. If this limit is exceeded, each additional gigabyte (or proportional fraction) is charged at $\$2$.

Write the function $C(x)$ that represents the monthly cost as a function of the gigabytes $x$ consumed, and calculate how much a customer who has consumed $3$ GB and another who has consumed $8.5$ GB will pay.

Solve
Practice★★☆Not started
The electricity bill of a house has a fixed monthly charge of $\$10$. In addition, the first $100$ kWh consumed are billed at $\$0.12$/kWh. If $100$ kWh are exceeded,…

The electricity bill of a house has a fixed monthly charge of $\$10$. In addition, the first $100$ kWh consumed are billed at $\$0.12$/kWh. If $100$ kWh are exceeded, the excess consumption is charged at $\$0.15$/kWh. Write the function $F(x)$ that gives the total amount of the bill as a function of the kWh $x$ consumed.

Solve

Tiers that build on each other: taxes, motion, and filling

The same idea works when the "rate" is a tax percentage or the slope of a graph. In every case, each new piece starts where the previous piece ended.

Graph of a drone's height: climbing from 0 to 20 feet in 5 seconds, hovering until 15 seconds, then descending to the ground at 20 seconds 4t 20 80 − 4t 5 15 20 t (s) h (ft)

To find when a quantity reaches a target, find the piece whose heights include the target, then solve the equation in that piece. The answer must lie in that piece's interval.

Filling to a capacity

A container cannot hold more than its capacity. Once it is full, the volume stops growing and stays at the capacity (or the model simply ends). So the full model has one more piece: a constant at the capacity. To find when it fills, set the tiered rule equal to the capacity, solve for the time, and make sure that time lies in the piece you used.

Practice★★☆Not started
In a fictional country, income tax is calculated as follows: no tax is paid on the first $\$10\,000$ of income ($0$%). For the amount exceeding $\$10\,000$ and up to…

In a fictional country, income tax is calculated as follows: no tax is paid on the first $\$10\,000$ of income ($0$%). For the amount exceeding $\$10\,000$ and up to $\$20\,000$, $10$% is paid. For the amount exceeding $\$20\,000$, $20$% is paid.

Write the piecewise function $I(x)$ that calculates the tax to be paid as a function of the income $x$.

Solve
Practice★★☆Not started
A commuter train starts from a station and accelerates at a constant rate until it reaches a speed of $20$ ft/s in $10$ seconds. It maintains this cruising speed for…

A commuter train starts from a station and accelerates at a constant rate until it reaches a speed of $20$ ft/s in $10$ seconds. It maintains this cruising speed for $30$ seconds and, finally, brakes uniformly until it comes to a complete stop at the next station in $5$ seconds. Write the piecewise function $v(t)$ that describes the speed of the train as a function of the time elapsed since starting.

Solve
Practice★★★Not started
A water tank with a capacity of $6000$ gallons is initially empty. A pump is turned on that introduces water at a constant rate of $50$ gallons per minute. After $60$…

A water tank with a capacity of $6000$ gallons is initially empty. A pump is turned on that introduces water at a constant rate of $50$ gallons per minute. After $60$ minutes, a second auxiliary pump is turned on that adds an additional flow of $30$ gallons per minute. Write the piecewise function $V(t)$ that represents the volume of water in the tank as a function of time, and calculate how much time in total it will take to fill the tank completely.

Solve

Maximum revenue and unknown parabolas

When a piece is a quadratic, its highest or lowest point is at the vertex, with $x = -\dfrac{b}{2a}$. But in a piecewise function the vertex only counts if it lies inside that piece's interval. Otherwise, check the endpoints of the interval.

When a problem tells you a parabola $h(t) = at^2 + bt + c$ has unknown coefficients, count the facts you know. Each fact is an equation, and with three unknowns you need three facts. The usual facts are:

  • the parabola passes through a given point,

  • the parabola meets the previous piece at the breakpoint (continuity),

  • the parabola has a zero, such as "hits the ground at $t = 50$".

There is also a fact that is easy to miss. If a parabola takes over from a line and nothing makes the motion change suddenly, the parabola touches the line without crossing it at the breakpoint $t_0$. Then (parabola) $-$ (line) is a quadratic with a double zero at $t_0$, so it factors as $a(t - t_0)^2$. This gives a shortcut: $$\text{parabola} = \text{line} + a(t - t_0)^2$$ This form already guarantees continuity at $t_0$, leaving only $a$ to find.

The zero $t = 2$ is outside the piece ($t > 10$), so it does not matter physically. It is only used to locate the axis of symmetry.

Practice★★★Not started
A theater offers a ticket price of $\$10$ if up to a maximum of $50$ people attend. To encourage the attendance of large groups, for each person exceeding $50…

A theater offers a ticket price of $\$10$ if up to a maximum of $50$ people attend. To encourage the attendance of large groups, for each person exceeding $50$, the ticket price for all attendees is reduced by $\$0.10$.

Write the total revenue function of the theater $I(x)$ as a function of the number of attendees $x$ (as a piecewise function) and determine how many people must attend for the theater to obtain the maximum possible revenue.

Solve
Practice★★★Not started
A test rocket takes off vertically. During the first $10$ seconds, its height in feet is modeled by the linear function $h(t) = 5t$. At $10$ seconds the engine is turned…

A test rocket takes off vertically. During the first $10$ seconds, its height in feet is modeled by the linear function $h(t) = 5t$. At $10$ seconds the engine is turned off and the rocket follows a parabolic free-fall trajectory $h(t) = at^2 + bt + c$, such that the transition is continuous. Knowing that the rocket hits the ground at $50$ seconds, find the expression of the parabola and determine the maximum height reached by the rocket.

Solve

Area and intersections

Area under a piecewise graph

To find the area between a graph and the $x$-axis, split it into shapes you know: rectangles ($bh$), triangles ($\tfrac{1}{2}bh$), and trapezoids.

Region under a graph that rises from 0 to 4 over the first 4 units and then stays at 4 until x = 7, split into a triangle and a rectangle triangle rectangle 4 7

Intersections with a line

To find where a piecewise graph meets another graph, set each piece equal to the other function separately. Keep only solutions that lie inside that piece's interval.

Practice★★★Not started
Given the piecewise function: $f(x) = \begin{cases} 2x & \text{if } 0 \le x \le 2 \\ k & \text{if } 2 < x \le 6 \end{cases}$ Calculate the value of the parameter $k$ so…

Given the piecewise function:

$f(x) = \begin{cases} 2x & \text{if } 0 \le x \le 2 \\ k & \text{if } 2 < x \le 6 \end{cases}$

Calculate the value of the parameter $k$ so that the total area of the geometric figure enclosed between the graph of the function and the x-axis ($X$-axis) is exactly $24$ square units.

Solve
Practice★★★Not started
Find analytically the points of intersection between the piecewise function $f(x) = \begin{cases} x^2 - 4 & \text{if } x < 0 \\ -2x + 4 & \text{if } x \ge 0 \end{cases}$…

Find analytically the points of intersection between the piecewise function $f(x) = \begin{cases} x^2 - 4 & \text{if } x < 0 \\ -2x + 4 & \text{if } x \ge 0 \end{cases}$ and the line $y = x + 2$.

Solve

Back to the store: the shipping cost is $$S(x) = \begin{cases} 5 & \text{if } 0 < x < 50 \\ 0 & \text{if } x \ge 50 \end{cases}$$ At $x = 50$ the left piece says $5$ and the right piece says $0$. They do not meet, so the graph has a jump, and an order of exactly $\$50$ ships free.

Summary

See all the exercises in this section