Math Lab
Home/Class XII/Ch 1/Composition of functions

Composition of functions

If you can map AA to BB and then BB to CC, you can map AA to CC by performing the two steps in sequence. That sequence is called the composition of the two functions, written gfg \circ f. Composition behaves like multiplication: it is associative, it has an identity, and on the set of bijections of any set AA to itself it even has inverses, producing what algebraists call the symmetric group SAS_A. 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:ABf : A \to B and g:BCg : B \to C be functions. The composition gf:ACg \circ f : A \to C is defined by

(gf)(x)=g(f(x))for all xA.(g \circ f)(x) = g(f(x)) \quad \text{for all } x \in A.

Read gfg \circ f as "gg after ff". Caution: gfg \circ f requires the codomain of ff to be contained in the domain of gg.

Three immediate properties

Associativity. If f:ABf : A \to B, g:BCg : B \to C, h:CDh : C \to D, then h(gf)=(hg)f.h \circ (g \circ f) = (h \circ g) \circ f. Proof. Both sides take xx to h(g(f(x)))h(g(f(x))).

Identity. Let IA:AAI_A : A \to A, IA(x)=xI_A(x) = x. Then for any f:ABf : A \to B, fIA=fandIBf=f.f \circ I_A = f \quad \text{and} \quad I_B \circ f = f.

Non-commutativity. In general fggff \circ g \neq g \circ f, even when both make sense. For f(x)=x+1f(x) = x + 1 and g(x)=2xg(x) = 2x, f(g(x))=2x+1f(g(x)) = 2x + 1 but g(f(x))=2x+2g(f(x)) = 2x + 2.

Preservation theorems

Theorem. Let f:ABf : A \to B and g:BCg : B \to C.

  1. If ff and gg are both one-one, then gfg \circ f is one-one.
  2. If ff and gg are both onto, then gfg \circ f is onto.
  3. If ff and gg are both bijective, then gfg \circ f is bijective.

Proof of (1). Suppose (gf)(x1)=(gf)(x2)(g \circ f)(x_1) = (g \circ f)(x_2). Then g(f(x1))=g(f(x2))g(f(x_1)) = g(f(x_2)). Since gg is one-one, f(x1)=f(x2)f(x_1) = f(x_2). Since ff is one-one, x1=x2x_1 = x_2.

Proof of (2). Let zCz \in C. Since gg is onto, there is yBy \in B with g(y)=zg(y) = z. Since ff is onto, there is xAx \in A with f(x)=yf(x) = y. Then (gf)(x)=z(g \circ f)(x) = z. \blacksquare

A subtler theorem

Theorem. Let f:ABf : A \to B and g:BCg : B \to C.

  1. If gfg \circ f is one-one, then ff is one-one.
  2. If gfg \circ f is onto, then gg is onto.

Proof of (1). Suppose f(x1)=f(x2)f(x_1) = f(x_2). Apply gg: g(f(x1))=g(f(x2))g(f(x_1)) = g(f(x_2)), i.e., (gf)(x1)=(gf)(x2)(g \circ f)(x_1) = (g \circ f)(x_2). Since gfg \circ f is one-one, x1=x2x_1 = x_2.

Proof of (2). Let zCz \in C. Since gfg \circ f is onto, there is xx with g(f(x))=zg(f(x)) = z. Setting y=f(x)By = f(x) \in B, g(y)=zg(y) = z. \blacksquare

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. gfg \circ f being one-one does not force gg to be one-one , only ff. Symmetrically, gfg \circ f onto does not force ff onto. The standard counter-example uses A={1}A = \{1\}, B={a,b}B = \{a, b\}, C={x}C = \{x\} with f(1)=af(1) = a and g(a)=g(b)=xg(a) = g(b) = x.

Worked examples

Example 1. f(x)=3x+1f(x) = 3x + 1, g(x)=x2g(x) = x^2. Find fgf \circ g and gfg \circ f.

(fg)(x)=f(x2)=3x2+1(f \circ g)(x) = f(x^2) = 3x^2 + 1. (gf)(x)=g(3x+1)=(3x+1)2=9x2+6x+1(g \circ f)(x) = g(3x + 1) = (3x + 1)^2 = 9x^2 + 6x + 1.

Example 2. f:RRf : \mathbb{R} \to \mathbb{R}, f(x)=xf(x) = |x| and g(x)=5x2g(x) = 5x - 2. Compute (fg)(3)(f \circ g)(3) and (gf)(3)(g \circ f)(-3).

(fg)(3)=f(13)=13(f \circ g)(3) = f(13) = 13. (gf)(3)=g(3)=13(g \circ f)(-3) = g(3) = 13. (Equal here by coincidence.)

Example 3. Let f(x)=11xf(x) = \tfrac{1}{1 - x} for x1x \neq 1. Compute fff \circ f and ffff \circ f \circ f.

(ff)(x)=f(11x)=1111x=1x(1x)1=1xx=x1x(f \circ f)(x) = f(\tfrac{1}{1 - x}) = \tfrac{1}{1 - \tfrac{1}{1 - x}} = \tfrac{1 - x}{(1 - x) - 1} = \tfrac{1 - x}{-x} = \tfrac{x - 1}{x}.

(fff)(x)=f(x1x)=11x1x=xx(x1)=x(f \circ f \circ f)(x) = f(\tfrac{x - 1}{x}) = \tfrac{1}{1 - \tfrac{x - 1}{x}} = \tfrac{x}{x - (x - 1)} = x.

So f3=If^3 = I on its domain. A function of period 33 under composition.

Example 4. f:RRf : \mathbb{R} \to \mathbb{R}, f(x)=x+7f(x) = x + 7. g:RRg : \mathbb{R} \to \mathbb{R}, g(x)=x7g(x) = x - 7. Compute fgf \circ g and gfg \circ f.

Both equal xx, i.e., the identity. This is the prototype of an inverse pair.

Example 5. Show (gf)1=f1g1(g \circ f)^{-1} = f^{-1} \circ g^{-1} for bijections ff and gg.

If ff and gg are bijections, so is gfg \circ f, by the preservation theorem. Compute:

(f1g1)(gf)=f1(g1g)f=f1If=f1f=I.(f^{-1} \circ g^{-1}) \circ (g \circ f) = f^{-1} \circ (g^{-1} \circ g) \circ f = f^{-1} \circ I \circ f = f^{-1} \circ f = I.

Similarly on the other side. So f1g1f^{-1} \circ g^{-1} is the inverse of gfg \circ f.

The reversal of order is the most-tested formula in this chapter.

Example 6. Let f,g:RRf, g : \mathbb{R} \to \mathbb{R} with f(x)=sinxf(x) = \sin x and g(x)=x2g(x) = x^2. Compute the four possible compositions.

(fg)(x)=sin(x2)(f \circ g)(x) = \sin(x^2), (gf)(x)=(sinx)2=sin2x(g \circ f)(x) = (\sin x)^2 = \sin^2 x, (ff)(x)=sin(sinx)(f \circ f)(x) = \sin(\sin x), (gg)(x)=x4(g \circ g)(x) = x^4.

Try it yourself

  1. f(x)=2x3,g(x)=(x+3)/2f(x) = 2x - 3, g(x) = (x + 3)/2. Compute fgf \circ g and gfg \circ f.
  2. f(x)=x2+1,g(x)=x1f(x) = x^2 + 1, g(x) = \sqrt{x - 1}. State the domains where fgf \circ g and gfg \circ f are defined.
  3. Find a function ff with ff=If \circ f = I on R\mathbb{R}. (Hint: try f(x)=xf(x) = -x or f(x)=cxf(x) = c - x.)
  4. Prove fIA=ff \circ I_A = f for any f:ABf : A \to B.
  5. If f(x)=ax+bf(x) = ax + b, find conditions on a,ba, b so that ff=If \circ f = I.
  6. Let f(x)=xx1f(x) = \tfrac{x}{x - 1} on R{1}\mathbb{R} \setminus \{1\}. Compute fff \circ f.
  7. Show: if ff and gg both surjective from AA to AA, then gfg \circ f is surjective.
  8. Provide a counter-example: gfg \circ f surjective but ff not surjective.
  9. Compute (gf)(3)(g \circ f)(3) and (fg)(3)(f \circ g)(3) where f(x)=x+2,g(x)=x2f(x) = x + 2, g(x) = x^2.
  10. Given f:RRf : \mathbb{R} \to \mathbb{R} such that f(f(x))=x2+x+1f(f(x)) = x^2 + x + 1, find f(0)f(0).
  11. Prove associativity of composition rigorously by expanding each side at an arbitrary input.
  12. Find ff on R\mathbb{R} such that fff=If \circ f \circ f = I, but fIf \neq I.
  13. Let f,g:AAf, g : A \to A with fg=IAf \circ g = I_A. Show ff is onto and gg is one-one.
  14. If fg=gff \circ g = g \circ f for all gg, what can ff be?

Pitfalls / Tricks

  • Reading order matters: gfg \circ f means apply ff first, then gg. The notation reads right-to-left.
  • Composition is associative but never assume commutativity unless proved.
  • For finite sets the iteration fn=ffff^n = f \circ f \circ \dots \circ f (nn times) is eventually periodic; in JEE it is common to ask for f100f^{100} in disguise.
  • The reversal formula (gf)1=f1g1(g \circ f)^{-1} = f^{-1} \circ g^{-1} is the same pattern as (AB)1=B1A1(AB)^{-1} = B^{-1} A^{-1} for matrices, and is also a daily formula in the matrices chapter.

Once you trust composition, inverses become a one-line definition.

Practice quiz

Quick check on this topic.

Quiz
Quick check : Composition of functions
6 questions · pick the best answer
Q1

Q2

Q3

Q4

Q5

Q6