Suppose you have two functions and :
Then you can make a new function whose rule is “do , then do ”.
Let and . The composition of and , written or , is the function with rule .
This makes sense because is an element of and has domain so we can use any element of as an input to .
It’s important to remember that is the function whose rule is “do , then do ”.
If then .
For any we have and . ∎
Functions and such that the codomain of equals the domain of , in other words, functions such that makes sense, are called composable. Suppose that and are composable and and are also composable, so that we can draw a diagram
It seems there are two different ways to compose these three functions: you could first compose and , then compose the result with , or you could compose with and then compose the result with . But they both give the same result, because function composition is associative.
Let . Then .
Both and have the same domain , same codomain , and same rule that sends to . ∎
The associativity property says that a composition like doesn’t need any brackets to make it unambiguous: however you bracket it, the result is the same. In fact we can omit brackets from a composition of any length without ambiguity.