topic badge

1.04 Piecewise functions

Piecewise functions

When more than one function is needed to create a model for a given situation, we can use a piecewise function to connect the different pieces. A domain is given for each individual function which makes up the piecewise function.

A piecewise function with name f open parenthesis x close parenthesis or f of x. The brace { is labeled. There are 3 pieces or functions within the piecewise function, each defined on a separate line. The top function is x minus 3, with domain x is less than  negative 2. The middle function is negative 4, with domain negative 2 is less than or equal to x and x is less than 0. The bottom function is x squared minus 4, with domain x is greater than 0. On each line the function is stated first, followed by a comma, and then the domain as an inequality. Each line is highlighted a different color to emphasise that they are different pieces or functions.

To graph piecewise functions, it can be helpful to first find all of the endpoints, then determine what the graph will look like between them.

The inequalities for the domains help us determine whether the endpoints are filled (closed) or unfilled (open).

Filled (closed): \bullet for \leq or \geq\\Unfilled (open): \circ for < or >

-6
-5
-4
-3
-2
-1
1
2
3
4
5
6
x
-7
-6
-5
-4
-3
-2
-1
1
2
3
4
5
y

For the piecewise function above:

  • The line for f\left(x\right)=x-3 is drawn for x-values less than -2.

  • The line for f\left(x\right)=-4 is only drawn for x-values between -2 and 0, including -2 but not 0.

  • The parabola for f\left(x\right)=x^2-4 is drawn for x-values greater than 0.

The domain of the function is all real numbers except for 0 because 0 is the only value where there is no solid graph.

The range is all real numbers except for those between -4 and -5. -4 is included in the domain because there is solid graph at a y-value of -4 but -5 is not included in the range.

A discontinuity occurs when there are values missing in the domain or range. Graphically, a discontinuity appears as a hole or a gap in the graph. For example, the graph above has a discontinuity at x=-2 and at x=0.

Examples

Example 1

Consider the piecewise function: f\left(x\right)=\begin{cases} x + 6, & x \lt -4 \\ 4, &-4\leq x \lt -2 \\ \left(x+2\right)^{2} +5, & x \gt -2 \end{cases}

a

Evaluate the function at f\left(-7\right),\,f\left(-4\right),\,f\left(-2\right),\,f\left(1\right).

Worked Solution
Create a strategy

For each value of x, we can determine which function from the piecewise function to evaluate based on the given domain.

Apply the idea

Since x=-7 is in the domain of x+6:f\left(-7\right)=\left(-7\right)+6=-1

Since x=-4 is in the domain of 4: f\left(-4\right)=4

Since x=-2 is not in the domain, f\left(-2\right)\text{ is undefined}

Since x=1 is in the domain of \left(x+2\right)^2+5: f\left(1\right)=\left(1+2\right)^2+5=3^2+5=14

b

Graph the piecewise function.

Worked Solution
Create a strategy

The three functions have their own place on the coordinate plane, so we can draw each function and erase the part of the function in the domain that the line does not belong to.

Apply the idea
-7
-6
-5
-4
-3
-2
-1
1
2
x
2
4
6
8
10
12
14
y
Reflect and check

Note that this is still considered a function because it passes the vertical line test, or rather, each input has a single, unique output.

c

Describe the key features of the function graphed in part (b).

Worked Solution
Create a strategy

Recall that key features may include domain, range, intercepts, minimum and maximum points, increasing and decreasing and constant intervals, and end behavior.

Apply the idea

Domain: \left(-\infty, -2\right)\cup\left(-2,\infty\right)

Range: \left(-\infty, 2\right) \cup \left[4\right] \cup\left(5, \infty\right)

x-intercept: \left(-6,0\right)

y-intercept: \left(9,0\right)

Increasing on \left(-\infty, -4\right) and \left(-2, \infty\right)

Constant on \left(-4,-2\right)

End behavior: As x \to -\infty, y \to -\infty and as x \to \infty, y \to \infty

Reflect and check

Notice that the domain is not continuous because there are two gaps in the range.

Example 2

Write the piecewise-defined function based on the graph shown:

-4
-3
-2
-1
1
2
3
4
x
-6
-4
-2
2
4
6
8
10
y
Worked Solution
Create a strategy

By covering up each part of the graph or imagining that we can extend each line or curve, we can identify the types of graphs that are in the piecewise function.

Apply the idea
-4
-3
-2
-1
1
2
3
4
x
-6
-4
-2
2
4
6
8
10
y

For x\leq 0, the graph is a straight line. We can determine its equation by finding the y-intercept and counting the rise and run to determine the slope.

The equation of the line is y=4x+3 for x-values less than or equal to 0.

-4
-3
-2
-1
1
2
3
4
x
-6
-4
-2
2
4
6
8
10
y

For x>0, the graph appears to be quadratic or exponential. By finding the ratio of the y-values, we can see it is an exponential function.\dfrac{9}{3}=3The equation of the curve is y=3^x for x-values greater than 0.

The piecewise-defined function for the given graph is

f\left(x\right) = \begin{cases} 4x+3, & x \leq 0 \\ 3^x, & x > 0 \end{cases}

Example 3

Determine the types of functions that are in this piecewise function.

f\left(x\right) = \begin{cases} x+4, & x \lt 0 \\ -2, & 0 \leq x \lt 4 \\ 12-x^2, & x\geq 4 \end{cases}

Worked Solution
Create a strategy

There are 3 types of functions that make up this piecewise function:

  • y=x+4

  • y=-2

  • y=12-x^2

We can use the structure of each equation to determine the function family it belongs to.

Apply the idea

The first equation is of the first degree and in the form f\left(x\right)=mx+b. In this case, m=1 and b=4. Therefore, the function that defines the interval x<0 is linear.

The second equation is in the form f\left(x\right)=c. In this case, c=-2. Therefore, the function that defines the interval 0\leq x <4 is constant.

The third equation is of the second degree and in the form f\left(x\right)=ax^2+bx+c. In this case, a=-1, b=0, and c=12. Therefore, the function that defines the interval x\geq 4 is quadratic.

Reflect and check
-4
-3
-2
-1
1
2
3
4
5
6
7
x
-7
-6
-5
-4
-3
-2
-1
1
2
3
4
y

If we had looked at the graph alone, we may have mistakenly classified the functions. Note that the linear function could have been part of an absolute value function, and the piece of the quadratic that is shown also appears linear.

This is why it is important to consider multiple features of the function instead of relying on a graph alone.

Example 4

Consider the functions shown:

  • Function 1: f\left(x\right) = \begin{cases} -x^{2}+5, & x \leq 0 \\ -\dfrac{1}{2}x-3, & 0<x \end{cases}
  • Function 2:
    -4
    -3
    -2
    -1
    1
    2
    3
    4
    x
    5
    10
    15
    20
    g\left(x\right)
a

Determine which function is increasing if x>0.

Worked Solution
Create a strategy

To visualize where Function 1 is increasing, we can graph it and compare it to the graph of Function 2.

Function 1
-8
-6
-4
-2
2
4
6
8
x
-8
-6
-4
-2
2
4
6
8
y

For x-values to the left of the y-axis, the graph is an upside down parabola translated 5 units up. The y-intercept will be a closed circle.

For x-values to the right of the y-axis, the graph is a line with a slope of -\dfrac{1}{2} and a y-intercept of -3. The y-intercept will be an open circle.

It is now easy to see that Function 1 is decreasing when x>0.

Apply the idea

If x>0, Function 2 is increasing.

Reflect and check

We also could have just looked at the equation for Function 1 when x>0, and identified it as a linear function with a slope of -\dfrac{1}{2}, meaning the function would be decreasing over that interval.

b

Determine whether or not each function has a maximum or minimum value.

Worked Solution
Create a strategy

Use the graph of the piecewise function from part (a) and the given graph of Function 2 to analyze them more easily.

Apply the idea
Function 1
-8
-6
-4
-2
2
4
6
8
x
-8
-6
-4
-2
2
4
6
8
y

Function 1 has a maximum point at the point \left(0,5\right), which is the vertex of the quadratic portion of the piecewise function.

Function 2
-4
-3
-2
-1
1
2
3
4
x
5
10
15
20
g\left(x\right)

Function 2 is exponential, and has a horizontal asymptote at y=5. Because the function never actually reaches 5 as x approaches negative infinity, we can not call this a minimum value.

There are an infinite number of smaller and smaller fractions that get close to, but never quite reach, 5.

As x approaches positive infinity, the exponential function will also approach positive infinity.

Therefore, Function 2 does not have a minimum or maximum value.

Idea summary

A piecewise function is made up of two or more functions.

The domain of a piecewise function is visible in both the piecewise-defined function and the graph.

Outcomes

A2.F.2

The student will investigate and analyze characteristics of square root, cube root, rational, polynomial, exponential, logarithmic, and piecewise-defined functions algebraically and graphically.

A2.F.2a

Determine and identify the domain, range, zeros, and intercepts of a function presented algebraically or graphically, including graphs with discontinuities.

A2.F.2b

Compare and contrast the characteristics of square root, cube root, rational, polynomial, exponential, logarithmic, and piecewise-defined functions.

A2.F.2c

Determine the intervals on which the graph of a function is increasing, decreasing, or constant.

A2.F.2d

Determine the location and value of absolute (global) maxima and absolute (global) minima of a function.

A2.F.2e

Determine the location and value of relative (local) maxima or relative (local) minima of a function.

A2.F.2f

For any value, x, in the domain of f, determine f(x) using a graph or equation. Explain the meaning of x and f(x) in context, where applicable.

A2.F.2g

Describe the end behavior of a function.

What is Mathspace

About Mathspace