Composition of functions

Forming a new function by applying one function after another
Composition of functions

A composition of functions is the function obtained by applying one function after another: if f:ABf:A\to B and g:BCg:B\to C are (so the codomain of ff matches the domain of gg), then the composition gf:ACg\circ f:A\to C is defined by

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

Composition is associative when defined, and act as identities for composition. If ff is , then composing with its recovers the appropriate identity functions.

Examples:

  • Let f:ZZf:\mathbb{Z}\to\mathbb{Z} be f(n)=n+1f(n)=n+1 and let g:ZZg:\mathbb{Z}\to\mathbb{Z} be g(n)=2ng(n)=2n; then (gf)(n)=2(n+1)=2n+2(g\circ f)(n)=2(n+1)=2n+2.
  • If i:SAi:S\to A is the inclusion of a and f:ABf:A\to B is any function, then fi:SBf\circ i:S\to B is the restriction of ff to SS.