# Composition of Functions

## Definition and Properties

Similarly to relations, we can compose two or more functions to create a new function. This operation is called the composition of functions.

Let \(g: A \to B\) and \(f: B \to C\) be two functions such that the range of \(g\) equals the domain of \(f.\) The composition of the functions \(f\) and \(g,\) denoted by \(f \circ g,\) is another function defined as

Since functions are a special case of relations, they inherit all properties of composition of relations and have some additional properties. We list here some of them:

- The composition of functions is associative. If \(h: A \to B,\) \(g: B \to C\) and \(f: C \to D,\) then \(\left( {f \circ g} \right) \circ h = f \circ \left( {g \circ h} \right).\)
- The composition of functions is not commutative. If \(g: A \to B\) and \(f: B \to C,\) then, as a rule, \(f \circ g \ne g \circ f.\)
- Let \(g: A \to B\) and \(f: B \to C\) be injective functions. Then the composition of the functions \(f \circ g\) is also injective.
- Let \(g: A \to B\) and \(f: B \to C\) be surjective functions. Then the composition of the functions \(f \circ g\) is also surjective.
- It follows from the last two properties that if two functions \(g\) and \(f\) are bijective, then their composition \(f \circ g\) is also bijective.

## Examples

### Example 1. Composition of Functions Defined on Finite Sets

Consider the sets \(A = \left\{ {1,2,3,4} \right\},\) \(B = \left\{ {a,b,c,d} \right\}\) and \(C = \left\{ \alpha, \beta, \gamma, \delta \right\}.\) The functions \(g: A \to B\) and \(f:B \to C\) are defined as

It is convenient to illustrate the mapping between the sets in an arrow diagram:

Given the mapping, we see that

Hence, the composition of functions \(f \circ g\) is given by

This is represented in the following diagram:

### Example 2. Composition of Functions Defined on Infinite Sets

Let \(g: \mathbb{R} \to \mathbb{R}\) and \(f: \mathbb{R} \to \mathbb{R}\) be two functions defined as

Determine the composite functions \(f \circ g,\) \(g \circ f,\) \(f \circ f,\) \(g \circ g.\)

The first composite function \(\left(f \circ g\right)\left(x\right) = f\left( {g\left( x \right)} \right)\) is formed when the inner function \({g\left( x \right)}\) is substituted for \(x\) in the outer function \({f\left( x \right)}.\) This yields:

Similarly we find the other composite functions:

## Compositions Involving Inverse Functions

Let \(f: A \to B\) be a bijective function from domain \(A\) to codomain \(B.\) Then it has an inverse function \({f^{-1}}\) that maps \(B\) back to \(A.\) Then

where \({I_A}\) is the identity function in the domain \(A\) and \(x\) is any element of \(A.\)

Similarly,

where \({I_B}\) is the identity function in the codomain \(B\) and \(y\) is any element of \(B.\)