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

SectionPiecewise Functions

Supplemental Videos

The main topics of this section are also presented in the following videos:

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.

Example149

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 Figure150. 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{.}\)

piecewise function
Figure150
Example151

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*}

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.

Example152
  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 Figure153.

    piecewise function
    Figure153

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 combination of these domains, and the range of the piecewise function is the combination of the ranges of the functions on their corresponding domains. This idea is better illustrated in the following example.

Example154

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 combination 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{:}\)

piecewise function
Figure155

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 combination of these two ranges:

\begin{equation*} [-6,10]\cup(0,5]. \end{equation*}

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

\begin{equation*} [-6,10]\cup(0,5]=[-6,10]. \end{equation*}

SubsectionExercises