Composite functions

Feed the output of one machine straight into a second machine and you get a new machine — that is a composite function, the algebraic idea of "a function of a function." In ISC Class 12, composite functions sit inside Unit 1, Relations and Functions, right after one-one/onto classification and invertibility. They matter for two concrete reasons. First, forming g∘fg \circ f and finding its domain is a standard Section-A skill in its own right. Second, composition is the tool used to check that a guessed formula really is the inverse of a given function: you compose it both ways and see whether you land back on the identity function. This article builds the definition, the domain rule, the order-matters warning, and the inverse-checking method — all fully algebraic, with no calculus needed until the chain rule appears later.

The core insight

The composite (g∘f)(x)=g(f(x))(g \circ f)(x) = g(f(x)) chains two functions so that ff acts first and gg acts on its output, is defined only where f(x)f(x) lands inside the domain of gg, and generally satisfies g∘f≠f∘gg \circ f \neq f \circ g.

The core idea

Composition takes two functions and glues them into one, in a fixed order.

Definition. Given f:A→Bf : A \to B and g:B→Cg : B \to C, the composite function g∘f:A→Cg \circ f : A \to C is

(g∘f)(x)=g(f(x))(g \circ f)(x) = g\big(f(x)\big)

where: ff is the inner function applied first, gg is the outer function applied to ff's result, and A,B,CA, B, C are the domain, intermediate set, and final codomain. Reading the symbol right to left matches the order of operations: in g∘fg \circ f, ff acts on xx before gg acts on f(x)f(x).

Domain of a composite. Even when ff and gg each look defined "everywhere," the glued function can fail somewhere in between, because f(x)f(x) must be a legal input to gg:

domain(g∘f)={x∈domain(f):f(x)∈domain(g)}\text{domain}(g \circ f) = \{x \in \text{domain}(f) : f(x) \in \text{domain}(g)\}

where: the right-hand condition is checked in two stages — first xx must be allowed into ff at all, and second the output f(x)f(x) must be allowed into gg. Dropping the second check is the single most common domain error in this topic.

Order matters. In general g∘f≠f∘gg \circ f \neq f \circ g; composition is not commutative, and frequently only one of the two orders is even defined (if the output set of one function does not match the input set the other expects). Composition is, however, associative: (h∘g)∘f=h∘(g∘f)(h \circ g) \circ f = h \circ (g \circ f), so a three-function chain can be written unambiguously as h∘g∘fh \circ g \circ f with no brackets needed.

Composition and inverses. If f:A→Bf : A \to B is a bijection with inverse f−1:B→Af^{-1} : B \to A, composing ff with its own inverse — in either order — collapses back to doing nothing at all:

(f−1∘f)(x)=x for all x∈A,(f∘f−1)(y)=y for all y∈B(f^{-1} \circ f)(x) = x \text{ for all } x \in A, \qquad (f \circ f^{-1})(y) = y \text{ for all } y \in B

where: the left identity undoes ff then f−1f^{-1}, the right identity undoes f−1f^{-1} then ff, and both must hold simultaneously for f−1f^{-1} to be a genuine inverse. This pair of identities is exactly how an algebraic guess for an inverse gets verified.

Figure
Two arrows chain set A to set B to set C labelled f then g with a curved arrow underneath labelled g circ f going directly from A to C
Composition chains f then g: g of f of x A x B f of x C g of f of x f g g circ f — do f first, then g
Derivation ADomain of a composite function

The definition (g∘f)(x)=g(f(x))(g \circ f)(x) = g(f(x)) says nothing by itself about where the composite is defined — that requires tracking two domains at once, since a value that is legal for ff can still be illegal for gg once it becomes gg's input, and this two-stage check is the step students skip most often. Work it out for functions with genuine restrictions rather than the all-real-numbers case, and the reasoning generalises to any pair of functions.

Step 1. Fix the functions and their own domains. Let f(x)=x−1f(x) = \sqrt{x - 1}, so ff needs x−1≥0x - 1 \geq 0, giving domain(f)=[1,∞)(f) = [1, \infty). Let g(x)=1x−3g(x) = \dfrac{1}{x - 3}, so gg needs x≠3x \neq 3, giving domain(g)=R∖{3}(g) = \mathbb{R} \setminus \{3\}.

Step 2. Form the composite algebraically. Substituting f(x)f(x) into gg: (g∘f)(x)=g(f(x))=1x−1−3(g \circ f)(x) = g(f(x)) = \dfrac{1}{\sqrt{x-1} - 3}. This expression is the candidate rule, but its domain is not simply "domain(f)(f)" — it must respect gg's restriction too.

Step 3. Apply the two-stage domain check. First, xx must be a legal input to ff, so x≥1x \geq 1. Second, the output f(x)=x−1f(x) = \sqrt{x-1} must be a legal input to gg, meaning x−1≠3\sqrt{x-1} \neq 3. Squaring, x−1≠9x - 1 \neq 9, so x≠10x \neq 10.

Step 4. Combine both conditions into the composite's domain. domain(g∘f)=[1,∞)∖{10}(g \circ f) = [1, \infty) \setminus \{10\} — every x≥1x \geq 1 works except x=10x = 10, where the denominator of gg would vanish. This excluded point is invisible if you only look at ff's domain [1,∞)[1,\infty); it only appears once you trace what ff outputs through gg's restriction, which is the entire point of the two-stage rule.

Worked example

Let f(x)=2x+1f(x) = 2x + 1 and g(x)=x2−3g(x) = x^2 - 3, both with domain R\mathbb{R}. Find (g∘f)(x)(g \circ f)(x) and (f∘g)(x)(f \circ g)(x), evaluate each at x=2x = 2, and confirm the two orders give different functions.

Step 1. Form g∘fg \circ f by substituting f(x)f(x) into gg: (g∘f)(x)=g(2x+1)=(2x+1)2−3=4x2+4x+1−3=4x2+4x−2(g\circ f)(x) = g(2x+1) = (2x+1)^2 - 3 = 4x^2 + 4x + 1 - 3 = 4x^2 + 4x - 2.

Step 2. Form f∘gf \circ g by substituting g(x)g(x) into ff: (f∘g)(x)=f(x2−3)=2(x2−3)+1=2x2−6+1=2x2−5(f\circ g)(x) = f(x^2-3) = 2(x^2-3)+1 = 2x^2 - 6 + 1 = 2x^2 - 5.

Step 3. Evaluate both at x=2x = 2: (g∘f)(2)=4(4)+4(2)−2=16+8−2=22(g\circ f)(2) = 4(4) + 4(2) - 2 = 16+8-2 = 22, and (f∘g)(2)=2(4)−5=8−5=3(f\circ g)(2) = 2(4) - 5 = 8 - 5 = 3.

Step 4. Compare. Since 22≠322 \neq 3, (g∘f)(2)≠(f∘g)(2)(g\circ f)(2) \neq (f\circ g)(2), confirming algebraically that g∘f≠f∘gg \circ f \neq f \circ g — order genuinely matters here, not just in principle.

Competitive stretch

Now use composition to check an inverse: let f(x)=2x−35f(x) = \dfrac{2x-3}{5} and the candidate inverse g(x)=5x+32g(x) = \dfrac{5x+3}{2}. Compute g(f(x))=5(2x−35)+32=(2x−3)+32=2x2=xg(f(x)) = \dfrac{5\left(\frac{2x-3}{5}\right)+3}{2} = \dfrac{(2x-3)+3}{2} = \dfrac{2x}{2} = x, and f(g(x))=2(5x+32)−35=(5x+3)−35=5x5=xf(g(x)) = \dfrac{2\left(\frac{5x+3}{2}\right)-3}{5} = \dfrac{(5x+3)-3}{5} = \dfrac{5x}{5} = x. Both compositions return xx, so g=f−1g = f^{-1} is confirmed — this two-way check is the standard algebraic method for verifying an inverse.

Common traps

  • Substituting in the wrong order: (g∘f)(x)(g\circ f)(x) means "ff first, then gg," i.e. g(f(x))g(f(x)) — many students compute f(g(x))f(g(x)) instead when asked for g∘fg \circ f.
  • Ignoring the second domain check: a composite can be undefined for some xx even when ff and gg each look fine individually — always verify f(x)f(x) lands inside domain(g)(g), not just that xx lands inside domain(f)(f).
  • Assuming g∘f=f∘gg \circ f = f \circ g by default — equality is the rare exception, confirmed only by direct computation, never assumed.
  • Checking only one of g∘f=idg\circ f = \mathrm{id} or f∘g=idf \circ g = \mathrm{id} and declaring g=f−1g = f^{-1} — a rigorous verification needs both directions checked.

Ask the tutor: If forming g∘fg \circ f, nailing its domain, or verifying an inverse via composition is tripping you up, ask the AI tutor for a fresh pair of functions to practise on.

Why do we need to check the domain of g composed with f separately, isn't the domain of f enough?

Because f(x)f(x) becomes the input to gg, and gg may reject values that ff happily produces. A classic case: f(x)=x−1f(x) = \sqrt{x-1} is fine for all x≥1x \geq 1, but if gg has a denominator that vanishes at one particular output value of ff, that single xx must be excluded from the composite even though it was perfectly legal for ff alone. Always trace the output of ff through gg's restrictions before declaring the composite's domain.

How is checking an inverse by composition different from just swapping x and y to find the inverse?

Swapping xx and yy (and solving) is how you find a candidate formula for f−1f^{-1}; composing is how you prove that candidate is correct. If g(f(x))=xg(f(x)) = x for every xx in the domain and f(g(y))=yf(g(y)) = y for every yy in the range, both identities hold and gg is confirmed as f−1f^{-1}. Skipping this check risks accepting an algebra slip as if it were a verified inverse — examiners specifically reward showing both compositions.

Why does order matter in composition when it does not matter in ordinary multiplication?

Because g∘fg \circ f and f∘gf \circ g generally build entirely different rules, not just reorder the same operation. Multiplication combines two numbers symmetrically, but composition feeds the entire output of one function into another as a fresh input, and squaring-then-doubling is rarely the same as doubling-then-squaring. The worked example above shows this concretely: (g∘f)(2)=22(g\circ f)(2) = 22 while (f∘g)(2)=3(f\circ g)(2) = 3 for the same two functions, so the two orders are simply different objects.

Before this

Where this leads