# Is function composition associative?

Jul 24, 2015

Yes

#### Explanation:

Given composable functions $f$, $g$ and $h$

$\left(f \circ \left(g \circ h\right)\right) \left(x\right)$

$= f \left(\left(g \circ h\right) \left(x\right)\right) = f \left(g \left(h \left(x\right)\right)\right) = \left(f \circ g\right) \left(h \left(x\right)\right)$

$= \left(\left(f \circ g\right) \circ h\right) \left(x\right)$

So $f \circ \left(g \circ h\right) = \left(f \circ g\right) \circ h$

Jul 28, 2015

It is, if the following works:

$\left(f \circ \left(g \circ h\right)\right) \left(x\right) = \left(\left(f \circ g\right) \circ h\right) \left(x\right)$

That is, if:

$f \left(x\right) = \text{something}$
$g \left(h \left(x\right)\right) = \left(g \circ h\right) \left(x\right) = \text{something else}$
$f \left(g \left(x\right)\right) = \left(f \circ g\right) \left(x\right) = \text{something else again}$
$h \left(x\right) = \text{something else yet again}$

...and you can use these together to satisfy the first expression, then they are associative. Let:

$f \left(x\right) = 2 x$
$g \left(x\right) = {x}^{2}$
$h \left(x\right) = {x}^{3}$

Thus:

$g \left(h \left(x\right)\right) = g \left({x}^{3}\right) = {\left({x}^{3}\right)}^{2} = {x}^{6}$

$f \left(g \left(x\right)\right) = g \left({x}^{2}\right) = 2 \left({x}^{2}\right) = 2 {x}^{2}$

Then:

$\left(f \circ \left(g \circ h\right)\right) \left(x\right) = f \left({x}^{6}\right) = 2 \left({x}^{6}\right) = \textcolor{b l u e}{2 {x}^{6}}$

$\left(\left(f \circ g\right) \circ h\right) \left(x\right) = f \left(g \left({x}^{3}\right)\right) = f \left({\left({x}^{3}\right)}^{2}\right) = f \left({x}^{6}\right) = \textcolor{b l u e}{2 {x}^{6}}$

Therefore they are associative.