Composition of functions

The function obtained by applying one function after another.
Composition of functions

Let f:XYf:X\to Y and g:YZg:Y\to Z be functions. The composition of gg with ff is the function

gf:XZ,(gf)(x):=g(f(x)).g\circ f:X\to Z,\qquad (g\circ f)(x):=g(f(x)).

Composition formalizes successive application of maps and is the basic operation for building new functions from old ones. In analysis, the chain rule concerns derivatives of compositions, and continuity is stable under composition.

Examples:

  • If f:RRf:\mathbb{R}\to\mathbb{R}, f(x)=x2f(x)=x^2 and g:RRg:\mathbb{R}\to\mathbb{R}, g(y)=y+1g(y)=y+1, then (gf)(x)=x2+1(g\circ f)(x)=x^2+1.
  • If f:R(0,)f:\mathbb{R}\to(0,\infty) is f(x)=exf(x)=e^x and g:(0,)Rg:(0,\infty)\to\mathbb{R} is g(y)=logyg(y)=\log y, then gf=idRg\circ f=\mathrm{id}_{\mathbb{R}}.
  • Composition is only defined when the codomain of ff matches the domain of gg (or at least f(X)dom(g)f(X)\subseteq \mathrm{dom}(g) if one allows partial maps).