# Composite functions

Given $$f(x) = 3x + 2$$, we are often asked to find $$f(2)$$ or $$f( - 3)$$. To do this we substitute $$2$$ or $$- 3$$ for $$x$$. So, $$f(2) = 3(2) + 2 = 8$$ and $$f( - 3) = 3( - 3) + 2 = - 7$$.

Sometimes, however, we are asked to find the result of a function of a function. That is, replacing $$x$$ in the example above with another function.

Follow this worked example:

$f(x) = 10x + 7$

$g(x) = 3x$

Find $$f(g(x))$$

Replace $$x$$ with the function

$f(g(x)) = 10(g(x)) + 7$

$f(3x) = 10(3x) + 7$

$f(g(x)) = 30x + 7$

Question

$f(x)=x+1$

$g(x) = 4{x^2} + 8x - 7$

Find $$g(f(x))$$

$g(f(x)) = 4{(f(x))^2} + 8(f(x)) - 7$

Simplify:

$g(x + 1) = 4{(x + 1)^2} + 8(x + 1) - 7$

$g(x + 1) = 4({x^2} + 2x + 1) + 8x + 8 - 7$

$g(f(x)) = 4{x^2} + 8x + 4 + 8x + 1$

$g(f(x)) = 4{x^2} + 16x + 5$

When you're asked to find $$f(g(x))$$ and $$g(f(x))$$, the order is important. Apart from a few special cases, $$f(g(x))$$ does not equal $$g(f(x))$$.