Section 6.4 Piecewise-defined Functions
You are not limited to functions defined by a single algebraic expression. Frequently engineers need to model situations that are quite complex and might require sudden changes in behavior. A piecewise-defined function is a function defined by multiple expressions, each assigned to a particular portion of the function’s domain indicated by some logical condition.
Example 6.18. A Piecewise-Defined Function.
A piecewise-defined function may be describe by listing multiple expressions gathered by a large brace as follows.
\begin{equation*}
f(x) =
\begin{cases}
4,& \text{if $0 \leq x \lt 3$} \\
-2(x-5),& \text{if $3 \leq x \lt 5$} \\
0,& \text{if $5 \leq x$} \\
\end{cases}
\end{equation*}
To evaluate \(f\) check which, if any, of the conditional statements are true and use that expression to evaluate. For example,
evaluating at \(x = 2\text{,}\) we note that \(0 \leq 2 \lt 3\) is true and conclude \(f(2) = 4\text{.}\)
evaluating at \(x = 3\text{,}\) we note that \(0 \leq 3 \lt 3\) is false, but \(3 \leq 3 \lt 5\) is true so that \(f(3) = -2(3-5) = -2(-2) = 4\text{.}\)
evaluating at \(x = 4\text{,}\) we note that \(3 \leq 4 \lt 5\) is true so that \(f(4) = -2(4-5) = -2(-1) = 2\text{.}\)
evaluating at \(x = 10\text{,}\) we note that \(4 \leq 10\) is true so that \(f(10) = 0\text{.}\)
evaluating at \(x = -10\text{,}\) we note that none of the conditions are true for this value so that \(f(-10)\) is undefined and \(x=-10\) is not in the domain of \(f\text{.}\)
In fact, the domain of \(f\) is \([0,+\infty)\) as every non-negative real number satisfies one of the conditions above.
To graph
\(y=f(x)\text{,}\) sketch the graph of each expression, but only on the domain indicated by its companion condition. In our example, there are three “pieces” to the graph. I’ve plotted each only on its domain indicated by the conditional.
Notice the use of a hole or dot, depending on the inequality
\(\lt\) or
\(\leq\) Combining them we obtain the graph of
\(y=f(x)\) From this, we conclude that the range of
\(f\) is
\([0,4]\text{.}\) Finally, observe how the graph is
continuous in that the piecewise join together at points and may be drawn without lifting our pencil up at any point.
Example 6.20. The Absolute Value Function.
The absolute value function is a piecewise-defined function. Its value depends on if the input is a negative or non-negative.
\begin{equation*}
|x| = \begin{cases}
-x,& \text{if $x \lt 0$} \\
x,& \text{if $x \geq 0$} \\
\end{cases}
\end{equation*}
Example 6.21. Graphing of a Piecewise-defined Function.
Graph
\begin{equation*}
g(x) =
\begin{cases}
x^2,& \text{if $x \lt 0$} \\
x-2,& \text{if $0 \lt x \leq 4$} \\
1,& \text{otherwise} \\
\end{cases}
\end{equation*}
and determine its domain and range.
Solution.
There are two pieces,
\(y=x^2\) and
\(y=x-2\text{.}\) Plot them individually, but restrict your attention to the interval they are defined on. Use a dot or hole depending on the inequality.
There is a “catchall” that assigns one to any other value of
\(x\text{.}\) For example,
\(f(0) = 1\) because neither condition applies to zero. Putting it all together:
The domain is
\((-\infty,+\infty)\) and the range is
\((-2,+\infty)\text{.}\)
Example 6.22. Finding Zeros.
Find the real number zeros of
\begin{equation*}
P(x) = \begin{cases}
4-x^2 &= \text{if $-4\leq x \lt 1$}\\
(x-3)^2 &= \text{of $1\leq x \lt 4$}\\
1-x &= \text{if $4 \leq x$}\\
\end{cases}
\end{equation*}
Solution.
Recall that a zero is a solution to \(P(x) = 0\text{.}\) We should attempt to find zeros of each expression defining \(P\text{,}\) but only on the interval where it applies.
Solving \(4-x^2 = 0\) results in \(x=\pm 2\text{,}\) but only \(x=-2\) satisfies \(-4\leq x \lt 1\text{.}\) Thus, \(x=-2\) is a zero of \(P\text{,}\) but \(x=2\) is not.
Solving \((x-3)^2 = 0\) results in \(x=3\text{,}\) which satisfies \(-1\leq x \lt 4\text{.}\) Thus, \(x=3\) is a zero of \(P\text{.}\)
Solving \(1-x = 0\) results in \(x=1\text{,}\) but this does not satisfy \(4 \leq x\text{.}\) Thus, \(x=1\) is not a zero of \(P\text{.}\)
We conclude that the real number zeros of
\(P\) are
\(x=-2\) and
\(x=3\text{.}\) These correspond to the
\(x\)-intercepts on its graph below.