If f(x) = x + 2, and g(x) = 2x + 4, what is f(g(x)) ?
A function can be conceptualized as a 'black box'. The input, or x value is placed into the box, and the box performs a specific set of operations on it. Once the operations are complete, the output (the " f(x) " or " y " value) is retrieved. Once the output is retrieved, the box is ready to work on the next input.
Using this idea, function composition can be seen as a box inside of a box. The input x value goes into the inner box, and then the output of the inner box is used as the input of the outer box.
This lesson is all about boxes inside of boxes. See if you can use what you learn to answer the question above before the review at the end.
Watch This
James Sousa  Composite Functions
Guidance
Composition of Functions
Functions are often described in terms of “input” and “output.” For example, consider the function f ( x ) = 2 x + 3. When we input an x value, we output a y value, or a function value. We find the output by taking the input x , multiplying by 2, and adding 3. We can do this for any value of x . Now consider a second function g ( x ) = 5 x . For this function too, we can take an x value, input the x into g ( x ), and obtain an output. What happens if we take the output of g and use it as the input of f ?
Example A
Given the function definition above, g ( x ) = 5 x . Therefore if x = 4, then we have g (4) = 5(4) = 20. What happens if we then take the output of 20 and use it as the input of f ?
Solution:
Substituting 20 in for x in f ( x ) = 2 x + 3 gives: f (20) = 2(20) + 3 = 43.
The table below shows several examples of this same process:
x  Output from g  Output from f 

2  10  23 
3  15  33 
4  20  43 
5  25  53 
Examining the values in the table, we can see a pattern: all of the final output values from f are 3 more than 10 times the initial input. We have created a new function called h ( x ) out of f ( x ) = 2 x + 3 in which g ( x ) = 5 x is the input:
h ( x ) = f (5 x ) = 2(5 x ) + 3 = 10 x + 3
When we input one function into another, we call this the composition of the two functions. Formally, we write the composed function as f ( g ( x )) = 10 x + 3 or write it as ( f o g ) x = 10 x + 3
Example B
Find f ( g ( x )) and g ( f ( x )):
a. f ( x ) = 3 x + 1 and g ( x ) = x ^{ 2 }  b. f ( x ) = 2 x + 4 and g ( x ) = (1/2) x  2 

Solution:
a. f ( x ) = 3 x + 1 and g ( x ) = x ^{ 2 }
 f ( g ( x )) = f ( x ^{ 2 } ) = 3( x ^{ 2 } ) + 1 = 3 x ^{ 2 } + 1
 g ( f ( x )) = g (3 x + 1) = (3 x + 1) ^{ 2 } = 9 x ^{ 2 } + 6 x + 1
 In both cases, the resulting function is quadratic.
b. f ( x ) = 2 x + 4 and g ( x ) = (1/2) x  2
 f ( g ( x )) = 2((1/2) x  2) + 4 = (2/2) x  4 + 4 = (2/2) x = x
 g ( f ( x )) = g (2 x + 4) = (1/2)(2 x + 4)  2 = x + 2  2 = x .
 In this case, the composites were equal to each other, and they both equal x , the original input into the function. This means that there is a special relationship between these two functions. We will examine this relationship in Chapter 3. It is important to note, however, that f ( g ( x ) is not necessarily equal to g ( f ( x )).
Example C
Decompose the function f ( x ) = (3 x  1) ^{ 2 }  5 into a quadratic function g ( x ) and a linear function h ( x ).
Solution:
When we compose functions, we are combining two (or more) functions by inputting the output of one function into another. We can also decompose a function. Consider the function f ( x ) = (2 x + 1) ^{ 2 } . We can decompose this function into an “inside” and an “outside” function. For example, we can construct f ( x ) = (2 x + 1) ^{ 2 } with a linear function and a quadratic function. If g ( x ) = x ^{ 2 } and h ( x ) = (2 x + 1), then f ( x ) = g ( h ( x )). The linear function h ( x ) = (2 x + 1) is the inside function, and the quadratic function g ( x ) = x ^{ 2 } is the outside function.
Let h ( x ) = 3 x  1 and g ( x ) = x ^{ 2 }  5. Then f ( x ) = g ( h ( x )) because g ( h ( x )) = g (3 x  1) = (3 x  1) ^{ 2 }  5.
The decomposition of a function is not necessarily unique. For example, there are many ways that we could express a linear function as the composition of other linear functions.
Can you answer the question at the beginning of the lesson now? If f(x) = x + 2, and g(x) = 2x + 4, what is f(g(x)) ? f(g(x)) = f(2x + 4) = (2x + 4) + 2 = 2x + 6 Once you get the idea, composite functions aren't as difficult as they look! 

Vocabulary
A composite function is a function formed by using the output of one function as the input of another.
The input of a function is the value on which the function is performed (commonly the x value).
The output of a function is the result of the operations performed on x (commonly y or f(x) ).
Guided Practice
Questions

1) Given:
 Find:

2) Given:
 Find:

3) Given:

 Find
Solutions
1) To find f ( g (4)), we need to know what is, so we know what to substitute into :
 Substitute 4 for x for the function g ( x ), giving:

Simplify:
 Substitute 48 for the x in the function giving:

Simplify:
2) First, let's solve for the value of the inner function, . Then we'll know what to plug into the outer function.
 To solve for the value of h , we need to solve
 Now we have:
 Simplify to get:
 Now we know that . That tells us that is
 Find
 So to solve for the value of , we need to solve for the value of

 Now we can finish up!
3) First, solve for the value of the inner function to find what to plug into the outer function
 Next, solve for which we now know is:
 To solve for the value of h , we need to solve for the value of g (5).

 Finally:
Practice
For problems 13:
 Find:
 Find:
 Find:
 Find:
Evaluate each composition below:
 Given: and Find
 Given: and Find
 Given: and Find
 Given and Find
 Given and Find
 Given and given and given Find
 Given and given and given Find
 Are compositions commutative? In other words, does ?
 Given: and Find
 Two functions are inverses of each other if and If , find its inverse:
 A toy manufacturer has a new product to sell. The number of units to be sold, n , is a function of the price p such that: The revenue r earned from the sales is a function of the number of units sold n such that: Find the function for revenue in terms of price, p .