### Composition of Functions

#### Definition

Given two functions $f(x)$ and $g(x)$, a composed function $gf$ is the function defined by $gf(x) = g\bigl(f(x)\bigr)$

A composed function is defined from two (or more) other functions, by using the output of one function as the input of another, starting with the inside function and working out. An alternative notation for $gf$ is $g \circ f$.

Function composition can be applied to more than two functions. For example, $fgh(x) = f\bigl(g\bigl(h(x)\bigr)\bigr)$.

Note: In general $gf(x)$ is not equal to $fg(x)$.

When defining a composed function, it is important to ensure you define both its domain and range.

#### Worked Examples

###### Example 1

Let $f$ and $g$ be the functions given by $f(x)=x^2$ and $g(x)=x+3$.

a) Compute $fg(x)$. b) Compute $gf(x)$.

###### Solution

a) Write down $g(x)$ first:

$g(x)=x+3$

Then apply $f$ to the whole of $g(x)$.

\begin{align} fg(x)&=f(x+3)\\ &=(x+3)^2 \end{align}

b) Write down $f(x)$ first:

$f(x)=x^2$

Then apply $g$ to the whole of $f(x)$.

\begin{align} gf(x)&=g(x^2)\\ &=x^2+3 \end{align}

###### Example 2

Let $f$ and $g$ be functions given by $f(x)=e^{4x}$ and $g(x)=\sqrt{x}+\dfrac{1}{x}$.

a) Compute $fg(x)$.

b) Compute $gf(x)$.

###### Solution

a) Write down $g(x)$ first:

$g(x)=\sqrt{x} + \dfrac{1}{x}$

Then apply $f$ to the whole of $g(x)$.

\begin{align} fg(x)&=f\left(\sqrt{x} + \dfrac{1}{x}\right)\\ &=e^{ 4\left({ \sqrt{x} + \frac{1}{x} }\right) } \end{align}

b) Write down $f(x)$ first:

$f(x)=e^{4x}$

Then apply $g$ to the whole of $f(x)$.

\begin{align} gf(x)&=g(e^{4x})\\ &=\sqrt{ e^{4x} } + \frac{1}{ e^{4x} } \end{align}

#### More Support

You can get one-to-one support from Maths-Aid.