---
tag: 07HF9YCWPP
kind: definition
name: Function composition
msc: ["03E20"]
defines: 0THBK9V825
uses: [0XHDTE5YMZ]
sources:
  - url: https://en.wikipedia.org/wiki/Function_composition
    locator: lead section
---

## Definition

Let $f \colon A \to B$ and $g \colon B \to C$ be [[functions|0XHDTE5YMZ]].
The composition of $g$ and $f$ is the function $g \circ f \colon A \to C$ with
$$(g \circ f)(a) = g(f(a))$$
for each $a \in A$.

## Remarks

Read $g \circ f$ as "$g$ after $f$": $f$ acts first.
In general $g \circ f \neq f \circ g$. For $f(x) = x + 1$ and $g(x) = 2x$ on $\mathbb{R}$, $(g \circ f)(x) = 2x + 2$ and $(f \circ g)(x) = 2x + 1$.
Composition is associative. See [[associativity of composition|0J6AKYZQT8]].

## Explanations

### L1 human

Composition chains two machines: the output of $f$ goes into $g$.
For $g \circ f$ to make sense, the values of $f$ must lie in the domain of $g$.
