Chapter 1.6 Piecewise Functions
The functions we examined so far are defined by a single formula. However, it is not always possible to do this. In this section, we will study piecewise functions and how decomposition can help us better understand them.
Decomposing Domains
To begin, we define what is a piecewise function.
Piecewise Defined Function
A piecewise defined function, \(f\colon \mathbb R\to \mathbb R\), is a function that is defined by more than one formula.
The different formulas are valid on different intervals.
In other words, it is a function that can be decomposed into different functions on the specified intervals. Therefore, understanding how a piecewise function’s domain is decomposed is crucial to understand its behavior.
In this example, pay attention on how we evaluate the piecewise function.
Example 1
Define \[f(x) = \begin{cases}x^2 &\text{if }x < -2\\x &\text{if }0<x < 2\\2x+1 &\text{if }x > 4.\end{cases}\] Evaluate \(f\) at \(x = -3\), \(x = 1\), and \(x = 7\).
The value \(x=-3\) satisfies \(x<-2\). Use the first formula to calculate \(f(-3)\): \[f(-3)=(-3)^3=9.\]
The value \(x=1\) satisfies \(0<x<2\). Use the second formula to calculate \(f(1)\): \[f(1)=1.\]
The value \(x=7\) satisfies \(x>7\). Use the third formula to calculate \(f(7)\): \[f(7)=2\cdot(7)+1=15.\]
The pervious example is actually not the first time we have seen a piecewise function. In fact, we have seen some functions before that are piecewise functions.
Example 2
Take \(f\) to be given by \[f(x) = \begin{cases}-x&\text{if }x < 0\\x&\text{if }x \ge 0.\end{cases}\] Evaluate \(f(-3)\), \(f(-1)\), \(f(2)\), \(f(10)\). Have you seen this function before?
The value \(x=-3\) satisfies \(x<0\). Use the first formula to calculate \(f(-3)\): \[f(-3)=-(-3)=3.\]
The value \(x=-1\) satisfies \(x<0\). Use the first formula to calculate \(f(-1)\): \[f(-1)=-(-1)=1.\]
The value \(x=2\) satisfies \(x\geq 0\). Use the second formula to calculate \(f(2)\): \[f(2)=(2)=2.\]
The value \(x=10\) satisfies \(x\geq 0\). Use the second formula to calculate \(f(10)\): \[f(10)=(10)=10.\]
This is the absolute value function. \(|-3|=3\), \(|-1|=1\), \(|2|=2\), \(|10|=10\).
In order to work with more complicated functions, we need to understand how to decompose a function’s domain. We are going to build a language that will allow us to do this.
We start with a partition.
Partition
A partition of a non-empty set \(X\) is a collection of non-empty disjoint subsets of \(X\) whose union is \(X\).
Partitions decompose sets into smaller sets.
Note: A set \(X\) has many partitions. Here is an example.
Example 3
Find a partition of the set \((-7, 12]\) that contains three sets.
A partition must be a collection of disjoint sets and the union of all three sets must be the interval \((-7,12).\)
One Partition is \(\{(-7,2),[2,10),[10,12]\}.\)
Another Partition is \(\{(-7,0),[0,5),[5,7]\}.\)
Partitions and piecewise functions are connected in the following way.
Presentation and Partiton for Function
A presentation of a function is its explicit description with respect to a partition of its domain into intervals.
The collection of intervals given by a particular presentation of a function \(f\) is said to be a partition for \(f\).
An important thing to note is that a function can have more than one presentation because it may have a different partition. In this next example, we will find another presentation of the function.
Example 4
Find another presentation of the function \(f\), given by \[f(x) = \begin{cases}2x &\text{if }-7< x < 10\\x+1 &\text{if }10\leq x \leq 12.\end{cases}\]
There are many answers.
First, here is one partition: \[\{(-7,2),[2,10),[10,12]\}.\] The presentation of \(f\) that corresponds to this partition is this:
\[f(x) = \begin{cases}2x &\text{if }-7<x < 2\\2x &\text{if }2\leq x < 10 \\x+1 &\text{if }10\leq x \leq 12.\end{cases}\]
An important thing to note about the pervious example is that it is just a different presentation, but it is still the same function in the sense that nothing has changed pointwise. That is, the domain is still the same and values of the function are the same.
Speaking of which, it is important to be able to read off the domain of a function. Practice that with the next example.
Example 5
Describe the domain of the function \(f\) that is given by \[f(x) = \begin{cases}2x-1 &\text{if }-4<x\leq 1\\3x^2+1 &\text{if }1<x\leq 3\\2\sqrt{x-1} &\text{if }5\leq x\leq 7.\end{cases}\]
The inequality \(-4<x\leq 1\) is the interval \((-4,1]\).
The inequality \(1<x\leq 3\) is the interval \((1,3]\).
The inequality \(5\leq x\leq 7\) is the interval \([5,7]\).
The function is defined on the unit of these interval, so \(\mathcal{D}(f)=(-4,3]\cup [5,7].\)
Although the domain of a piecewise function is easy to read off, its range cannot immediately be read off. However, one way to determine the range of a function is by looking at its partition and graphing the function defined on each interval in its partition.
Example 6
Use a sketch of the function \(f\) to determine the range of \(f\), where \(f\) is given by \[f(x) = \begin{cases}x^2 &\text{if }x < -2\\x &\text{if }-1<x < 1\\2x+1 &\text{if }x > 3.\end{cases}\]
The domain of \(f\) is \(\mathcal{D}(f)=(-\infty,2)\cup (-1,1)\cup (3,\infty).\) Its domain is the union of these three intervals. On each of these intervals, \(f\) is defined differently.
On \((-\infty,-2)\), the restriction of \(f\) is a portion of a parabola.
The range here is \((4,\infty)\).
On \((-1,1)\), the restriction of \(f\) is a portion of a line.
The range here is \((-1,1)\).
On \((3,\infty)\), the restriction of \(f\) is a portion of another line.
The range here is \((7,\infty)\).
Altogether \(\mathcal{R}(f)=(4,\infty)\cup(-1,1)\cup(7,\infty)\) which simplifies to \[\mathcal{R}(f)=(-1,1)\cup(4,\infty).\]
So far, we have been working with one piecewise function. However, what do we do if we need to work with more than one piecewise function? We need some way to be able to work with two piecewise functions. This can be done by understanding them through their partitions.
The vocabulary is part of the language that allows us to work with the piecewise functions.
Finer Partition
A partition \(A\) for a set \(X\) is finer than a partition \(B\), if every set in \(B\) is a union of sets in \(A\).
Basically, \(A\) is finer than \(B\) if every element in \(B\) can be reconstructed using elements in \(A\) via a set union.
To understand the definition better, let’s look at an example.
Example 7
- Find two partitions for the set \((-3, 10]\) that each contain at least two sets so that neither partition is finer than the other.
- Find two partitions for the set \((-3, 10]\) that each contain at least two sets so that one partition is finer than the other.
There are many answers. Here are some examples.
Partition A \(\{(-3,0],(0,10]\}\) and Partition B \(\{(-3,-1),[-1,10]\}\). Neither partition is finer than other.
Partition A \(\{(-3,0],(0,10]\}\) and Partition B \(\{(-3,-1),[-1,10].(0,10]\}\). Partition B is finer than Partition A.
Since we need to work with more than one partition, we need the following vocabulary.
Refinement and Common Refinement
A refinement \(C\) of a partition \(A\) for a set \(X\) is a partition for \(X\) that is finer than \(A\).
A common refinement \(C\) of partitions \(A\) and \(B\) for a set \(X\) is a partition for \(X\) that is finer than both \(A\) and \(B\).
Essentially, a common refinement is a partition that refines both \(A\) and \(B\).
Let’s understand this with the following example.
Example 8
Take \(A\) and \(B\) to be the sets that are given by \[A = \left\{[-3, 2), [2, 8)\right\}\quad {\rm and}\quad B = \left\{[-3, 1), [1, 5], (5, 8)\right\}.\] The sets \(A\) and \(B\) are partitions of the set \([-3, 8)\). Find a common refinement for \(A\) and \(B\).
Here is a common refinement \(C=\{[-3,1),[1,2),[2,5],(5,8)\}\). We can check by making sure we can build each interval in \(A\) and \(B\) by using some combination of intervals in \(C\) and unions.
For example the interval in \(A\), \([-3,2)\) is built by unioning \([-3,1)\) and \([1,2)\). The other interval in \(A\), \([2,8)\) is the union of \([2,5]\) and \((5,8)\).
The intervals in \(B\) are all present. For example \([1,5]\) is the union of \([1,2)\) and \([2,5]\),
Now, let’s practice this idea with a piecewise defined function.
Example 9
Take \(f\) to be the function that is given by \[f(x) = \begin{cases}2x &\text{if }-2<x\leq 4\\x+1&\text{if }4< x < 10.\end{cases}\] Present \(f\) as a piecewise defined function with respect to a different partition for the set \((-2, 10)\).
The given partition is \(\{(-2,4],(4,10)\}\). There are many ways to create a new presentation. For example, split \((-2,4]\) into \((-2,1)\) and \([1,4]\) and split \((4,10)\) into \((4,7]\) and \((7,10)\). This is the new presentation of \(f\):
\[f(x)=\begin{cases}2x &\text{if }-2<x<1\\ 2x &\text{if }1\leq x\leq 4\\x+1&\text{if }4< x \leq 7\\x+1&\text{if }7< x < 10.\end{cases}\]
Compound Piecewise Defined Function
Two piecewise functions may have presentations that are defined on partitions that are not the same. For example, one function may have a presentation on \(\{(-1,1),[1,\infty)\}\) while another function may have a presentation \(\{(-3,0),[0,4],(4,\infty)\}.\) To work with two piecewise functions, we need to be able to compare them in a simple way.
We do that with a commensurable partition.
Commensurable Partition
A commensurable partition for two piecewise defined functions is a collection of sets that is a partition for each of the two functions.
The first step in working with sums, products, and quotients of two piecewise defined functions is finding a commensurable partition for the two functions.
Composition of piecewise defined functions is somewhat more complicated since it demands an analysis of the range of a piecewise defined function.
Example 10
Take \(f\) and \(g\) to be given by \[f(x) = \begin{cases} x^2+1 &\text{if } x\leq 4\\ \frac{1}{x} &\text{if }x >8\end{cases}\quad {\rm and}\quad g(x) = \begin{cases} 3x + 4 &\text{if } x < 2\\ 20 - x &\text{if } x \ge 3.\end{cases}\] Determine \(\mathcal D(f+g)\) and compute \(f+g\).
To determine \(\mathcal{D}(f+g)\), figure out \(\mathcal{D}(f)\cap\mathcal{D}(g)\).
The domain of \(f\), \(\mathcal{D}(f)\) is \((-\infty,4]\cup (8,\infty).\) The domain of \(g\), \(\mathcal{D}(g)\) is \((-\infty,2)\cup [3,\infty).\) Thus \[\mathcal{D}(f+g)=\mathcal{D}(f)\cap\mathcal{D}(g)=(-\infty,2)\cup [3,4]\cup (8,\infty).\]
To compute \(f+g\), use the idea of commensurable partition.
A commensurable partition is \(\{(-\infty,2),[3,4],(8\infty)\}\).
Thus
\[(f+g)(x) = \begin{cases} x^2+1+3x+4 &\text{if } x<2\\ x^2+1+20-x &\text{if }3\leq x \leq 4\\ \frac{1}{x}+20-x &\text{if }x >8\end{cases}\]
or
\[(f+g)(x) = \begin{cases} x^2+3x+5 &\text{if } x<2\\ x^2-x+21 &\text{if }3\leq x \leq 4\\ \frac{1}{x}+20-x &\text{if }x >8\end{cases}\]
In this example, we go one step beyond finding the domain by finding an explicit formula for the sum, product and quotient.
Example 11
Take \(f\) and \(g\) to be given by \[f(x) = \begin{cases} x+1 &\text{if } x < -1\\2x &\text{if } -1\leq x \leq 3\\x^2 &\text{if } x >3\end{cases}\quad {\rm and}\quad g(x) = \begin{cases} x + 4 &\text{if } x < 1\\ x^2+1 &\text{if } x \ge 1.\end{cases}\] Compute \(f+g\), \(f\cdot g\), and \(\frac{f}{g}\).
First find the domain.
To determine \(f+g\) and \(f\cdot g\), figure out \(\mathcal{D}(f)\cap\mathcal{D}(g)\).
The domain of \(f\), \(\mathcal{D}(f)\) is \((-\infty,\infty).\) The domain of \(g\), \(\mathcal{D}(g)\) is \((-\infty,\infty).\) Thus \[\mathcal{D}(f+g)= (-\infty,\infty).\]
To compute \(f+g\) and \(f\cdot g\), use the idea of commensurable partition.
A commensurable partition is \(\{(-\infty,-1),[-1,1),[1,3],(3,\infty)\}\).
Thus
\[(f+g)(x) = \begin{cases} x+1+x+4 &\text{if } x<-1\\ 2x+x+4 &\text{if } -1\leq x<1\\ 2x+x^2+1&\text{if } 1\leq x\leq 3\\ x^2+x^2+1&\text{if } 3<x\\\end{cases}\]
and
\[(f\cdot g)(x) = \begin{cases} (x+1)(x+4) &\text{if } x<-1\\ 2x(x+4) &\text{if } -1\leq x<1\\ 2x(x^2+1)&\text{if } 1\leq x\leq 3\\ x^2(x^2+1)&\text{if } 3<x\\\end{cases}\]
To compute \(\frac{f}{g}\) account for when \(g(x)=0\) on commensurable partition. The function \(g\) looks like \(g(x)=x+4\) when \((-\infty,1)\). It is zero when \(x=-4\), so we remove that from our presentation. The function \(g\) looks like \(g(x)=x^2+1\) when \([1,\infty)\). It is non-zero because \(x^2+1=0\) has no solution. So our answer for \(\frac{f}{g}\) is
\[\left(\frac{f}{g}\right)(x) = \begin{cases} \frac{x+1}{x+4} &\text{if } x<-4\\ \frac{x+1}{x+4} &\text{if } -4<x<-1\\ \frac{2x}{x+4} &\text{if } -1\leq x<1\\ \frac{2x}{x^2+1}&\text{if } 1\leq x\leq 3\\ \frac{x^2}{x^2+1}&\text{if } 3<x\\\end{cases}\]
Inequalities Involving Piecewise Defined Functions
To solve inequalities involving piecewise defined functions, study the solutions on commensurable partitions.
Take the union of the solution sets on the subsets of the domains to find all solutions.
Example 12
Take \(f\) to be given by \[f(x) = \begin{cases}5-x &\text{if } x < 2\\2x - 10 &\text{if } x\ge 2.\end{cases}\] Sketch on a number line the solution set to the inequality \(f(x) > 1\).
The function \(f\) decomposes into two parts.
On \((-\infty,2),\) the inequality \(f(x)>1\) is the same as \(5-x>1\). Solve the inequality to get \(4>x\) or \((-\infty,4)\). The solution set is the intersection of the solution set of the solved inequality and the partition; \((-\infty,4)\cap(-\infty,2)=(-\infty,2)\).
On \([2,\infty),\) the inequality \(f(x)>1\) is the same as \(2x-10>1\). Solve the inequality to get \(x>\frac{11}{2}\) or \((\frac{11}{2},\infty)\). The solution set is the intersection of the solution set of the solved inequality and the partition; \([2,\infty)\cap\left(\frac{11}{2},\infty\right)=\left(\frac{11}{2},\infty\right)\).
Therefore, the solution set to \(f(x)>1\) is the union of the two previous solutions: \[(-\infty,2)\cup\left(\frac{11}{2},\infty\right).\]
Here is an inequality involving two piecewise functions.
Example 13
Take \(f\) and \(g\) to be given by \[f(x) = \begin{cases} 2x + 12 &\text{if } x < 0\\5 &\text{if } 0\leq x \leq 6\\x - 7 &\text{if } x >6\end{cases}\quad {\rm and}\quad g(x) = \begin{cases} x + 4 &\text{if } x < 2\\ 8 - x &\text{if } x \ge 2.\end{cases}\] Sketch on a number line the solution set to the inequality \(f(x) > g(x)\).
Use the principle of decomposition to decompose the domain into partitions.
Split into intervals \(A=(-\infty,0)\), \(B=[0,2)\), \(C=[2,6]\), and \(D=(6,\infty)\) to solve \(f(x)>g(x)\).
- On \(A=(-\infty,0)\), solving \(f(x)>g(x)\) is the same as the inequality \(2x+12>x+4\). Solve to get \(x>-8\) or \((-8,\infty)\). The overall solution set for partition \(A\) is \(A\) intersect the solved inequality: \((-\infty,0)\cap(-8,\infty)=(-8,0).\)
- On \(B=[0,2)\), solving \(f(x)>g(x)\) is the same as the inequality \(5>x+4\). Solve to get \(1>x\) or \((-\infty,1)\). The overall solution set for partition \(B\) is \(B\) intersect the solved inequality: \([O,2)\cap(-\infty,1)=[0,1).\)
- On \(C=[2,6]\), solving \(f(x)>g(x)\) is the same as the inequality \(5>8-x\). Solve to get \(x>3\) or \((3,\infty)\). The overall solution set for partition \(C\) is \(C\) intersect the solved inequality: \([2,6]\cap(3,\infty)=(3,6].\)
- On \(D=(6,\infty)\), solving \(f(x)>g(x)\) is the same as the inequality \(x-7>8-x\). Solve to get \(x>\frac{15}{2}\) or \((\frac{15}{2},\infty)\). The overall solution set for partition \(D\) is \(D\) intersect the solved inequality: \((6,\infty)\cap(\frac{15}{2},\infty)=(\frac{15}{2},\infty).\)
Therefore, the solution set to \(f(x)>g(x)\) is the union of the two previous solutions: \[(-8,0)\cup[0,1)\cup(3,6]\cup\left(\frac{15}{2},\infty\right)=(-8,1)\cup(3,6)\cup\left(\frac{15}{2},\infty\right).\]
The absolute value is a piecewise defined function. Solving absolute value inequalities is a special case of solving inequalities involving piecewise defined functions. Decomposition is particularly useful for solving such inequalities.
Example 14
Sketch on a real number line the solutions to \[|x| > 2.\]
The absolute value function is a piecewise function.
\[ |x|=\begin{cases}x &\text{ if }x\geq 0\\ -x &\text{ if } x<0\end{cases}. \]
The inequality \(|x|>2\) can be split into two parts.
- On \(A=[0,\infty)\), solving \(|x|>2\) is the same as the inequality \(x>2\). Solve to get \((2,\infty)\). The overall solution set for partition \(A\) is \(A\) intersect the solved inequality: \([0,\infty)\cap(2,\infty)=(2,\infty).\)
- On \(B=(-\infty,0)\), solving \(|x|>2\) is the same as the inequality \(-x>2\). Solve to get \(-2>x\) or \((-\infty,-2)\). The overall solution set for partition \(B\) is \(B\) intersect the solved inequality: \((-\infty,0)\cap(-\infty,2)=(-\infty,2).\)
Therefore, the solution set to \(|x|>2\) is the union of the previous solutions: \[(2,\infty)\cup(-\infty,2)\] or \[(-\infty,2)\cup(2,\infty).\]
Write out the absolute value term below as a piecewise defined function to solve the inequality
Example 15
Solve the inequality \[|5x+1| < 3.\]
The absolute value function is a piecewise function.
\[ |x|=\begin{cases}x &\text{ if }x\geq 0\\ -x &\text{ if } x<0\end{cases}. \]
Therefore,
\[ |5x+1|=\begin{cases}5x+1 &\text{ if }5x+1\geq 0\\ -(5x+1) &\text{ if } 5x+1<0\end{cases}. \]
Solve \(5x+1\geq 0\) and \(5x+1<0\) to get the partitions. The presentation is
\[ |5x+1|=\begin{cases}5x+1 &\text{ if }x\geq \frac{1}{5}\\ -(5x+1) &\text{ if } x<\frac{1}{5}\end{cases}. \]
The inequality \(|5x+1|<3\) can be split into two parts.
- On \(A=[\frac{1}{5},\infty)\), solving \(|5x+1|<3\) is the same as the inequality \(5x+1<3\). Solve to get \(x<\frac{2}{5}\) or \(\left(-\infty,\frac{2}{5}\right)\). The overall solution set for partition \(A\) is \(A\) intersect the solved inequality: \(\left[\frac{1}{5},\infty\right)\cap\left(-\infty,\frac{2}{5}\right)=\left[\frac{1}{5},\frac{2}{5}\right).\)
- On \(B=(-\infty,\frac{1}{5})\), solving \(|5x+1|<3\) is the same as the inequality \(-(5x+1)<3\). Solve to get \(-\frac{4}{5}<x\) or \(\left(-\frac{4}{5},\infty\right)\). The overall solution set for partition \(B\) is \(B\) intersect the solved inequality: \(\left(-\infty,\frac{1}{5}\right)\cap\left(\frac{4}{5},\infty\right)=\left(-\frac{4}{5},\frac{1}{5}\right).\)
Therefore, the solution set to \(|5x+1|<3\) is the union of the previous solutions: \[\left[\frac{1}{5},\frac{2}{5}\right)\cup\left(-\frac{4}{5},\frac{1}{5}\right)\] or \[\left(-\frac{4}{5},\frac{2}{5}\right).\]
Write out both absolute value term below as a piecewise defined function and then find a common refinement to solve the inequality.
Example 16
Solve the inequality \[|3x+1| > |x-8|.\]
The absolute value function is a piecewise function.
\[ |x|=\begin{cases}x &\text{ if }x\geq 0\\ -x &\text{ if } x<0\end{cases}. \]
Therefore,
\[ |3x+1|=\begin{cases}3x+1 &\text{ if }3x+1\geq 0\\ -(3x+1) &\text{ if } 3x+1<0\end{cases} \]
and \[ |x-8|=\begin{cases}x-8 &\text{ if }x-8\geq 0\\ -(x-8) &\text{ if } x-8<0\end{cases}. \]
Solve \(3x+1\geq 0\), \(3x+1<0\), \(x-8\geq 0\), \(x-8<0\) to get the partitions. The presentations are
\[ |3x+1|=\begin{cases}3x+1 &\text{ if }x\geq -\frac{1}{3}\\ -3x-1 &\text{ if } x<-\frac{1}{3}\end{cases} \]
and
\[ |x-8|=\begin{cases}x-8 &\text{ if }x\geq 8\\ -(x-8) &\text{ if } x<8\end{cases}. \]
The inequality \(|3x+1|>|x-8|\) can be split into three parts.
- On \(A=(-\infty,-\frac{1}{3})\), solving \(|3x+1|>|x-8|\) is the same as the inequality \(-3x-1>-x+8\). Solve to get \(x<-\frac{9}{2}\) or \(\left(-\infty,-\frac{9}{2}\right)\). The overall solution set for partition \(A\) is \(A\) intersect the solved inequality: \(\left(-\infty,-\frac{9}{2}\right)\cap\left(-\infty,-\frac{1}{3}\right)=\left(-\infty,-\frac{9}{2}\right)\)
- On \(B=\left[-\frac{1}{3},8\right)\), solving \(|3x+1|>|x-8|\) is the same as the inequality \(3x+1>-x+8\). Solve to get \(x>\frac{7}{4}\) or \(\left(\frac{7}{4},\infty\right)\). The overall solution set for partition \(B\) is \(B\) intersect the solved inequality: \(\left[-\frac{1}{3},8\right)\cap\left(\frac{7}{4},\infty\right)=\left(\frac{7}{4},8\right)\)
- On \(C=\left[8,\infty\right)\), solving \(|3x+1|>|x-8|\) is the same as the inequality \(3x+1>x-8\). Solve to get \(x>-\frac{9}{2}\) or \(\left(-\frac{9}{2},\infty\right)\). The overall solution set for partition \(C\) is \(C\) intersect the solved inequality: \(\left[8,\infty\right)\cap\left(-\frac{9}{2},\infty\right)=\left[8,\infty\right)\)
Therefore, the solution set to \(|3x+1|>|x-8|\) is the union of the previous solutions: \[\left(-\infty,-\frac{9}{2}\right)\cup\left(\frac{7}{4},8\right)\cup \left[8,\infty\right)\] or \[\left(-\infty,-\frac{9}{2}\right)\cup \left(\frac{7}{4},\infty\right).\]