When the output set of one function feeds the input set of another, the two can be chained.
Definition. Let f:A→B and g:B→C. The composition of f and g, written g∘f (read "g of f"), is the function g∘f:A→C given by
(g∘f)(x)=g(f(x)),∀x∈A
Read it right to left: f acts first, then g acts on the result. The middle set B must match — f's outputs must be legal inputs for g.
Worked chain on finite sets. Let f:{2,3,4,5}→{3,4,5,9} with f(2)=3, f(3)=4, f(4)=f(5)=5, and g:{3,4,5,9}→{7,11,15} with g(3)=g(4)=7, g(5)=g(9)=11. Then
(g∘f)(2)=g(3)=7,(g∘f)(3)=g(4)=7,(g∘f)(4)=g(5)=11,(g∘f)(5)=g(5)=11
Order matters: g∘f=f∘g in general
For f(x)=cosx and g(x)=3x2 on R:
(g∘f)(x)=g(cosx)=3cos2x,(f∘g)(x)=f(3x2)=cos(3x2)
At x=0: (g∘f)(0)=3cos20=3 while (f∘g)(0)=cos0=1. One disagreement is enough: g∘f=f∘g. Composition is not commutative — but it isassociative: h∘(g∘f)=(h∘g)∘f whenever the chains make sense, because both sides send x to h(g(f(x))).
How composition interacts with one-one and onto
Two facts that exams (especially JEE) probe:
Fact 1. If g∘f is one-one, then f must be one-one (a collision in f would survive into g∘f) — but g need not be.
Fact 2. If g∘f is onto, then g must be onto (everything in C is reached through g) — but f need not be.
And in the convenient direction: the composite of two one-one functions is one-one; the composite of two onto functions is onto; hence the composite of two bijections is a bijection.
Invertible Functions
Undoing a function
Definition. A function f:X→Y is invertible if there exists a function g:Y→X such that
g∘f=IXandf∘g=IY
where IX and IY are the identity functions. The function g is called the inverse of f, written f−1.
Both equations matter: g must undo f from the left and from the right.
The central theorem
Theorem.f is invertible if and only iff is one-one and onto (bijective).
Why: if f has an inverse, then f cannot collide (the inverse could not decide where to send the shared image) and cannot miss any y (the inverse must send every y somewhere that maps back to it). Conversely a bijection pairs X and Y perfectly, and "follow the pairing backwards" defines the inverse.
This theorem is a labour-saving device: to prove invertibility you may simply prove one-one and onto — no formula for f−1 required. When the formula is required, use the template below.
Computing an inverse (the template)
Step 1 — set y=f(x) and solve for x in terms of y.
Step 2 — the solution defines g(y); state its domain (the co-domain of f).
Step 3 — verify both compositions: g(f(x))=x and f(g(y))=y.
Worked inverse.f:N→Y, f(x)=4x+3, where Y={y∈N:y=4x+3 for some x∈N}.
Step 1:y=4x+3⇒x=4y−3.
Step 2: define g:Y→N by g(y)=4y−3 (a natural number by the definition of Y).
Step 3:g(f(x))=4(4x+3)−3=x and f(g(y))=4⋅4y−3+3=y. Both identities hold, so f is invertible with f−1(y)=4y−3. ■
Note how the co-domain was chosen to be exactly the range — that choice is what made f onto and hence invertible.
Properties worth memorising
(f−1)−1=f,(g∘f)−1=f−1∘g−1(socks-shoes rule: undo in reverse order)
A function can even be its own inverse (a self-inverse function): f(x)=6x−44x+3, x=32, satisfies (f∘f)(x)=x, so f−1=f. Other self-inverse examples: f(x)=−x, f(x)=x1, f(x)=a−x.
Common mistakes to avoid
Mistake 1 — f−1(x) vs f(x)1. The inverse function is not the reciprocal. f(x)=2x has f−1(x)=2x, not 2x1.
Mistake 2 — inverting a non-bijection.f(x)=x2 on R has no inverse; only after restricting to [0,∞) (making it bijective onto [0,∞)) does x become its inverse.
Mistake 3 — checking only one composition.g∘f=IX alone does not prove invertibility in general; the definition demands both g∘f=IX and f∘g=IY.
Mistake 4 — wrong order in (g∘f)−1. It is f−1∘g−1, not g−1∘f−1 — you take off shoes before socks.
Solved Examples
Example 1 — Composing along finite tables
Let f:{2,3,4,5}→{3,4,5,9} and g:{3,4,5,9}→{7,11,15} be defined by f(2)=3, f(3)=4, f(4)=f(5)=5, and g(3)=g(4)=7, g(5)=g(9)=11. Find g∘f.
Step 1 — push each element through both tables:(g∘f)(2)=g(f(2))=g(3)=7(g∘f)(3)=g(f(3))=g(4)=7(g∘f)(4)=g(f(4))=g(5)=11(g∘f)(5)=g(f(5))=g(5)=11
Answer:g∘f sends 2↦7, 3↦7, 4↦11, 5↦11. (Note 15 in the final co-domain is never reached — composition can lose surjectivity.)
Example 2 — Order matters
Find g∘f and f∘g for f(x)=cosx and g(x)=3x2 on R, and show g∘f=f∘g.
Step 1 — compose both ways:(g∘f)(x)=g(cosx)=3cos2x,(f∘g)(x)=f(3x2)=cos(3x2)
Step 2 — find one point of disagreement: at x=0, 3cos20=3 but cos0=1.
Answer:g∘f=f∘g — composition is not commutative, and a single differing value proves it.
Example 3 — A composition that simplifies
If f:R→R is f(x)=8x3 and g:R→R is g(x)=x1/3, find g∘f and f∘g.
Step 1 — g∘f:(g∘f)(x)=g(8x3)=(8x3)1/3=2x
Step 2 — f∘g:(f∘g)(x)=f(x1/3)=8(x1/3)3=8x
Answer:(g∘f)(x)=2x and (f∘g)(x)=8x — both linear, but different: yet another reminder that the order of composition matters.
Example 4 — Proving invertibility and finding the inverse
Let f:N→Y, f(x)=4x+3, where Y={y∈N:y=4x+3 for some x∈N}. Show that f is invertible and find its inverse.
Step 1 — solve y=f(x) for x:y=4x+3 gives x=4y−3, a natural number for every y∈Y by the very definition of Y.
Step 2 — define the candidate inverse:g:Y→N, g(y)=4y−3.
Step 3 — verify both compositions:g(f(x))=4(4x+3)−3=x,f(g(y))=4(4y−3)+3=y
Answer:g∘f=IN and f∘g=IY, so f is invertible with f−1(y)=4y−3.
Example 5 — Another linear inverse
Let f:R→R be f(x)=10x+7. Find the function g:R→R such that g∘f=f∘g=IR.
Step 1 — solve:y=10x+7⇒x=10y−7, so define g(y)=10y−7.