Skip to main content

Section 2.2 Piecewise Functions

Sometimes, we want to use different formulas for our function, depending on what the input is. In this section, we will look at how those kinds of functions are written and practice working with them.

Definition 2.9.

A piecewise function is a function that uses different formulas for different inputs. It is a function made of pieces of other functions.

Since our function has multiple formulas and requirements for when we use which formula, the notation is a bit longer. Here is an example of a piecewise function:

\begin{equation*} f(x) = \begin{cases}2x+3 \amp x \gt 4 \\ x^2+7 \amp -1 \lt x \le 4 \\ \sqrt{3-x} \amp x \le -1 \end{cases} \end{equation*}

To evaluate the function, we actually start on the right. The column on the right that has \(x \gt 4\text{,}\) \(-1 \lt x \le 4\text{,}\) and \(x \ge -1\) is the part that tells us when to use which formula. Once we know which formula to use, that's when we move to the left to actually use the formula.

Example 2.10.

Suppose

\begin{equation*} f(x) = \begin{cases}2x+3 \amp x \gt 4 \\ x^2+7 \amp -1 \lt x \le 4 \\ \sqrt{3-x} \amp x \le -1 \end{cases} \end{equation*}

We want to evaluate each of the following:

  1. \(\displaystyle f(0)\)

  2. \(\displaystyle f(-2)\)

  3. \(\displaystyle f(10)\)

  4. \(\displaystyle f(4)\)

Let's go through them one-by-one:

  1. To find \(f(0)\text{,}\) we know that our input is \(0\text{.}\) So, we look on the right side and see that \(0\) fits into the middle inequality, since \(0\) is between \(-1\) and \(4\text{.}\) That tells us that we want to plug \(0\) into the middle equation. Therfore, \(f(0) = (0)^2+7 = 7\text{.}\)

  2. To find \(f(-2)\text{,}\) we know that our input is \(-2\text{.}\) So, we look on the right side and see that \(-2\) fits into the last inequality, since \(-2\) is less than \(-1\text{.}\) That tells us that we want to plug \(-2\) into the last equation. Therfore, \(f(-2) = \sqrt{3-(-2)} = \sqrt{3+2}=\sqrt{5}\text{.}\)

  3. To find \(f(10)\text{,}\) we know that our input is \(10\text{.}\) So, we look on the right side and see that \(10\) fits into the first inequality, since \(10\) is greater than \(4\text{.}\) That tells us that we want to plug \(10\) into the first equation. Therfore, \(f(10) = 2(10)+3 = 23\text{.}\)

  4. To find \(f(4)\text{,}\) we know that our input is \(4\text{.}\) So, we look on the right side to see which inequality \(4\) fits into. Notice that the first inequality is only the numbers greater than \(4\text{,}\) which doesn't include \(4\) itself. However, the middle equation has \(x \le 4\text{,}\) which does include \(4\text{.}\) That tells us that we want to plug \(4\) into the middle equation. Therfore, \(f(4) = (4)^2+7 = 16+7=23\text{.}\)

Checkpoint 2.11.

Suppose

\begin{equation*} p(x)=\begin{cases}3-x \amp x \gt 2 \\ 42 \amp x=2 \\ x^2 \amp x \lt 2\end{cases} \end{equation*}

Evaluate each of the following:

  1. \(\displaystyle f(1)\)

  2. \(\displaystyle f(-3)\)

  3. \(\displaystyle f(2)\)

  4. \(\displaystyle f(4)\)

Answer.
  1. \(f(1)\)=1

  2. \(\displaystyle f(-3)=9\)

  3. \(\displaystyle f(2)=42\)

  4. \(\displaystyle f(4)=-1\)

Solution.

Suppose

\begin{equation*} p(x)=\begin{cases}3-x \amp x \gt 2 \\ 42 \amp x=2 \\ x^2 \amp x \lt 2\end{cases} \end{equation*}

Evaluate each of the following:

  1. To find \(f(1)\text{,}\) we know that our input is \(1\text{.}\) So, we look on the right side and see that \(1\) fits into the last inequality, since \(1\) is less than \(2\text{.}\) That tells us that we want to plug \(1\) into the last equation. Therfore, \(f(1) = (1)^2=1\text{.}\)

  2. To find \(f(-3)\text{,}\) we know that our input is \(-3\text{.}\) So, we look on the right side and see that \(-3\) fits into the last inequality, since \(-3\) is less than \(2\text{.}\) That tells us that we want to plug \(-3\) into the last equation. Therfore, \(f(-3) = (-3)^2=9\text{.}\)

  3. To find \(f(2)\text{,}\) we know that our input is \(2\text{.}\) So, we look on the right side and see that \(2\) fits into the middle, that one is just \(x=2\text{.}\) That tells us that we want to plug \(-2\) into the middle equation, which is a constant function. Therfore, \(f(2) = 42\text{.}\)

  4. To find \(f(4)\text{,}\) we know that our input is \(4\text{.}\) So, we look on the right side and see that \(4\) fits into the first inequality, since \(4\) is greater than \(2\text{.}\) That tells us that we want to plug \(4\) into the first equation. Therfore, \(f(4) = 3-(4)=-1\text{.}\)