# Function composition

In mathematics, **function composition** is an operation that takes two functions *f* and *g* and produces a function *h* such that *h*(*x*) = *g*(*f*(*x*)). In this operation, the function *g* is applied to the result of applying the function *f* to *x*. That is, the functions *f* : *X* → *Y* and *g* : *Y* → *Z* are **composed** to yield a function that maps *x* in *X* to *g*(*f*(*x*)) in *Z*.

Function |
---|

x ↦ f (x) |

Examples of domains and codomains |

Classes/properties |

Constructions |

Generalizations |

Intuitively, if *z* is a function of *y*, and *y* is a function of *x*, then *z* is a function of *x*. The resulting *composite* function is denoted *g* ∘ *f* : *X* → *Z*, defined by (*g* ∘ *f* )(*x*) = *g*(*f*(*x*)) for all *x* in *X*.[nb 1]
The notation *g* ∘ *f* is read as "*g* circle *f* ", "*g* round *f* ", "*g* about *f* ", "*g* composed with *f* ", "*g* after *f* ", "*g* following *f* ", "*g* of *f*", "*f* then *g*", or "*g* on *f* ", or "the composition of *g* and *f* ". Intuitively, composing functions is a chaining process in which the output of function *f* feeds the input of function *g*.

The composition of functions is a special case of the composition of relations, sometimes also denoted by . As a result, all properties of composition of relations are true of composition of functions,[1] though the composition of functions has some additional properties.

Composition of functions is different from multiplication of functions, and has quite different properties; in particular, composition of functions is not commutative.[2]