1.4: Composition of Functions
 Page ID
 13830
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{\!\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
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[GrindEQ__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)).
Definition: Composition of Functions
When the output of one function is used as the input of another, we call the entire operation a composition of functionsComposition of FunctionsFunction:Composition of Functions. We write f(g(x)), and read this as “f of g of x” or “f composed with g at x”.
An alternate notation for composition uses the composition operator: \(\circ\)
\((f\circ g)(x)\) is read “f of g of x” or “f composed with g at x”, just like f(g(x)).
Example \(\PageIndex{1}\)
Suppose c(s) gives the number of calories burned doing s situps, and s(t) gives the number of situps a person can do in t minutes. Interpret c(s[GrindEQ__3_]).
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[GrindEQ__3_]. Since the input to the s function is time, the 3 is representing 3 minutes, and s[GrindEQ__3_] is the number of situps 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 situps 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.
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

Add answer text here and it will automatically be hidden if you have a "AutoNum" template active on the page.
Composition of Functions using Tables and GraphsComposition of Functions:Tables and Graphs
When working with functions given as tables and graphs, we can look up values for the functions using a provided table or graph, as discussed in section 1.1. We start evaluation from the provided input, and first evaluate the inside function. We can then use the output of the inside function as the input to the outside function. To remember this, always work from the inside out.
Example \(\PageIndex{1}\)
Using the tables below, evaluate \(f(g(3))\)and \(g(f(4))\) \[63\]
Solution
To evaluate \(f(g(3))\), we start from the inside with the value 3. We then evaluate the inside expression \(g\eqref{GrindEQ__3_}\)using the table that defines the function g: \(g\eqref{GrindEQ__3_}=2\).
We can then use that result as the input to the f function, so \(g\eqref{GrindEQ__3_}\) is replaced by the equivalent value 2 and we can evaluate \(f\eqref{GrindEQ__2_}\). Then using the table that defines the function f, we find that \(f\eqref{GrindEQ__2_}=8\). \[f(g(3))=f(2)=8.\]
To evaluate \(g(f(4))\), we first evaluate the inside expression \(f\eqref{GrindEQ__4_}\)using the first table: \(f\eqref{GrindEQ__4_}=1\). Then using the table for g we can evaluate: \[g(f(4))=g(1)=3.\]
Exercise \(\PageIndex{1}\)
2. Using the tables from the example above, evaluate \(f(g(1))\) and \(g(f(3))\).
 Answer

Add answer text here and it will automatically be hidden if you have a "AutoNum" template active on the page.
Example \(\PageIndex{1}\)
Using the graphs below, evaluate \(f(g(1))\).
To evaluate \(f(g(1))\), we again start with the inside evaluation. We evaluate \(g\eqref{GrindEQ__1_}\) using the graph of the g(x) function, finding the input of 1 on the horizontal axis and finding the output value of the graph at that input. Here, \(g\eqref{GrindEQ__1_}=3\).
Using this value as the input to the f function, \(f(g(1))=f\eqref{GrindEQ__3_}\). We can then evaluate this by looking to the graph of the f(x) function, finding the input of 3 on the horizontal axis, and reading the output value of the graph at this input.
\(f\eqref{GrindEQ__3_}=6\), so \(f(g(1))=6\).
Exercise \(\PageIndex{1}\)
3. Using the graphs from the previous example, evaluate \(g(f(2))\).
 Answer

Add answer text here and it will automatically be hidden if you have a "AutoNum" template active on the page.
Composition using FormulasComposition of Functions:Formulas
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.
Example \(\PageIndex{1}\):
5
Given \(f(t)=t^{2} t\) and \(h(x)=3x+2\), evaluate \(f(h(1))\).
Since the inside evaluation is \(h\eqref{GrindEQ__1_}\)we start by evaluating the h(x) function at 1: \[h(1)=3(1)+2=5\]
Then \(f(h(1))=f\eqref{GrindEQ__5_}\), so we evaluate the f(t) function at an input of 5: \[f(h(1))=f(5)=5^{2} 5=20\]
Try it Now
4. Using the functions from the example above, evaluate \(h(f(2))\).
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{1}\):
6
Given \(f(t)=t^{2} t\), evaluate \(f\eqref{GrindEQ__3_}\) and \(f(2)\).
\[f(3)=3^{2} 3\] \[f(2)=(2)^{2} (2)\]
We could simplify the results above if we wanted to \[f(3)=3^{2} 3=93=6\] \[f(2)=(2)^{2} (2)=4+2=6\]
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{1}\):
7
Using the function from the previous example, evaluate f(a).
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\]
The same idea can then be applied to expressions more complicated than a single letter.
Example \(\PageIndex{1}\):
8
Using the same f(t) function from above, evaluate \(f(x+2)\).
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)\]
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)\) Use the “FOIL” technique (first, outside, inside, last)
\(f(x+2)=x^{2} +2x+2x+4(x+2)\) distribute the negative sign \(f(x+2)=x^{2} +2x+2x+4x2\) combine like terms \[f(x+2)=x^{2} +3x+2\]
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}\]
Exercise \(\PageIndex{5}\)
Given \(g(x)=3x\sqrt{x}\), evaluate \(g(t2)\).
 Answer

Add answer text here and it will automatically be hidden if you have a "AutoNum" template active on the page.
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)=\frac{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)=\frac{1}{x} 2x\] We then use the expression \(\left(\frac{1}{x} 2x\right)\) as input for the function f. \[f(g(x))=f\left(\frac{1}{x} 2x\right)\]
We then evaluate the function f(x) using the formula for g(x) as the input.
Since \(f(x)=x^{2}\), \(f\left(\frac{1}{x} 2x\right)=\left(\frac{1}{x} 2x\right)^{2}\)
This gives us the formula for the composition: \(f(g(x))=\left(\frac{1}{x} 2x\right)^{2}\).
Likewise, to find g(f(x)), we evaluate the inside, writing out the formula for f(x) \[g(f(x))=g\left(x^{2} \right)\]
Now we evaluate the function g(x) using x \({}^{2}\) as the input. \[g(f(x))=\frac{1}{x^{2} } 2x^{2}\]
Exercise \(\PageIndex{1}\)
6. Let \(f(x)=x^{3} +3x\) and \(g(x)=\sqrt{x}\), find f(g(x)) and g(f(x)).
 Answer

Add answer text here and it will automatically be hidden if you have a "AutoNum" template active on the page.
Example \(\PageIndex{11}\)
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\left(60+2t+0.3t^{2} \right)=0.03\left(60+2t+0.3t^{2} \right)+\sqrt{60+2t+0.3t^{2} }\]
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\left(60+2(7)+0.3\eqref{GrindEQ__7_}^{2} \right)+\sqrt{60+2\eqref{GrindEQ__7_}+0.3\eqref{GrindEQ__7_}^{2} } \approx 12.079\)million dollars
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)=\frac{1}{x^{2} 1}\) and \(g(x)=\sqrt{x2}\). Find the domain of \(f\left(g(x)\right)\).
Since we want to avoid the square root of negative numbers, the domain of \(g(x)\) is the set of values where \(x2\ge 0\). The domain is \(x\ge 2\).
The composition is \(f\left(g(x)\right)=\frac{1}{\left(\sqrt{x2} \right)^{2} 1} =\frac{1}{(x2)1} =\frac{1}{x3}\).
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{\rm \; or\; }x>3\).
In interval notation, the domain is: \(\left[2,3\right)\cup \left(3,\infty \right)\).
Exercise \(\PageIndex{1}\)
7. Let \(f(x)=\frac{1}{x2}\) and \(g(x)=\frac{1}{x}\). Find the domain of \(f\left(g(x)\right)\).
 Answer

Add answer text here and it will automatically be hidden if you have a "AutoNum" template active on the page.
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{5x^{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 \(5x^{2}\) is the inside of the square root. We could then decompose the function as: \[h(x)=5x^{2}\] \[g(x)=3+\sqrt{x}\]
We can check our answer by recomposing the functions: \[g(h(x))=g\left(5x^{2} \right)=3+\sqrt{5x^{2} }\]
Note that this is not the only solution to the problem. Another nontrivial decomposition would be \(h(x)=x^{2}\) and \(g(x)=3+\sqrt{5x}\)
Important Topics of this Section
 Definition of Composition of Functions
 Compositions using:
 Words
 Tables
 Graphs
 Equations
 Domain of Compositions
 Decomposition of Functions
Try it Now Answers

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.)

\(f(g(1))=f\eqref{GrindEQ__3_}=3\) and \(g(f(3))=g\eqref{GrindEQ__3_}=2\)

\(g(f(2))=g\eqref{GrindEQ__5_}=3\)

\(h(f(2))=h\eqref{GrindEQ__6_}=20\) did you remember to insert your input values using parentheses?

\(g(t2)=3(t2)\sqrt{(t2)}\)

\(f(g(x))=f\left(\sqrt{x} \right)=\left(\sqrt{x} \right)^{3} +3\left(\sqrt{x} \right)\) \(g(f(x))=g\left(x^{3} +3x\right)=\sqrt{\left(x^{3} +3x\right)}\)

\(g(x)=\frac{1}{x}\) is undefined at x = 0.The composition, \(f\left(g(x)\right)=f\left(\frac{1}{x} \right)=\frac{1}{\frac{1}{x} 2} =\frac{1}{\frac{1}{x} \frac{2x}{x} } =\frac{1}{\frac{12x}{x} } =\frac{x}{12x}\) is undefined when \(12x=0\), when \(x=\frac{1}{2}\). Restricting these two values, the domain is \(\left(\infty ,0\right)\cup \left(0,\frac{1}{2} \right)\cup \left(\frac{1}{2} ,\infty \right)\).
Section 1.4 Exercises
Given each pair of functions, calculate \(f\left(g\left(0\right)\right)\) and \(g\left(f\left(0\right)\right)\). \[1. f\left(x\right)=4x+8, g\left(x\right)=7x^{2} 2. f\left(x\right)=5x+7, g\left(x\right)=42x^{2}\] \[3. f\left(x\right)=\sqrt{x+4} , g\left(x\right)=12x^{3} 4. f\left(x\right)=\frac{1}{x+2} , g\left(x\right)=4x+3\]
\(f(x)\) \({\it g}({\it x})\) \(f(x)\) \({\it g}({\it x})\)Use the table of values to evaluate each expression

\(f(g(8))\)

\(f\left(g\left(5\right)\right)\)

\(g(f(5))\)

\(g\left(f\left(3\right)\right)\)

\(f(f(4))\)

\(f\left(f\left(1\right)\right)\)

\(g(g(2))\)

\(g\left(g\left(6\right)\right)\)
Use the graphs to evaluate the expressions below.

\(f(g(3))\)

\(f\left(g\left(1\right)\right)\)

\(g(f(1))\)

\(g\left(f\left(0\right)\right)\)

\(f(f(5))\)

\(f\left(f\left(4\right)\right)\)

\(g(g(2))\)

\(g\left(g\left(0\right)\right)\)
For each pair of functions, find \(f\left(g\left(x\right)\right)\) and \(g\left(f\left(x\right)\right)\). Simplify your answers. \[21. f\left(x\right)=\frac{1}{x6} , g\left(x\right)=\frac{7}{x} +6\; 22. f\left(x\right)=\frac{1}{x4} , g\left(x\right)=\frac{2}{x} +4\] \[23. f\left(x\right)=x^{2} +1, g\left(x\right)=\sqrt{x+2} 24. f\left(x\right)=\sqrt{x} +2, g\left(x\right)=x^{2} +3\] \[25. f\left(x\right)=\leftx\right, g\left(x\right)=5x+1 26. f\left(x\right)=\sqrt[{3}]{x} , g\left(x\right)=\frac{x+1}{x^{3} }\]

If \(f\left(x\right)=\; x^{4} +6\), \(\; g(x)\; =\; x6\;\)and \(h(x)\; =\; \sqrt{x}\), find \(f(g(h(x)))\)

If \(f\left(x\right)=\; x^{2} +1\), \(g\left(x\right)=\frac{1}{x}\) and \(h\left(x\right)=\; x+3\) , find \(f(g(h(x)))\)

The function \(D(p)\) gives the number of items that will be demanded when the price is p. The production cost, \(C(x)\) is the cost of producing x items. To determine the cost of production when the price is $6, you would do which of the following:
a. Evaluate \(D(C(6))\) b. Evaluate \(C(D(6))\)
c. Solve \(D(C(x))\; =\; 6\) d. Solve \(C(D(p))\; =\; 6\)

The function \(A(d)\) gives the pain level on a scale of 010 experienced by a patient with d milligrams of a pain reduction drug in their system. The milligrams of drug in the patient’s system after t minutes is modeled by \(m(t)\). To determine when the patient will be at a pain level of 4, you would need to:
a. Evaluate \(A\left(m\left(4\right)\right)\) b. Evaluate \(m\left(A\left(4\right)\right)\)
c. Solve \(A\left(m\left(t\right)\right)\; =\; 4\) d. Solve \(m\left(A\left(d\right)\right)\; =\; 4\)

The radius r, in inches, of a spherical balloon is related to the volume, V, by \(r(V)=\sqrt[{3}]{\frac{3V}{4\pi } }\). Air is pumped into the balloon, so the volume after t seconds is given by \(V\left(t\right)=10+20t\).

Find the composite function \(r\left(V\left(t\right)\right)\)

Find the radius after 20 seconds


The number of bacteria in a refrigerated food product is given by \(N\left(T\right)=23T^{2} 56T+\; 1\;\), \(3<T<33\), where T is the temperature of the food. When the food is removed from the refrigerator, the temperature is given by \(T(t)=5t+1.5\), where t is the time in hours.

Find the composite function \(N\left(T\left(t\right)\right)\)

Find the bacteria count after 4 hours

Given \(p\left(x\right)=\frac{1}{\sqrt{x} }\) and \(m\left(x\right)=\; x^{2} 4\), find the domain of \(m(p(x))\;\).
34. Given \(p\left(x\right)=\frac{1}{\sqrt{x} }\) and \(m\left(x\right)=\; 9x^{2}\), find the domain of \(m(p(x))\;\).
35. Given \(f\left(x\right)=\frac{1}{x+3}\) and \(g\left(x\right)=\frac{2}{x1}\), find the domain of \(f\left(g\left(x\right)\right)\).
36. Given \(f\left(x\right)=\frac{x}{x+1}\) and \(g\left(x\right)=\frac{4}{x}\), find the domain of \(f\left(g\left(x\right)\right)\).
37. Given \(f\left(x\right)=\sqrt{x2}\) and \(g\left(x\right)=\frac{2}{x^{2} 3}\), find the domain of \(g\left(f\left(x\right)\right)\).
38. Given \(f\left(x\right)=\sqrt{4x}\) and \(g\left(x\right)=\frac{1}{x^{2} 2}\), find the domain of \(g\left(f\left(x\right)\right)\).
Find functions \(f(x)\) and \(g(x)\) so the given function can be expressed as \(h\left(x\right)=f\left(g\left(x\right)\right)\). \[39. h\left(x\right)=\left(x+2\right)^{2} 40. h\left(x\right)=\left(x5\right)^{3}\] \[41. h\left(x\right)=\frac{3}{x5} 42. h\left(x\right)=\frac{4}{\left(x+2\right)^{2} }\] \[43. h\left(x\right)=3+\sqrt{x2} 44. h\left(x\right)=4+\sqrt[{3}]{x}\] 45. Let \(f(x)\) be a linear function, with form \(f\left(x\right)=ax+b\) for constants a and b. [UW]


Show that \(f\left(f\left(x\right)\right)\) is a linear function

Find a function \(g(x)\) such that \(g\left(g\left(x\right)\right)=6x8\)

46. Let \(f\left(x\right)=\frac{1}{2} x+3\) [UW]

Sketch the graphs of \(f\left(x\right),\; f\left(f\left(x\right)\right),\; f\left(f\left(f\left(x\right)\right)\right)\) on the interval \(\mathrm{}\)2 \(\mathrm{\le}\) x \(\mathrm{\le}\) 10.

Your graphs should all intersect at the point (6, 6). The value x = 6 is called a fixed point of the function f(x)since \(f\eqref{GrindEQ__6_}=6\); that is, 6 is fixed  it doesn’t move when f is applied to it. Give an explanation for why 6 is a fixed point for any function \(f(f(f(...f(x)...)))\).

Linear functions (with the exception of \(f(x)=x\)) can have at most one fixed point. Quadratic functions can have at most two. Find the fixed points of the function \(g\left(x\right)=x^{2} 2\).

Give a quadratic function whose fixed points are x = \(\mathrm{}\)2 and x = 3.
47. A car leaves Seattle heading east. The speed of the car in mph after m minutes is given by the function \(C\left(m\right)=\frac{70m^{2} }{10+m^{2} }\). [UW]

Find a function \(m=f(s)\) that converts seconds s into minutes m. Write out the formula for the new function \(C(f(s))\); what does this function calculate?

Find a function \(m=g(h\)) that converts hours h into minutes m. Write out the formula for the new function \(C(g(h))\); what does this function calculate?

Find a function \(z=v(s)\) that converts mph s into ft/sec z. Write out the formula for the new function \(v(C(m)\); what does this function calculate?
\[93\]