Is function composition associative?

2 Answers
Jul 24, 2015

Yes

Explanation:

Given composable functions ff, gg and hh

(f@(g@h))(x)(f(gh))(x)

= f((g@h)(x)) = f(g(h(x))) = (f@g)(h(x))=f((gh)(x))=f(g(h(x)))=(fg)(h(x))

= ((f@g)@h)(x)=((fg)h)(x)

So f@(g@h) = (f@g)@hf(gh)=(fg)h

It is, if the following works:

(f@(g@h))(x) = ((f@g)@h)(x)(f(gh))(x)=((fg)h)(x)

That is, if:

f(x) = "something"f(x)=something
g(h(x)) = (g@h)(x) = "something else"g(h(x))=(gh)(x)=something else
f(g(x)) = (f@g)(x) = "something else again"f(g(x))=(fg)(x)=something else again
h(x) = "something else yet again"h(x)=something else yet again

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

f(x) = 2xf(x)=2x
g(x) = x^2g(x)=x2
h(x) = x^3h(x)=x3

Thus:

g(h(x)) = g(x^3) = (x^3)^2 = x^6g(h(x))=g(x3)=(x3)2=x6

f(g(x)) = g(x^2) = 2(x^2) = 2x^2f(g(x))=g(x2)=2(x2)=2x2

Then:

(f@(g@h))(x) = f(x^6) = 2(x^6) = color(blue)(2x^6)(f(gh))(x)=f(x6)=2(x6)=2x6

((f@g)@h)(x) = f(g(x^3)) = f((x^3)^2) = f(x^6) = color(blue)(2x^6)((fg)h)(x)=f(g(x3))=f((x3)2)=f(x6)=2x6

Therefore they are associative.