2.2: Combinations and Compositions of Functions
Focus: Combinations of Functions
We need to develop more types of functions to describe relationships. If the rate of change is not constant, we can't use a linear function. If it does not have two or more distinct pieces, we can't use a piecewise defined function. In this section, we will explore techniques to build new functions from old ones using arithmetic operations on the outputs.
Since the outputs of many functions are real numbers, such as \(f(1) = 3\) and \(g(1) =5\), arithmetic operations, such as addition, subtraction, multiplication, and division can be performed on those outputs. For example, we can add these outputs for a specific input, such as x = 1, \[f(1) + g(2) =3 + 5 = 8\nonumber \] We can subtract outputs \[f(1) - g(1) =3 - 5 = -2\nonumber \]We can multiply outputs \[f(1) \cdot g(1) =3 \cdot 5 = 15\nonumber \] We can divide outputs \[\dfrac{f(1)}{g(1)} = \dfrac{3}{5} = 0.6 \nonumber \]
If we added the outputs of these two functions for a given set of inputs, we can create a new function. For example, for x = 1, \[ f(1) + g(1) =3 + 5 = 8\nonumber \] For x = 2, if \(f(2) = 1\) and \(g(2) =4\), then the sum of outputs \[f(2) + g(2) = 1 + 4 = 5 \nonumber \] For x = 3, if \(f(3) = 2\) and \(g(3) = -1\), then the sum of outputs \[f(3) + g(3) = 2 + -1 = 1 \nonumber \] For x = 4, if \(f(4) = 6\) and \(g(4) =2\), then the sum of outputs \[f(4) + g(4) = 6 + 2 = 8 \nonumber \] For x = 5, if \(f(5) = 0\) and \(g(5) = -2\), then the sum of outputs \[f(5) + g(5) = 0 + -2 = -2 \nonumber \] In general, the formula for this function can be written as \(y= f(x) + g(x)\). We call this function the sum function . For the function name we use the expression \(f+g\) as opposed to a single letter to indicate that it is the function which is the sum of the outputs of \(f\) and \(g\).
Definition: Function Arithmetic
Suppose \(f\) and \(g\) are functions and \(x\) is in both the domain of \(f\) and the domain of \(g\). The domain of the combination function is the intersection of the two domains.
- The sum function \(f+g\) adds the outputs of \(f\) and \(g\) and is defined by the formula \[(f+g)(x) = f(x) + g(x) \nonumber \]
- The difference function \(f-g\) subtracts the outputs of \(f\) and \(g\) and is defined by the formula \[(f-g)(x) = f(x) - g(x) \nonumber \]
- The product function \(fg\) multiplies the outputs of \(f\) and \(g\) and is defined by the formula \[(fg)(x) = f(x) \cdot g(x) \nonumber \]
- The quotient function \(\dfrac{f}{g}\) divides the outputs of \(f\) and \(g\) and is defined by the formula \[\left(\dfrac{f}{g}\right)(x) = \dfrac{f(x)}{g(x)}, \qquad \text{ provided } g(x) \neq 0 \nonumber \]
The functions \(f(x)\) and \(g(x)\) are given in the table below. Use the tables to evaluate the following
- \((f+g)(3)\)
- \((f \cdot g)(2)\)
- \(\left(\dfrac{f}{g}\right)(1) \)
- \(\left(\dfrac{f}{g}\right)(4) \)
| x | 1 | 2 | 3 | 4 |
| \(f(x)\) | 4 | 3 | 1 | -1 |
| \(g(x)\) | 2 | 5 | 2 | 0 |
Solution
- \((f+g)(3) = f(3)+g(3) = 1 + 2 = 3 \)
- \((f \cdot g)(2) - (f(2))(g(2)) = (3)(5) = 15\)
- \(\left(\dfrac{f}{g}\right)(1) = \dfrac{f(1)}{g(1)} = \dfrac{4}{2} = 2 \)
- \(\left(\dfrac{f}{g}\right)(4) = \dfrac{f(4)}{g(4)} = \dfrac{-1}{0}\) is undefined.
Be careful. We can't input values of x into the quotient function that give a zero in the denominator even though they might be valid inputs of \(f\) and \(g\) in their respective domains.
The functions \(h(x)\) and \(h(x)\) are given in the table below. Use the tables to evaluate the following
- \((h-k)(2)\)
- \((h \cdot k)(1)\)
- \(\left(\dfrac{k}{h}\right)(4) \)
Solution
- \((h-k)(2) = h(2)-k(2) = 5 - 2 = 3 \)
- \((h \cdot k)(1) - (h(1))(k(1)) = (4)(3) = 12\)
- \(\left(\dfrac{k}{h}\right)(4) = \dfrac{k(4)}{h(4)} = \dfrac{0}{1} = 0 \)
Example \(\PageIndex{3}\)
Given the functions \(f(x)=x−1\) and \(g(x)=x^2−1\).
- Evaluate \((f+g)(2)\)
- Evaluate \( \left(\dfrac{f}{g}\right) (3)\)
- Find a formula for the sum function \((f+g)(x)\) in terms of x.
- Find a formula for the quotient function \( \left(\dfrac{f}{g}\right)(x)\) in terms of x.
Solution.
- Adding the outputs of \(f\) and \(g\) at \(x=2\), we have \[(f+g)(2) = f(2) + g(2) = (2-1) + (2^2-1) = 1 + 3 = 4 \nonumber \]
- Dividing the outputs of \(f\) and \(g\) at \(x=3\), we have \[\left(\dfrac{f}{g}\right)(3) = \dfrac{f(3)}{g(3)} = \dfrac{3-1}{3^2-1} = \dfrac{2}{8} = \dfrac{1}{4} \nonumber \]
- Adding the outputs of \(f\) and \(g\) for a general input \(x\) and collecting like terms, we have \[(f+g)(x) = f(x) + g(x) = (x-1) - (x^2-1) = x-1 - x^2+1 = -x^2+x \nonumber \]
- Dividing the outputs of \(f\) and \(g\)for a general input \(x\), we have \[\left(\dfrac{f}{g}\right)(x) = \dfrac{f(x)}{g(x)} = \dfrac{x-1}{x^2-1} \nonumber \] Then simplifying \[ = \dfrac{(x-1)}{(x-1)(x+1)} = \dfrac{1}{x+1} \nonumber \] provided the the input \(x \ne 1\) and \(x \ne -1\).
In part (c) of the last example, the domain of the sum function is the set of all inputs that are defined inputs of both \(f\) and \(g\). Since the \(f\) and \(g\) are both defined for all real numbers and there is no restriction on adding the two nermical outputs, the domain of \((f+g)(x)\) is \( (-\infty,\infty) \).
In part (d) of the last example, the domain of the quotient function is the set of all inputs that are defined inputs of both \(f\) and \(g\) that do not make the denominator zero. Since the \(f\) and \(g\) are both defined for all real numbers, the only restrictions on the input are those which make the denominator zero, \(x \ne 1\) and \(x \ne -1\). Therefore, the domain of \( \left(\dfrac{f}{g}\right) \) is all real numbers where \(x \ne 1\) and \(x \ne -1\). Be careful here. The simplified form of the quotient function by itself is defined at \(x=1\). However, since it is equivalent to the original form of the quotient function, we must have \(x \ne 1\) also.
Now you Try \(\PageIndex{1}\)
Suppose a manufacturer \( f(x)=2x+1 \) and \(g(x)=x^2+2x \).
- Evaluate \((f-g)(1)\)
- Evaluate \((f \cdot g)(3)\)
- Find a formula for the difference function \((f - g)(x)\) in terms of x.
- Find a formula for the product function \((f \cdot g)(x)\) in terms of x.
- Answer
-
a. \((f-g)(1) = f(1) - g(1) = 0 \)
b. \((f \cdot g)(3) = f(3) \cdot g(3) = 105 \)
c. \((f - g)(x) = -x^2-1\)
d. \((f \cdot g)(x) = 2x^3+5x^2+2x\)
In some cases it may be easier to build a function to describe a relationship in an application using a combination of two simpler functions as shown in the two examples below.
Example \(\PageIndex{4}\):
Suppose a manufacturer uses test market data to determine that the price \(p\) they can charge for an item is related to the number of items \(x\) they can sell by the function \(p = 100 - 0.0001x\). Furthermore, the cost of producing the items is given by the function \(C(x) = 350,000 + 30x\).
- Find a formula for the revenue \(R(x)\) in terms of the number of items sold.
- Find a formula for the profit \(P(x)\) in terms of the number of items sold.
- Find the profit from selling and producing 8000 items.
Solution
- Since revenue typically is regarded as the total sales, we can calculate the revenue from selling \(x\) items at a price \(p\) as follows\[R(x)= (\text{price})(\text{number of items sold}) = px = (100 - 0.0001x)x \nonumber \] \[R(x)= 100x - 0.0001x^2 \nonumber \]
- We can calculate the profit from selling \(x\) items as a price \(p\) using the revenue and cost as follows\[P(x)= (\text{Revenue})-(\text{Cost}) = R(x) - C(x) = (100x - 0.0001x^2) - (350,000+3x) \nonumber \] Then subtracting and simplifying our formula is \[P(x) = 100x - 0.0001x^2 -350,000 -30x \nonumber\] \[ = - 0.0001x^2 + 70x -350,000 \nonumber\]
- \(P(8000) = - 0.0001(8000)^2 + 70(8000) -350,000 = 203,600\)
Notice how much simpler it was to develop the formula for profit from the revenue and cost functions than building the profit function from scratch.
Suppose the population of a country is 2 million and is projected to grow by 4% per year. The population in \(t\) years can be modeled by the function \(P(t) = 2(1.04)^t\). The number of people the country's agricultural output can feed is 4 million and is projected to grow by 0.5 million people per year as more land is turned into farmland and agricultural techniques are improved. The number of people the country can feed in \(t\) years can be modeled by the function \(N(t) = 4 + 0.5t\). In order to compare the relative prosperity of two countries with regard to their food supply and population, economists could build a prosperity index in t years as the ratio of the number of people the country's agricultural output can feed to the population where \[R(t) = \dfrac{\text{Number of people fed}}{\text{Population}} \nonumber \]
- Find a formula for the prosperity index \(R(t)\) in terms of \(t\).
- Find the prosperity index in 5 years. Interpret the meaning of your result in the context of this application.
Solution
- The prosperity index is a quotient function \[R(t) = \dfrac{N(t)}{P(t)} = \dfrac{4 + 0.5t}{2(1.04)^t} \nonumber \]
- The prosperity in 5 years \[R(5) = \dfrac{2(1.04)^5}{4 + 0.5(5)} = \approx 2.67 \nonumber \] Since the prosperity index in five years \(R(5)>1\), the country can feed its population with its agricultural output and export the rest.
Focus: Compositions of Functions
Let's explore another way of building a new function from old one's using a composition of two functions. Since both the inputs and the outputs of many functions are real numbers, we can use the output of one function as the input of another function. For example with two functions \(f\) and \(g\) where \(g(2) = 5\) and \(f(5) =12\) we can use the output of \(g\) at \(x=2\) as the input of \(f\). \[f(\text{output of g}) = f(g(2)) = f(5) = 12\nonumber \] Suppose that \(g(1) = 3\) and \(f(3) =7\). Then we can use the output of \(g\) at \(x=1\) as the input of \(f\) once again. \[f(\text{output of g}) = f(g(1)) = f(3) = 7\nonumber \] If we use the output of \(g\) at each value of \(x\) in its domain as the input of \(f\), we can create a new function. Suppose the functions \(f\) and \(g\) are given in the tables below
| \(x\) | 1 | 2 | 3 | 4 | 5 |
| \(g(x)\) | 3 | 5 | 2 | 1 | 4 |
| \(x\) | 1 | 2 | 3 | 4 | 5 |
| \(f(x)\) | 6 | 1 | 7 | 3 | 12 |
Then using the output of \(g\) at each value of \(x\) in its domain as the input of \(f\)
| \(x\) | 1 | 2 | 3 | 4 | 5 |
| \(g(x)\) | 3 | 5 | 2 | 1 | 4 |
| \(y = f(g(x))\) | \(f(3)=7\) | \(f(5)=12\) | \(f(2)=1\) | \(f(1)=6\) | \(f(4)=3\) |
This gives us a new function that is different from \(f\) and \(g\) where
| \(x\) | 1 | 2 | 3 | 4 | 5 |
| \(y\) | 7 | 12 | 1 | 6 | 3 |
We call a function created in this manner a composition of functions.
Definition: Composition of Functions
The composition of two functions \(f\) and \(g\) is a function created using the output of one function \(g\) as the input of another function \(f\). We write \(f(g(x))\), and read this as “\(f\) of \(g\) of \(x\)” or “\(f\) composed with \(g\) at \(x\)”.
We give this function the name \((f \circ g)\) where \((f \circ g)(x) = f(g(x)) \).
Be careful, if we do a multistep process in a different order we may get a different result. For example, in the process of putting on your shoes, there three steps done in this order: (1) Put on your socks (2) Put on your shoes (3) Tie your laces. If you do those steps in a different order, such as (1) Put on your shoes (2) Tie your laces (3) Put on your socks, we get a very different and comical result with our socks covering our shoes.
With a composition of functions, the order of composition matters. If we compose the functions in a different order, we may get a different result. If we use the output of the function \(f\) as the input of the function \(g\) given in the tables above, we create a different function than the first composition \((f \circ g)(x) = f(g(x)) \).
| \(x\) | 1 | 2 | 3 | 4 | 5 |
| \(f(x)\) | 6 | 1 | 7 | 3 | 12 |
| \(y = g(f(x))\) | \(g(6)\) is not defined | \(g(1)=3\) | \(g(7)\) is not defined | \(g(3) = 2\) | \(g(12)\) is not defined |
This function we give the name \((g \circ f)\) where \((g \circ f)(x) = g(f(x)) \).
The order in which you compose two functions matters. If you compose two functions in a different order, you may get a different function.
Also, notice that some of the outputs of \(f\) are numbers that are not defined as inputs for the function \(g\). Therefore, we must restrict the domain of \((g \circ f)(x) = g(f(x)) \) to the inputs of \(f\) where whose outputs \(f(x)\) are defined inputs of \(g\). In the example above, the domain of \((f \circ g)\) is D = {1,3}.
The domain of the composition \((f \circ g)(x) = f(g(x)) \) must be restricted to the inputs of \(g\) where the outputs \(g(x)\) are defined inputs of \(f\).
Let's build some more functions with compositions.
Example \(\PageIndex{6}\)
The functions \(h\) and \(k\) are given in the tables below.
| \(x\) | 1 | 2 | 3 | 4 |
| \(h(x)\) | 3 | 5 | 2 | 7 |
| \(k(x)\) | 6 | 8 | 3 | 1 |
- Evaluate \((k \circ h)(3)\)
- Evaluate \((h \circ k)(4)\)
- Evaluate \((k \circ h)(4)\)
- Build a table that defines the composition \((k \circ h)(x)\)
Solution
- To evaluate \((k \circ h)(3) = k(h(3))\), we start by evaluate the inside expression \(h(3)\) using the table where \(h(3) = 2\). We can then use that result as the input to the \(k\) function, so \[k(h(3))=k(2)=8 \nonumber\]
- To evaluate \( (h \circ k)(4) =h(k(4))\), we first evaluate the inside expression \(k(4)\)using the first table \(k(4) = 1\). Then using the table for \(h\) we can evaluate \[h(k(4))=h(1)=3 \nonumber\]
- To evaluate \((k \circ h)(4) = k(h(4))\), we start by evaluate the inside expression \(h(4)\) using the table where \( h(4) = 7\). However 7 is not a defined input for the \(k\) function, so \(k(h(4))\) is undefined.
- Using the output of \(h\) as the input of \(k\) for each possible
| \(x\) | 1 | 2 | 3 | 4 |
| \(h(x)\) | 3 | 5 | 2 | 7 |
| \(k(h(x))\) | 3 | \(k(5)\) is not defined | 8 | \(k(7)\) is not defined |
Example \(\PageIndex{7}\)
The functions \(f\) and \(g\) are given in the tables below.
- Evaluate \((f \circ g)(1)\)
- Evaluate \((f \circ g)(3)\)
- Evaluate \((g \circ f)(1)\)
Solution
- To evaluate \((f \circ g)(1) = f(g(1))\), we start by using the graph of \(g\) to identify \(g(1)\), where we have \(g(1) = 3\). Using that result as the input to the \(f\) function, the graph of \(f\) gives us \[f(g(1))=f(3)=6 \nonumber\]
- To evaluate \( (f \circ g)(4) =f(g(4))\), we start by using the graph of \(g\) to identify \(g(4)\), where we have \(g(4) = 0\). Using that result as the input to the \(f\) function, the graph of \(f\) gives us \[f(g(4))=f(0)=-3 \nonumber\]
- To evaluate \((g \circ f)(4) = g(f(4))\), we start by using the graph of \(f\) to identify \(f(4)\), where we have \(f(4) = 5\). Using that result as the input to the \(g\) function, the graph of \(g\) gives us \[g(f(4))=g(5)=3 \nonumber\]
Now You Try: Exercise \(\PageIndex{2}\)
The functions \(m\) and \(n\) are given by the set of ordered pairs \((x,y)\) with inputs \(x\) and corresponding outputs \(y\) below.
\(m\) = {(1,2),(2,4),(3,0),(4,1),(5,3)} and \(n\) = {(1,4),(2,5),(3,1),(4,2),(5,11)}
- Evaluate \((m \circ n)(1)\)
- Evaluate \((m \circ n)(2)\)
- Evaluate \((n \circ m)(2)\)
- Build a set of ordered pairs that defines the composition \((n \circ m)\)
- Answer
-
- \((m \circ n)(1) = m(n(1))\) = m(4) = 1
- \((m \circ n)(2) = m(n(2))\) = m(5) = 3
- \((n \circ m)(2) = n(m(2))\) = n(4) = 2
Compositions of Functions Using Formulas
We can also build a new function using a composition with functions.
Example \(\PageIndex{8}\)
Let \(f(x)=2x+1\) and \(g(x)=x^2 + 3\)
- Evaluate \((f \circ g)(2)\)
- Evaluate \((g \circ f)(1)\)
- Evaluate \((f \circ g)(3)\)
- Find a formula for the composition \(f \circ g\) in terms of \(x\).
- Find a formula for the composition \(g \circ f\) in terms of \(x\).
Solution
- To evaluate \((k \circ h)(3) = k(h(3))\), we start by evaluate the inside expression \(h(3)\) using the table where \(h(3) = 2\). We can then use that result as the input to the \(k\) function, so \[k(h(3))=k(2)=8 \nonumber\]
\[h(1) = 3(1) + 2 = 5\nonumber \]
Then \(f(h(1))=f(5)\), so we evaluate the f(t) function at an input of 5:
\[f(h(1)) = f(5) = 5^{2} - 5 = 20\nonumber \]
When evaluating a composition of functions where we have either created or been given formulas, the concept of working from the inside out remains the same. First, we evaluate the inside function using the input value provided, then use the resulting output as the input to the outside function.
Exercise \(\PageIndex{4}\)
Using the functions from the example above, evaluate \(h(f(-2))\).
- Answer
-
\(h(f(-2)) = h(6) = 20\) ( did you remember to insert your input values using parentheses? )
While we can compose the functions as above for each individual input value, sometimes it would be really helpful to find a single formula which will calculate the result of a composition f(g(x)) . To do this, we will extend our idea of function evaluation. Recall that when we evaluate a function like \(f(t)=t^{2} -t\), we put whatever value is inside the parentheses after the function name into the formula wherever we see the input variable.
Example \(\PageIndex{6}\)
Given \(f(t) = t^{2} - t\), evaluate \(f(3)\) and \(f(-2)\).
Solution
\[ \begin{align*} f(3) &= 3^2 - 3 \\[4pt] f(-2) &= (-2)^2 - (-2)\end{align*} \]
We could simplify the results above if we wanted to
\[ \begin{align*} f(3) &= 3^2 - 3 = 9 - 3 = 6 \\[4pt] f(-2) &= (-2)^2 - (-2) = 4 + 2 = 6 \end{align*}\]
We are not limited, however, to using a numerical value as the input to the function. We can put anything into the function: a value, a different variable, or even an algebraic expression, provided we use the input expression everywhere we see the input variable.
Example \(\PageIndex{7}\)
Using the function from the previous example, evaluate f(a).
Solution
This means that the input value for \(t\) is some unknown quantity \(a\). As before, we evaluate by replacing the input variable \(t\) with the input quantity, in this case \(a\).
\[f(a)=a^{2} - a\nonumber \]
The same idea can then be applied to expressions more complicated than a single letter.
Example \(\PageIndex{8}\)
Using the same \(f(t)\) function from above, evaluate \(f(x + 2)\).
Solution
Everywhere in the formula for f where there was a t , we would replace it with the input \((x+2)\). Since in the original formula the input t was squared in the first term, the entire input \(x+2\) needs to be squared when we substitute, so we need to use grouping parentheses . To avoid problems, it is advisable to always use parentheses around inputs.
\[f(x+2)=(x+2)^{2} -(x+2)\nonumber \]
We could simplify this expression further to \(f(x+2)=x^{2} +3x+2\) if we wanted to:
\[f(x+2)=(x+2)(x+2)-(x+2)\nonumber \]
Use the “FOIL” technique (first, outside, inside, last)
\[f(x+2)=x^{2} +2x+2x+4-(x+2)\nonumber \]
distribute the negative sign
\[f(x+2)=x^{2} +2x+2x+4-x-2\nonumber \]
combine like terms
\[f(x+2)=x^{2} +3x+2\nonumber \]
Example \(\PageIndex{9}\)
Using the same function, evaluate \(f(t^{3} )\).
Solution
Note that in this example, the same variable is used in the input expression and as the input variable of the function. This doesn’t matter – we still replace the original input t in the formula with the new input expression, \(t^{3}\).
\[f(t^{3} )=(t^{3} )^{2} -(t^{3} )=t^{6} - t^{3}\nonumber \]
Exercise \(\PageIndex{5}\)
Given \(g(x) = 3x - \sqrt{x}\), evaluate \(g(t - 2)\).
- Answer
-
\[g(t - 2) = 3(t - 2) - \sqrt{(t - 2)}\nonumber \]
This now allows us to find an expression for a composition of functions. If we want to find a formula for \(f(g(x))\), we can start by writing out the formula for \(g(x)\). We can then evaluate the function \(f(x)\) at that expression, as in the examples above.
Example \(\PageIndex{10}\)
Let \(f(x)=x^{2}\) and \(g(x)=\dfrac{1}{x} -2x\), find \(f(g(x))\) and \(g(f(x))\).
Solution
To find \(f(g(x))\), we start by evaluating the inside, writing out the formula for \(g(x)\).
\[g(x)=\dfrac{1}{x} -2x\nonumber \]
We then use the expression \((\dfrac{1}{x} -2x)\) as input for the function \(f\).
\[f(g(x)) = f(\dfrac{1}{x} - 2x)\nonumber \]
We then evaluate the function \(f(x)\) using the formula for \(g(x)\) as the input.
Since \(f(x)=x^{2}\),
\[f(\dfrac{1}{x} -2x) = (\dfrac{1}{x} - 2x)^{2}\nonumber \]
This gives us the formula for the composition:
\[f(g(x)) = (\dfrac{1}{x} - 2x)^{2}\nonumber \]
Likewise, to find g(f(x)), we evaluate the inside, writing out the formula for f(x)
\[g(f(x))=g(x^{2})\nonumber \]
Now we evaluate the function g(x) using \(x^{2}\) as the input.
\[g(f(x))=\dfrac{1}{x^{2} } -2x^{2}\nonumber \]
Exercise \(\PageIndex{6}\)
Let \(f(x) = x^{3} +3x\) and \(g(x)=\sqrt{x}\), find \(f(g(x))\) and \(g(f(x))\).
- Answer
-
\[f(g(x) = f(\sqrt{x}) = (\sqrt{x})^3 + 3(\sqrt{x})\nonumber \]
\[g(f(x) = g(x^3 + 3x) = \sqrt{(x^3 + 3x)}\nonumber \]
Example \(\PageIndex{11}\)
Domain of Compositions
When we think about the domain of a composition \(h(x)=f(g(x))\), we must consider both the domain of the inner function and the domain of the composition itself. While it is tempting to only look at the resulting composite function, if the inner function were undefined at a value of \(x\), the composition would not be possible.
Example \(\PageIndex{12}\)
Let \(f(x)=\dfrac{1}{x^{2} -1}\) and \(g(x)=\sqrt{x-2}\). Find the domain of \(f(g(x))\).
Since we want to avoid the square root of negative numbers, the domain of \(g(x)\) is the set of values where \(x - 2 \ge 0\). The domain is \(x \ge 2\).
The composition is \[f(g(x))=\dfrac{1}{(\sqrt{x-2})^{2} - 1} = \dfrac{1}{(x - 2)-1} = \dfrac{1}{x - 3}\nonumber \].
The composition is undefined when \(x = 3\), so that value must also be excluded from the domain. Notice that the composition doesn’t involve a square root, but we still have to consider the domain limitation from the inside function.
Combining the two restrictions, the domain is all values of x greater than or equal to 2, except \(x = 3\).
In inequalities, the domain is: \(2 \le x<3\) or \(x > 3\)
In interval notation, the domain is: \([2, 3) \cup (3, \infty)\).
Exercise \(\PageIndex{7}\)
Let \(f(x) = \dfrac{1}{x-2}\) and \(g(x)=\dfrac{1}{x}\). Find the domain of \(f(g(x))\).
- Answer
-
\(g(x) = \dfrac{1}{x}\) is undefined at \(x = 0\).
The composition, \[f(g(x)) = f(\dfrac{1}{x}) = \dfrac{1}{\dfrac{1}{x} - 2} = \dfrac{1}{\dfrac{1}{x} - \dfrac{2x}{x}} = \dfrac{1}{\dfrac{1 - 2x}{x}} = \dfrac{x}{1 - 2x}\nonumber \] is undefined when \(1 - 2x = 0\), when \(x = \dfrac{1}{2}\).
Restricting these two values, the domain is \((-\infty, 0) \cup (0, \dfrac{1}{2}) \cup (\dfrac{1}{2}, \infty)\)
Decomposing Functions
In some cases, it is desirable to decompose a function – to write it as a composition of two simpler functions.
Example \(\PageIndex{13}\)
Write \(f(x)=3+\sqrt{5 - x^{2} }\) as the composition of two functions.
Solution
We are looking for two functions, \(g\) and \(h\), so \(f(x) = g(h(x))\). To do this, we look for a function inside a function in the formula for \(f(x)\). As one possibility, we might notice that \(5 - x^{2}\) is the inside of the square root. We could then decompose the function as:
\[h(x)=5-x^{2}\nonumber \]
\[g(x)=3+\sqrt{x}\nonumber \]
We can check our answer by recomposing the functions:
\[g(h(x)) = g(5 - x^{2})=3 + \sqrt{5-x^2 }\nonumber \]
Note that this is not the only solution to the problem. Another non-trivial decomposition would be \(h(x) = x^{2}\) and \(g(x) = 3 + \sqrt{5-x}\)
Composition of Function
Evaluating Composite Functions
When working with functions given as tables, graphs, and formulas we can look up values for the functions using a provided table, graph, or formula. Start evaluation with the inside function. Then use the output of the inside function as the input to the outside function. To remember this, always work from the inside out - just like with order of operations.
Evaluate Composite Functions Using Formulas
When evaluating a composite function where we have either created or been given formulas, the rule of working from the inside out remains the same. The input value to the outer function will be the output of the inner function, which may be a numerical value, a variable name, or a more complicated expression.
How to: Evaluate a Composition \( (f \circ g)(c) \).
- Write the definition for the composition function: \((f \circ g)(c) = f(g(c)) \).
- Substitute \(c\) in the function definition for \(g\) to evaluate the inside function \(g(c)\). Let \(k\) be this result: \((f \circ g)(c) = f(g(c))=f(k) \).
- Substitute \(k\) in the function definition for \(f\) to evaluate the outside function
Example \(\PageIndex{24}\): Evaluate a Composition of Functions Expressed as Formulas with a Numerical Input
Given \(f(t)=t^2−t\) and \(h(x)=3x+2\), evaluate \( (f \circ h)(1))\).
Solution
Rewrite \( (f \circ h)(1))\) using the definition: \( (f \circ h)(1)) = f(h(1))\)
The inside expression is \(h(1)\). The argument of \(h\) is \(1\), so substitute \(1\) for \(x\) in the formula for \(h\) and evaluate it.
\[ \begin{align*} h(1)&=3(1)+2 \\[4pt] h(1)&=5 \end{align*} \]
Now \(f(h(1))=f(5)\). The argument of \(f\) is \(5\) so substitute \(5\) for \(t\) in the formula for \(f\) and evaluate it.
\[ \begin{align*} f(h(1)) &=f(5) \\[5pt] f(h(1))&=5^2−5 \\[5pt] f(h(1))&=20 \end{align*} \]
Analysis
It makes no difference what the input variables \(t\) and \(x\) were called in this problem because we evaluated for specific numerical values.
Example \(\PageIndex{25}\): Evaluating a Composition of Functions Expressed as Formulas with a Numerical Input
Given \(f(x) = x^2-4x\), \(g(x) = 2-\sqrt{x+3}\), and \(h(x) = \dfrac{2x}{x+1}\) evaluate the following.
- \((g \circ f)(1) \qquad \) b. \((f \circ g)(1) \qquad \) c. \((g \circ g)(6) \qquad \) d. \((g \circ f)(2) \qquad \) e. \((g \circ h)(-1) \qquad \)
Solution
a. Use the definition: \((g \circ f)(1) = g(f(1))\).
\(\quad\) Evaluate the inner function: \(f(1) = -3\)
\(\quad\) Evaluate the outer function using this result: \( g(f(1)) = g(-3) = 2 \)
b. Use the definition to write \((f \circ g)(1) = f(g(1))\).
\(\quad\) Evaluate the inner function: \(g(1) = 0\),
\(\quad\) Evaluate the outer function using this result: \(f(g(1)) = f(0) = 0 \)
c. Use the definition \((g \circ g)(6) = g(g(6))\).
\(\quad\) Evaluate the inner function: \(g(6) = -1\)
\(\quad\) Evaluate the outer function using this result: \( g(g(6)) = g(-1) = 2-\sqrt{2} \)
d. Use the definition: \((g \circ f)(2) = g(f(2))\)
\(\quad\) Evaluate the inner function: \(f(2) = (2)^2-4(2)=4-8=-4\)
\(\quad\) Evaluate the outer function using this result: \(g(f(2)) = g(-4) = 2-\sqrt{-4+3} =2-\sqrt{-1} = 2-i\). This result is not a real number, so we say \((g \circ f)(2) \) is undefined.
e. Use the definition: \((g \circ h)(-1) = g(h(-1))\)
\(\quad\) Evaluate the inner function: \(h(-1) = \dfrac{2(-1)}{(-1)+1}= \dfrac{-2}{0} = \text{undefined}\)
\(\quad\) Evaluate the outer function: \( g(h(-1)) =g(\text{undefined}) \) cannot be evaluated! So \((g \circ h)(-1) = \text{undefined}\).
Try It \(\PageIndex{26}\)
Given \(f(t)=t^2−t\) and \(h(x)=3x+2\), evaluate
a. \(h(f(2))\)
b. \(h(f(−2))\)
- Answers:
-
a. 8 \( \qquad \) b. 20
Finding the Formula and Domain of a Composite Function
While we can compose the functions for each individual input value, it is sometimes helpful to find a single formula that will calculate the result of a composition \((f \circ g)(x)\). To do this, we will extend our idea of function evaluation. Recall that, when we evaluate a function with a formula like \(f(t)=t^2−t\), we substitute the value inside the parentheses (called the argument) into the formula wherever we see the input variable.
The domain of a composite function such as \(f{\circ}g\) is dependent on the domain of \(g\) and the domain of \(f\). It is important to know when we can apply a composite function and when we cannot, that is, to know the domain of a function such as \(f{\circ}g\). If we write the composite function for an input \(x\) as \(f(g(x))\), we can see right away that \(x\) must be a member of the domain of \(g\) in order for the expression to be meaningful, because otherwise we cannot complete the inner function evaluation. Secondly, the outer function evaluation, \(f(g(x))\), must also be defined. Thus the restrictions to the domain of \(f{\circ}g\) consist of not only the values of \(x\) that make \(g(x)\) undefined, but also the values of \(x\) that make the expression \(f(g(x))\) undefined.
How to: Determine a Function Composition \( (f \circ g)(x) \) and its Domain.
- Write the definition for the composition function: \((f \circ g)(x) = f(g(x)) \).
-
Substitute the function definition for \(g\) in for the argument of \(f\).
Determine the domain of \(g\) because the argument to \(f\) must be defined during the composition process. - Substitute the argument expression \(g(x)\) into the function definition for \(f\) to determine the formula for \((f \circ g)(x)\).
- Simplify the formula for \((f \circ g)(x)\).
- The domain of \((f \circ g)(x)\) combines both the domain restrictions to the inner function and the domain restrictions apparent in the resulting function. It is important to include the domain restrictions to \(g\) because sometimes they get lost in the simplification process (step 4).
Example \(\PageIndex{27}\): Finding a composition and its domain
Given \(f(x)=5x−1 \) and \( g(x)=\dfrac{4}{3x−2}\) find \((f∘g)(x)\) and its domain.
Solution: 1. \((f∘g)(x) = f(g(x))\)
2. \(f(g(x)) = f \Big(\dfrac{4}{3x−2} \Big) \). The domain of \(g(x)\) consists of all real numbers except \(x=\frac{2}{3}\), since that input value would cause us to divide by 0.
3. \( f \Big(\dfrac{4}{3x−2} \Big) = 5\Big(\dfrac{4}{3x−2} \Big) -1 \). Notice in this form the domain restriction \(x \ne \frac{2}{3}\)
4. \(5\Big(\dfrac{4}{3x−2} \Big) -1 = 5\Big(\dfrac{4}{3x−2} \Big) - \dfrac{3x−2}{3x−2} = \dfrac{20 -3x+2}{3x−2} =\dfrac{22-3x}{3x−2} \)
5. The domain restriction of the simplified expression is still \(x \ne \frac{2}{3}\).
Answer: \((f∘g)(x) = \dfrac{22-3x}{3x−2}\) and its domain is \( (−\infty,\dfrac{2}{3}) \cup (\dfrac{2}{3},\infty) \)
Example \(\PageIndex{28}\)
Given \(f(x)=\sqrt{x+2}\) and \(g(x)=\sqrt{3−x}\) find \((f∘g)(x)\) and its domain.
Solution: 1. \((f∘g)(x) = f(g(x))\)
2. \(f(g(x)) = f (\sqrt{3−x})\). The domain restriction for \(g\) is \(3-x \ge 0 \longrightarrow 3 \ge x \longrightarrow x \le 3\)
3. \(f (\sqrt{3−x})= \sqrt{\sqrt{3−x}+2}\)
4. This expression cannot be simplified.
5. The domain restriction for this expression is \(\sqrt{3−x}+2 \ge 0\). As long as \(\sqrt{3-x}\) is a real number, \(\sqrt{3−x} \ge 0\) so \(\sqrt{3−x}+2 \ge 2\). The expression \(\sqrt{3-x}\) is a real number whenever \(3-x \ge 0\) or \(x \le 3\).
Answer: \((f∘g)(x)=\sqrt{ \sqrt{3−x}+2}\) and its domain is \((-∞,3]\).
Example \(\PageIndex{29}\)
Let \(f(x) = x^2-4x\), \(g(x) = 2-\sqrt{x+3}\), and \(h(x) = \dfrac{2x}{x+1}\). Find and simplify the indicated composite functions. State the domain of each.
- \((f \circ g)(x)\)
- \((h \circ g)(x)\)
- \((h \circ h)(x)\)
Solution
a. \(\quad \;\)1. \((f \circ g)(x)= f(g(x))\)
2. \(f(g(x)) = f(2-\sqrt{x+3})\). The domain of \(g\) is \( x+3 \ge 0 \longrightarrow x \ge -3\)
\( \begin{array}{rrll}
3.& f(2-\sqrt{x+3}) &= (2-\sqrt{x+3})^2 - 4(2-\sqrt{x+3}) \\
4.& &= 4 - 4 \sqrt{x+3} + (\sqrt{x+3})^2 - 8 + 4\sqrt{x+3} \\
&&= 4 + x + 3 - 8\\
&&= x-1
\end{array}\)
5. The resulting expression has no domain restrictions, but the domain restriction found for \(g\) still applies to the composition process.
Answer: \((f \circ g)(x)= x-1\) with a domain of \([-3, \infty)\)
b. \(\quad \;\)1. \((h \circ g)(x) = h(g(x))\)
2. \(h(g(x)) = h (2-\sqrt{x+3})\). The domain of \(g\) here is \(x+3 \ge 0 \longrightarrow x \ge -3\).
\( \begin{array}{rrll}
3.& h (2-\sqrt{x+3})&=\dfrac{2(2-\sqrt{x+3})}{(2-\sqrt{x+3})+1} \\
4.& &= \dfrac{4-2\sqrt{x+3}}{3-\sqrt{x+3}} &\text{Simplify} \\
& &= \dfrac{4-2\sqrt{x+3}}{3-\sqrt{x+3}}\cdot \dfrac{3+\sqrt{x+3}}{3+\sqrt{x+3}} &\text{Rationalize denominator} \\
& &= \dfrac{12+4\sqrt{x+3}-6\sqrt{x+3}-2(x+3)}{9-(x+3)} &\text{Multiply out and simplify} \\
& &= \dfrac{6-2x-2\sqrt{x+3}}{6-x} \\
\end{array}\)
5. The resulting expression has two domain restrictions: \(x+3 \ge 0 \) and \( 6-x \ne 0 \). Therefore, \(x \ge -3\) and \(x \ne 6\). Both of these restrictions apply to the composition process. The domain restriction to \(g\) found earlier is repeated here.
Answer: \((h \circ g)(x) = = \dfrac{4-2\sqrt{x+3}}{3-\sqrt{x+3}}\) with a domain of \([-3,6) \cup (6, \infty)\).
c. \(\quad \;\)1. \((h \circ h)(x) = h(h(x))\).
2. \( h(h(x)) = h \Big( \dfrac{2x}{x+1}\Big) \). The domain of \(h\) here is \(x + 1 \ne 0 \longrightarrow x \ne -1\).
\(\begin{array}{rrll}
3. & h \left( \dfrac{2x}{x+1} \right) &= \dfrac{2\Big( \dfrac{2x}{x+1} \Big)}{\Big( \dfrac{2x}{x+1} \Big) + 1 }\\
\end{array}\)
\(\begin{array}{rrll}
4.& \qquad \qquad \qquad \qquad &= \dfrac{ \Big( \dfrac{4x}{x+1} \Big)}{\Big( \dfrac{2x}{x+1} \Big) + 1 }\cdot \dfrac{x+1}{x+1} &\text{Simplify complex fraction}\\
&&= \dfrac{ \Big( \dfrac{4x}{x+1} \Big) \cdot (x+1)}{\Big( \dfrac{2x}{x+1} \Big)\cdot (x+1) + 1\cdot (x+1) }\\
&&= \dfrac{4x}{2x+x+1} = \dfrac{4x}{3x+1}
\end{array}\)
5. The resulting expression has one domain restriction, \( 3x+1 \ne 0\). Therefore, \(x \ne \frac{1}{3}\). The domain of the composition process includes not only this domain but also the domain restriction to \(h\) found earlier: \(x \ne -1\)
Answer: \((h \circ h)(x) =\dfrac{4x}{3x+1}\) and its domain is \((-\infty, -1) \cup \left(-1, -\frac{1}{3}\right) \cup \left(-\frac{1}{3}, \infty\right)\).
Try It \(\PageIndex{30}\)
Find and simplify \((f∘g)(x)\) and find its domain given
- \(f(x)=\dfrac{1}{x−2} \text{ and } g(x)=\sqrt{x+4}\)
- \( f(x)=\dfrac{4}{3x−2}\) and \(g(x)=\dfrac{1}{x-1}\)
- Answers
-
a. \((f∘g)(x) = \dfrac{2+\sqrt{x+4}}{x}\) with domain \([−4,0)∪(0,∞)\) \(\qquad\) b. \((f∘g)(x) = \dfrac{4(x-1)}{5-2x}\) with domain \((-∞, 1)∪(1, 2.5)∪(2.5,∞)\)
Decomposing a Composite Function into its Component Functions
In some cases, it is necessary to decompose a complicated function. In other words, we can write it as a composition of two simpler functions. There may be more than one way to decompose a composite function , so we may choose the decomposition that appears to be most expedient.
Example \(\PageIndex{31}\): Decomposing a Function
Write \(f(x)=\sqrt{5−x^2}\) as the composition of two functions.
Solution
We are looking for two functions, \(g\) and \(h\), so \(f(x)=g(h(x))\). To do this, we look for a function inside a function in the formula for \(f(x)\). As one possibility, we might notice that the expression \(5−x^2\) is the inside of the square root. We could then decompose the function as
\(h(x)=5−x^2 \text{ and } g(x)=\sqrt{x}\)
We can check our answer by recomposing the functions.
\(g(h(x))=g(5−x^2)=\sqrt{5−x^2}\)
Try It \(\PageIndex{32}\)
Write \(f(x)=\dfrac{4}{3−\sqrt{4+x^2}}\) as the composition of two functions.
- Answer
-
Possible answers:
\(g(x)=\sqrt{4+x^2}\)
\(h(x)=\dfrac{4}{3−x}\)
\(f=h{\circ}g\)
Applications of Composite Functions
Suppose we wanted to calculate how much it costs to heat a house on a particular day of the year. The cost to heat a house will depend on the average daily temperature, and the average daily temperature depends on the particular day of the year. Notice how we have just defined two relationships: The temperature depends on the day, and the cost depends on the temperature. Using descriptive variables, we can notate these two functions.
The first function, \(C(T)\), gives the cost \(C\) of heating a house when the average daily temperature is \(T\) degrees Celsius, and the second, \(T(d)\), gives the average daily temperature on day \(d\) of the year in some city. If we wanted to determine the cost of heating the house on the 5 \({}^{th}\) day of the year, we could do this by linking our two functions together, an idea called composition of functions. Using the function \(T(d)\), we could evaluate \(T(5)\) to determine the average daily temperature on the 5 \({}^{th}\) day of the year. We could then use that temperature as the input to the \(C(T)\) function to find the cost to heat the house on the 5 \({}^{th}\) day of the year: \(C(T(5))\).
Example \(\PageIndex{1}\)
Suppose \(c(s)\) gives the number of calories burned doing s sit-ups, and \(s(t)\) gives the number of sit-ups a person can do in t minutes. Interpret \(c(s(3))\).
Solution
When we are asked to interpret, we are being asked to explain the meaning of the expression in words. The inside expression in the composition is \(s(3)\). Since the input to the s function is time, the 3 is representing 3 minutes, and \(s(3)\) is the number of sit-ups that can be done in 3 minutes. Taking this output and using it as the input to the \(c(s)\) function will gives us the calories that can be burned by the number of sit-ups that can be done in 3 minutes.
Note that it is not important that the same variable be used for the output of the inside function and the input to the outside function. However, it is essential that the units on the output of the inside function match the units on the input to the outside function, if the units are specified.
A city manager determines that the tax revenue, \(R\), in millions of dollars collected on a population of \(p\) thousand people is given by the formula \(R(p) = 0.03p + \sqrt{p}\), and that the city’s population, in thousands, is predicted to follow the formula \(p(t) = 60 + 2t + 0.3t^{2}\), where t is measured in years after 2010. Find a formula for the tax revenue as a function of the year.
Solution
Since we want tax revenue as a function of the year, we want year to be our initial input, and revenue to be our final output. To find revenue, we will first have to predict the city population, and then use that result as the input to the tax function. So we need to find \(R(p(t))\). Evaluating this,
\[R(p(t)) = R(60 + 2t + 0.3t^{2} ) = 0.03(60+2t+0.3t^{2}) + \sqrt{60 + 2t + 0.3t^{2} }\nonumber \]
This composition gives us a single formula which can be used to predict the tax revenue during a given year, without needing to find the intermediary population value.
For example, to predict the tax revenue in 2017, when t = 7 (because t is measured in years after 2010),
\[R(p(7))=0.03(60 + 2(7) + 0.3(7)^{2})+ \sqrt{60 + 2(7) + 0.3(7)^{2} } \approx 12.079\text{ million dollars}\nonumber \]
Example \(\PageIndex{16}\): Interpreting Composite Functions
The function \(c(s)\) gives the number of calories burned completing \(s\) sit-ups, and \(s(t)\) gives the number of sit-ups a person can complete in \(t\) minutes. Interpret \(c(s(3))\).
Solution
The inside expression in the composition is \(s(3)\). Because the input to the \(s\)-function is time, \(t=3\) represents 3 minutes, and \(s(3)\) is the number of sit-ups completed in 3 minutes.
Using \(s(3)\) as the input to the function \(c(s)\) gives us the number of calories burned during the number of sit-ups that can be completed in 3 minutes, or simply the number of calories burned in 3 minutes (by doing sit-ups).
Note that it is not important that the same variable be used for the output of the inside function and the input to the outside function. However, it is essential that the units on the output of the inside function match the units on the input to the outside function, if the units are specified.
Example \(\PageIndex{17}\): Investigating the Order of Function Composition
Suppose \(f(x)\) gives miles that can be driven in \(x\) hours and \(g(y)\) gives the gallons of gas used in driving \(y\) miles. Which of these expressions is meaningful: \(f(g(y))\) or \(g(f(x))\)?
Solution
The function \(y=f(x)\) is a function that produces the number of miles driven given the number of hours driven:
\[\text{number of miles } =f (\text{number of hours}) \nonumber\]
The function \(g(y)\) is a function that produces the number of gallons used given the number of miles driven:
\[\text{number of gallons } =g(\text{number of miles}) \nonumber\]
Consider the composition \(f(g(y))\). The expression \(g(y)\) takes miles as the input and a number of gallons as the output. The function \(f(x)\) requires a number of hours as the input. Trying to input a number of gallons into \(f\) does not make sense. The expression \(f(g(y))\) is meaningless.
Consider the composition \(g(f(x))\). The expression \(f(x)\) takes hours as input and a number of miles driven as the output. The function \(g(y)\) requires a number of miles as the input. Using \(f(x)\) (miles driven) as an input value for \(g(y)\), where gallons of gas depends on miles driven, does make sense. The expression \(g(f(x))\) makes sense, and will yield the number of gallons of gas used, \(g\), driving a certain number of miles, \(f(x)\), in \(x\) hours.
Try It \(\PageIndex{18}\)
In a department store you see a sign that says 50% off clearance merchandise, so final cost \(C\) depends on the clearance price, \(p\), according to the function \(C(p)\). Clearance price, \(p\), depends on the original discount, \(d\), given to the clearance item, \(p(d)\). Interpret \(C(p(d))\).
- Answer
-
The final cost, \(C\), depends on the clearance price, \(p\), which is based on the original discount, \(d\). (Or the original discount \(d\), determines the clearance price and the final cost is half of the clearance price.)
Try It \(\PageIndex{19}\)
The gravitational force on a planet a distance \(r\) from the sun is given by the function \(G(r)\). The acceleration of a planet subjected to any force \(F\) is given by the function \(a(F)\). Form a meaningful composition of these two functions, and explain what it means.
- Answer
-
A gravitational force is still a force, so \(a(G(r))\) makes sense as the acceleration of a planet at a distance \(r\) from the Sun (due to gravity), but \(
Example \(\PageIndex{2}\)
Suppose \(f(x)\) gives miles that can be driven in \(x\) hours, and \(g(y)\) gives the gallons of gas used in driving \(y\) miles. Which of these expressions is meaningful: \(f(g(y))\) or \(g(f(x))\)?
Solution
The expression \(g(y)\) takes miles as the input and outputs a number of gallons. The function \(f(x)\) is expecting a number of hours as the input; trying to give it a number of gallons as input does not make sense. Remember the units must match, and number of gallons does not match number of hours, so the expression \(f(g(y))\) is meaningless.
The expression \(f(x)\) takes hours as input and outputs a number of miles driven. The function \(g(y)\) is expecting a number of miles as the input, so giving the output of the \(f(x)\) function (miles driven) as an input value for \(g(y)\), where gallons of gas depends on miles driven, does make sense. The expression \(g(f(x))\) makes sense, and will give the number of gallons of gas used, \(g\), driving a certain number of miles, \(f(x)\), in \(x\) hours.
Exercise \(\PageIndex{1}\)
In a department store you see a sign that says 50% off clearance merchandise, so final cost \(C\) depends on the clearance price, \(p\), according to the function \(C(p)\). Clearance price, \(p\), depends on the original discount, \(d\), given to the clearance item, \(p(d)\). Interpret \(C(p(d))\).
- Answer
-
The final cost, \(C\), depends on the clearance price, \(p\), which is based on the original discount, \(d\). (Or the original discount \(d\), determines the clearance price and the final cost is half of the clearance price.)