## Piecewise Functions

17calculus > precalculus > piecewise functions

### Search 17calculus

coming early 2014 - new mobile site

This is an incredibly important concept that you need to understand for limits, which are the key to calculus. To understand this topic, you need to know why the domain of a function is important. Click here to refresh your understanding.
Many students think this is a difficult concept but I have had students that come into my class not understanding this and, after they get it, they look at me and say, 'That's it?!" as if it should be harder. But it is not hard, it just stretches your brain a tad bit but you can get it. Here is the idea.

A regular function usually has a single domain, which may or may not be explicitly stated. If it is not stated, you can imply it from the equation. In contrast, a piecewise function always specifies the domain AND the domain is usually broken into pieces. Graphically, you can think about breaking up the xy-plane with vertical lines. First, let's look at a graph and then we will discuss what the equations look like.

plot 1

Look at plot 1 to the right. Notice that at $$x = 1$$ something strange is happening. We can divide the xy-plane into two parts, one to the left of $$x = 1$$ and one to the right. So, what we do is consider each side separately. There is no overlap (Otherwise it would not be a function, would it?).

So, if we cover up the part of the plane from $$x = 1$$ to the right (take a piece of paper and do that now, if you need to), we have something that looks like part of a parabola, right? Now, we if cover up the part of the plane from $$x = 1$$ to the left, we have something that looks like part of an upside-down parabola, right? So this graph could be described by the equation

$$\displaystyle{ f(x) = \left\{ \begin{array}{rrl} x^2 & & x < 1 \\ -(x-2)^2+3 & & x \geq 1 \end{array} \right. }$$

Okay, we have seen how an equation might fit a graph. But what if you are given the equation and you need to come up with a graph? I will show you how I do it and see if this helps you.

Let's start with the same equation above, i.e. $$\displaystyle{ f(x) = \left\{ \begin{array}{rrl} x^2 & & x < 1 \\ -(x-2)^2+3 & & x \geq 1 \end{array} \right. }$$ and let's try to build the graph shown in plot 1.

Start by just graphing both functions on the same set of axes to get the plot 2 below. The red graph is $$y = x^2$$. The blue graph is $$-(x-2)^2+3$$. At this point, we show the complete graphs of both equations without taking into account the domains. You can tell this is not a function, right?

What we need to do now is implement the domain of each part of f(x). To do this we notice that $$y=x^2$$ is defined only for $$x < 1$$. So we 'erase' or remove all of the red graph that is to the right of $$x = 1$$. We also notice that $$x < 1$$ means that x must be less than one but not equal to one. So we need an open circle on the red graph to indicate this exclusion of one. The result of these changes is the plot 3 below.

plot 2

plot 3

plot 1

Okay, we are almost done. Now we need to implement the domain of $$x \geq 1$$ on the blue graph. The equation tells us that the blue graph is defined only for $$x \geq 1$$. So we 'erase' or remove all of the blue graph to the left of $$x= 1$$. We also notice that this graph includes $$x = 1$$ since the greater than or equal sign is used. So we need a closed circle at $$x = 1$$. The result is plot 1, repeated here.

So, that's one way to do it. This idea can be extended to more than two parts, i.e. the graph may be broken at more than just one point. Just break the domain into the separate sections and deal with as many sections as you have in your equation. The practice problems contain some examples.

### Piecewise Functions Resources

Piecewise Functions Questions

### Can sections of piecewise functions overlap?

Long Answer - - As with many questions, the answer depends on the wording of the question. When writing down the piecewise equation of a graph, sections can certainly overlap. The mathematics is there to allow such a graph. However, since the word 'function' is used in the question, if there were any overlaps in the definition or the graph, we would no longer have a function (since the graph would not pass the vertical line test). So in order to define a piecewise function, none of the sections may overlap.

Note: We are assuming here that the question is implying that 'overlap' means there exists at least one x-value with two possible corresponding y-values, i.e. there is at least one vertical line that crosses the graph at more than one point.

like? 0

Practice Problems

Instructions - - Unless otherwise instructed,
- if the problem gives an equation, graph the function
- if the problem shows a graph, write an equation for the graph

 Level A - Basic

Practice A01

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} 2x+1 & x < 0 \\ 2x+2 & x \geq 0 \end{array} \right. }$$

Practice A02

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} 1-x & x < 1 \\ \sqrt{x-1} & x \geq 1 \end{array} \right. }$$

Practice Problem [ A01 ]

Problem Statement

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} 2x+1 & x < 0 \\ 2x+2 & x \geq 0 \end{array} \right. }$$

Problem Solution

The red part of the graph represents the function $$2x + 1 ~~~ x < 0$$. Notice there is an open circle at $$x = 0$$ since the domain is all values less than zero not including zero.

The blue part of the graph represents the function $$2x + 2 ~~~ x \geq 0$$. The solid circle indicates that $$x=0$$ is included in the domain.

Notice that both ends of the lines do not have end points, i.e. there is no circle, open or closed, at the left end of the red line and the right end of the blue line. This indicates that the lines go off to infinity and never stop. Some instructors require arrows to represent the same idea. Check with your instructor to clarify what they want to see in your work.

Note that we used two colors in the graph to represent different parts to clarify what is going on. However, the function $$f(x)$$ is the entire graph and the sections would not normally be in different colors.
Also notice that the axes are not labeled, i.e. there is no way to know what the scales of the gridlines are. In this graph, the grids (both x and y) are units of one. This is extremely unusual on this site and it is not recommended as standard practice to leave off the labels. However, check with your instructor to see what they require as far as labeling the axes your graphs.

like? 4

Practice Problem [ A02 ]

Problem Statement

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} 1-x & x < 1 \\ \sqrt{x-1} & x \geq 1 \end{array} \right. }$$

Problem Solution

In this graph, the straight line to the left of $$x=1$$ represents the function $$y = 1 - x ~~~ x < 1$$. If we were graphing only this part of the graph, there would be an open circle at $$x=1$$ to represent the fact that $$x=1$$ is not included in the domain of this part of the function. However, the second part of the graph, $$\sqrt{x-1} ~~~ x \geq 1$$, actually fills in the open circle at $$x=1$$. So we can't see the open circle for the first part of the graph. We have made the circle obvious in this graph to emphasize this. However, it is not necessary to do so to be correct.

Notice that both ends of the lines do not have end points, i.e. there is no circle, open or closed, at the left end of the straight line and the right end of the curved line. This indicates that the lines go off to infinity and never stop. Some instructors require arrows to represent the same idea. Check with your instructor to clarify what they want to see in your work.

Also, notice that the axes are not labeled, i.e. there is no way to know what the scales of the gridlines are. In this graph, the grids (both x and y) are units of one. Check with your instructor to see what they require as far as labeling the axes your graphs.

like? 2

Practice A03

Practice A04

Practice Problem [ A03 ]

Problem Statement

Problem Solution

There are several ways to describe this graph. We are restricted by the fact that the problem statement says that this is a function. So we have to be careful how to describe the point $$(-1,1)$$ since functions are required to pass the vertical line test.

First we notice that we have two straight lines, so that simplifies things a bit. Since we have two points on each line, we can easily find the equation of the line using the equation for slope and one of the points. Doing that we get $$y = x+2$$ for the line to the left of $$x=-1$$ and $$y = -x/2 + 1/2$$ for the line to the right of $$x=-1$$. Now we need to restrict the domain.

Notice that we have definite endpoints for both ends of the lines. So we need to take that into account. Also, the point $$(-1,1)$$ can be included in the domain for the left line or the right line but not both. That's because we know this is a function and the equation (and graph) must pass the vertical line test. So here are three possible answers.

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+2 & -2 \leq x \leq -1 \\ -x/2+1/2 & -1 < x \leq 3 \end{array} \right. }$$

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+2 & -2 \leq x < -1 \\ -x/2+1/2 & -1 \leq x \leq 3 \end{array} \right. }$$

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+2 & -2 \leq x < -1 \\ 1 & x = -1 \\ -x/2+1/2 & -1 < x \leq 3 \end{array} \right. }$$

Answer 3 is certainly a valid and correct answer. However, you probably won't see it written like this very often since it is not as concise as the previous two.
Notice in all three cases, there is no overlap in the domain, which means that this is a function (i.e. it passes the vertical line test).

like? -1

Practice Problem [ A04 ]

Problem Statement

Problem Solution

 video by IntegralCALC

like? 1

Practice A05

For the piecewise function
$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+1 & x \leq -2 \\ 3 & -2 < x \leq 1 \\ -x^2 & 1 < x \end{array} \right. }$$
a) evaluate $$f(-4), f(0), f(4)$$
b) over what interval is the function increasing?

Practice A06

Find the domain and range of these piecewise functions.
a) $$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+1 & -3 \leq 0 \\ x^2 & 0 \leq x \leq 2 \end{array} \right. }$$

b) $$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x & -3 \leq x \leq 0 \\ 2 & 0 < x < 1 \\ \sqrt{x} & 1 \leq x < 4 \end{array} \right. }$$

Practice Problem [ A05 ]

Problem Statement

For the piecewise function
$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+1 & x \leq -2 \\ 3 & -2 < x \leq 1 \\ -x^2 & 1 < x \end{array} \right. }$$
a) evaluate $$f(-4), f(0), f(4)$$
b) over what interval is the function increasing?

Problem Solution

 video by PatrickJMT

like? 1

Practice Problem [ A06 ]

Problem Statement

Find the domain and range of these piecewise functions.
a) $$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+1 & -3 \leq 0 \\ x^2 & 0 \leq x \leq 2 \end{array} \right. }$$

b) $$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x & -3 \leq x \leq 0 \\ 2 & 0 < x < 1 \\ \sqrt{x} & 1 \leq x < 4 \end{array} \right. }$$

Problem Solution

 video by PatrickJMT

like? 0

 Level B - Intermediate

Practice B01

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+1 & -3 \leq x < 0 \\ x^2 & 0 \leq x \leq 2 \end{array} \right. }$$

Practice B02

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x & -3 \leq x \leq 0 \\ 2 & 0 < x < 1 \\ \sqrt{x} & 1 \leq x < 4 \end{array} \right. }$$

Practice B03

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} -2 & x \leq -3 \\ 4-x & -3 < x < 0 \\ x & x \geq 0 \end{array} \right. }$$

Practice Problem [ B01 ]

Problem Statement

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x+1 & -3 \leq x < 0 \\ x^2 & 0 \leq x \leq 2 \end{array} \right. }$$

Problem Solution

 video by PatrickJMT

like? 0

Practice Problem [ B02 ]

Problem Statement

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} x & -3 \leq x \leq 0 \\ 2 & 0 < x < 1 \\ \sqrt{x} & 1 \leq x < 4 \end{array} \right. }$$

Problem Solution

 video by PatrickJMT

like? 0

Practice Problem [ B03 ]

Problem Statement

$$\displaystyle{ f(x) = \left\{ \begin{array}{lr} -2 & x \leq -3 \\ 4-x & -3 < x < 0 \\ x & x \geq 0 \end{array} \right. }$$

Problem Solution

 video by PatrickJMT

like? 0

Practice B04

Practice Problem [ B04 ]

Problem Statement

Problem Solution

 video by PatrickJMT

like? 0