In mathematics, function composition is the construction of a function out of two others by taking the value or output of one function and using it as the argument or input to another function.
If f and g are functions, then we may evaluate the function g on an input x to produce an output y, written : we then take y as the input to f to produce a further output z, written . The composite function that takes the initial input x to the final output z is the composite function, written .
For function composition to make sense, the set of possible outputs of g must be a subset of the set of permissible inputs of f: that is, the image of g must be contained in the domain of f. In some contexts, the stricter requirement may be imposed that functions may only be composed if the codomain of the first function is equal to the domain of the second.
Function composition is associative but need not be commutative: indeed it is quite possible that it makes no sense to compose f and g in the reverse order.
The chain rule in calculus describes the derivative of the composite of differentiable functions.