If you can map A to B and then B to C, you can map A to C by performing the two steps in sequence. That sequence is called the composition of the two functions, written g∘f. Composition behaves like multiplication: it is associative, it has an identity, and on the set of bijections of any set A to itself it even has inverses, producing what algebraists call the symmetric group SA. For our purposes the immediate payoff is that composition is how we will define and verify inverse functions in the next subtopic.
Definition
Let f:A→B and g:B→C be functions. The compositiong∘f:A→C is defined by
(g∘f)(x)=g(f(x))for all x∈A.
Read g∘f as "g after f". Caution: g∘f requires the codomain of f to be contained in the domain of g.
Three immediate properties
Associativity. If f:A→B, g:B→C, h:C→D, then
h∘(g∘f)=(h∘g)∘f.Proof. Both sides take x to h(g(f(x))).
Identity. Let IA:A→A, IA(x)=x. Then for any f:A→B,
f∘IA=fandIB∘f=f.
Non-commutativity. In general f∘g=g∘f, even when both make sense. For f(x)=x+1 and g(x)=2x, f(g(x))=2x+1 but g(f(x))=2x+2.
Preservation theorems
Theorem. Let f:A→B and g:B→C.
If f and g are both one-one, then g∘f is one-one.
If f and g are both onto, then g∘f is onto.
If f and g are both bijective, then g∘f is bijective.
Proof of (1). Suppose (g∘f)(x1)=(g∘f)(x2). Then g(f(x1))=g(f(x2)). Since g is one-one, f(x1)=f(x2). Since f is one-one, x1=x2.
Proof of (2). Let z∈C. Since g is onto, there is y∈B with g(y)=z. Since f is onto, there is x∈A with f(x)=y. Then (g∘f)(x)=z. ■
A subtler theorem
Theorem. Let f:A→B and g:B→C.
If g∘f is one-one, then f is one-one.
If g∘f is onto, then g is onto.
Proof of (1). Suppose f(x1)=f(x2). Apply g: g(f(x1))=g(f(x2)), i.e., (g∘f)(x1)=(g∘f)(x2). Since g∘f is one-one, x1=x2.
Proof of (2). Let z∈C. Since g∘f is onto, there is x with g(f(x))=z. Setting y=f(x)∈B, g(y)=z. ■
Note the asymmetry: the hypothesis tells us about the outer map in one case and the inner in the other.
A common JEE trap
The converse of the above is false. g∘f being one-one does not force g to be one-one , only f. Symmetrically, g∘f onto does not force f onto. The standard counter-example uses A={1}, B={a,b}, C={x} with f(1)=a and g(a)=g(b)=x.