# Composition of Mappings/Examples/Compositions of x^2 with 2x+1

## Example of Compositions of Mappings

Let $f: \R \to \R$ be the real function defined as:

$\forall x \in \R: \map f x = x^2$

Let $g: \R \to \R$ be the real function defined as:

$\forall x \in \R: \map g x = 2 x + 1$

Then the compositions of $f$ with $g$ are:

$f \circ g: \R \to \R$:

$\forall x \in \R: \map {\paren {f \circ g} } x = \paren {2 x + 1}^2$

$g \circ f: \R \to \R$:

$\forall x \in \R: \map {\paren {g \circ f} } x = 2 x^2 + 1$

Note that:

$\map {\paren {f \circ g} } 1 = \paren {2 \times 1 + 1}^2 = 9$
$\map {\paren {g \circ f} } 1 = 2 \times 1^2 + 1 = 3$

demonstrating that composition of mappings is in general not commutative.