Is composition associative?

1.5k Views Asked by At

is composition associative?

How do we define this?

I thought I could counter example this with integers and mappings

$f_1(x)=1$, and $f_2(x) = f_3(x)=2x.$

But I couldn't get it work on paper only in my head which means I am probably wrong thx

2

There are 2 best solutions below

0
On

Composition is associative : Let $f, g, h$: $$\forall x \in D_{f, g, h}, ((f \circ g) \circ h)(x) = f(g(h(x))) = (f \circ (g \circ h))(x)$$

Hence $(f \circ g) \circ h = f \circ (g \circ h)$.

With two of the example you given, you can prove however that it is not commutative.

2
On

Using your example, we test for associativity by comparing

$$f_1\circ (f_2\circ f_3)(x) \,\text{ and }\,(f_1\circ f_2)\circ f_3(x)$$

If we can establish equality, we will have shown that, yes, composition is associative.

So we test $$f_1\circ (f_2\circ f_3)(x) = f_1(f_2(f_3(x))) = (f_1\circ f_2)( f_3(x)) = (f_1\circ f_2)\circ f_3(x)$$

Hence, composition is associative.


Challenge: can you answer whether composition is commutative? That is, is it true that for all functions $f, g$, $$\;(f\circ g)(x) = (g\circ f)(x)\iff f(g(x)) = g(f(x))\;\;?$$

Hint: Try to find a counterexample to prove commutativity fails.