Definition. [Function Composition] The composition of two functions \( f \) and \( g \) is written \( f \circ g \) (
$f \circ g$), which means applying \( g \) first and then \( f \).
If \( f: B \to C \) and \( g: A \to B \), then the composition \( f \circ g: A \to C \) is defined by \( (f \circ g)(x) = f(g(x)) \).
For example, if \( f(x) = x^2 \) and \( g(x) = x + 1 \), then $(f \circ g)(x) = $$\;f(g(x)) = $$\;(x + 1)^2$.
Function composition is not necessarily commutative, meaning \( f \circ g \ne g \circ f \) in general. For example, if \( f(x) = x^2 \) and \( g(x) = x + 1 \) again, then $(g \circ f)(x) = $$\;g(f(x)) = $$\;x^2 + 1 \neq $$\;(x + 1)^2 = $$\;f(g(x)) = $$\;(f \circ g)(x)$.
The domain of the composition \( f \circ g \) is the set of all \( x \) such that \( g(x) \) is in the domain of \( f \).
Function composition is associative: \( f \circ (g \circ h) = (f \circ g) \circ h \).