Let
\(f(x) = x^2 + 2x - 1\) and
\(g(x) = 3x - 5\) be functions from
\(\RR\) to
\(\RR\text{.}\)
Let’s compute some compositions. First, consider \(f \circ g\text{.}\)
\begin{align*}
(f \circ g) (x) \amp = f(g(x)) \\
\amp = f(3x - 5) \\
\amp = (3x - 5)^2 + 2(3x - 5) - 1 \\
\amp = (9x^2 - 30x + 25) + (6x - 10) - 1 \\
\amp = 9x^2 - 24x + 14.
\end{align*}
Next, let’s compose them in the opposite order.
\begin{align*}
(g \circ f)(x) \amp = g(f(x)) \\
\amp =g(x^2 + 2x - 1) \\
\amp = 3(x^2 + 2x - 1) - 5 \\
\amp = (3x^2 + 6x - 3) - 5 \\
\amp = 3x^2 + 6x - 8.
\end{align*}
Finally, let’s compose \(g\) with itself.
\begin{align*}
(g \circ g) (x) \amp = g(g(x)) \\
\amp = g(3x - 5) \\
\amp = 3(3x - 5) - 5 \\
\amp = (9x - 15) - 5 \\
\amp = 9x - 20.
\end{align*}