$\require{cancel}\newcommand\degree{^{\circ}} \newcommand\Ccancel[black]{\renewcommand\CancelColor{\color{#1}}\cancel{#2}} \newcommand{\alert}{\boldsymbol{\color{magenta}{#1}}} \newcommand{\blert}{\boldsymbol{\color{blue}{#1}}} \newcommand{\bluetext}{\color{blue}{#1}} \delimitershortfall-1sp \newcommand\abs{\left|#1\right|} \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&}$

## SectionPiecewise Functions

A function may be defined by different formulas on different portions of the $x$-axis. Such a function is said to be defined piecewise. To graph a function defined piecewise, we consider each piece of the $x$-axis separately.

###### Example140

Graph the function defined by

\begin{equation*} f(x) = \begin{cases} x +1 \amp \text{if } x\le 1\\ 3 \amp \text{if } x\gt 1 \end{cases}. \end{equation*}
Solution

Think of the plane as divided into two regions by the vertical line $x = 1\text{,}$ as shown in Figure141. In the left-hand region ($x \le 1$), we graph the line $y = x + 1\text{.}$ (The fastest way to graph the line is to plot its intercepts, $(-1, 0)$ and $(0, 1)\text{.}$)

Notice that the value $x = 1$ is included in the first region, so $f (1) = 1 + 1 = 2\text{,}$ and the point $(1, 2)$ is included on the graph. We indicate this with a solid dot at the point $(1, 2)\text{.}$

In the right-hand region ($x \gt 1$), we graph the horizontal line $y = 3\text{.}$ The value $x = 1$ is not included in the second region, so the point $(1, 3)$ is not part of the graph. We indicate this with an open circle at the point $(1, 3)\text{.}$ ###### Example142

Graph the piecewise defined function

\begin{equation*} g(x) =\begin{cases} -1 - x \amp \text { if } x \le -1\\ x^3 \amp \text{ if } x \gt -1 \end{cases}. \end{equation*}
Solution The absolute value function $f (x) = \abs{x}$ is an example of a function that is defined piecewise.

\begin{equation*} f (x) =\abs{x} = \begin{cases} x \amp \text{if } x\ge 0\\ -x \amp \text{if } x\lt 0 \end{cases} \end{equation*}

To sketch the absolute value function, we graph the line $y = x$ in the first quadrant and the line $y = -x$ in the second quadrant.

###### Example143
1. Write a piecewise definition for $g(x) = \abs{x - 3}\text{.}$

2. Sketch a graph of $g(x) = \abs{x - 3}\text{.}$

Solution
1. In the definition for $\abs{x}\text{,}$ we replace $x$ by $x - 3$ to get

\begin{equation*} g(x) =\abs{x-3} = \begin{cases} x-3 \amp \text{if }~ x-3\ge 0\\ -(x-3) \amp \text{if }~ -(x-3)\lt 0 \end{cases}. \end{equation*}

We can simplify this expression to

\begin{equation*} g(x) =\abs{x-3} = \begin{cases} x-3 \amp \text{if }~ x\ge 3\\ -x+3 \amp \text{if }~ x\lt 3 \end{cases}. \end{equation*}
2. In the first region, $x \ge 3\text{,}$ we graph the line $y = x - 3\text{.}$ Because $x = 3$ is included in this region, the endpoint of this portion of the graph, $(3, 0)\text{,}$ is included, too.

In the second region, $x \lt 3\text{,}$ we graph the line $y = -x + 3\text{.}$ Note that the two pieces of the graph meet at the point $(0, 3)\text{,}$ as shown in Figure144.

### SubsectionDomain and Range

To identify the domain and range of a piecewise function, we recall that a piecewise function is defined by different functions each with corresponding domains.

Then the domain of the piecewise function is the concatenation of these domains, and the range of the piecewise function is the contatenation of the ranges of the functions on their corresponding domains. This idea is better illustrated in the following example.

###### Example145

Find the domain and range of the function

\begin{equation*} f(x) = \begin{cases} x^2 -6 \amp \text{if } 0\le x\le 4\\ -x+10 \amp \text{if } 5\le x\lt 10 \end{cases}. \end{equation*}
Solution

By definition, we see that $f$ is comprised of two functions:

• $x^2-6$ on the domain $[0,4]$

• $-x+10$ on the domain $[5,10)$

Then the domain of $f$ is the concatination of the domains of the two functions listed above. We represent this as

\begin{equation*} [0,4]\cup [5,10). \end{equation*}

The symbol "$\cup$" is shorthand for the word "and".

Each of the functions which make up $f$ were considered in the Domain and Range Section as examples. Putting together the two graphs, we get the graph of $f \text{:}$

In the Domain and Range Section we found that the range of $x^2-6$ on the domain $0\le x\le 4$ is $[-6,10]\text{.}$ Additionally, we found that the range of $-x+10$ on the domain $5\le x\lt 10$ is $(0,5]\text{.}$ Then the range of $f$ is the concatination of these two ranges:
However, notice that we can simplify this a bit. Since the values in the interval $(0,5]$ are contained in the interval $[-6,10]$ and thus