Function Composition
If f: A โ B and g: B โ C, the composition g โ f is a function from A to C defined by (g โ f)(x) = g(f(x)).
g โ f means: first apply f, then apply g
Example: f(x) = 2x, g(x) = x + 3
(g โ f)(x) = g(f(x)) = g(2x) = 2x + 3
(f โ g)(x) = f(g(x)) = f(x + 3) = 2(x + 3) = 2x + 6
Composition Is Not Commutative
In general, g โ f โ f โ g. The order matters!
Example:
f(x) = xยฒ, g(x) = x + 1
(g โ f)(x) = xยฒ + 1
(f โ g)(x) = (x + 1)ยฒ = xยฒ + 2x + 1
g โ f โ f โ g
Composition Is Associative
(h โ g) โ f = h โ (g โ f)
This is always true. You can compose in any grouping:
h(g(f(x))) = (h โ g โ f)(x)
Properties Preserved by Composition
If f and g are both injective, then g โ f is injective.
If f and g are both surjective, then g โ f is surjective.
If f and g are both bijective, then g โ f is bijective.