Let \(f(x) = 3x -1\) and \(g(x) = x^2 + 1\text{.}\) Then:
- \(f(2) = 3(2) -1 = 6-1 = 5\) and \(g(2) = 2^2+1 = 4+1 =5\text{.}\)
- \((g \circ f)(2) = g(f(2)) = g(5) = 26\text{.}\)
- \((f \circ g)(2) = f(g(2)) = f(5) = 14\text{.}\)
- Note: the previous two bullet points imply that \((g \circ f)(x)\) is not necessarily equal to \((f \circ g)(x)\text{.}\) The order in which functions are composed matters!
- \(\displaystyle (g\circ f)(y) = g(f(y)) = g(3y-1) = (3y-1)^2 + 1 = 9y^2-6y + 1 + 1 = 9y^2-6y + 2\)
- \(\displaystyle (f\circ g)(x) = f(g(x)) = f(x^2 + 1) = 3(x^2 + 1) - 1 = 3x^2 + 3 -1 = 3x^2 +2\)
- Both \((g \circ f)\) and \((f \circ g)\) have domain equal to the set of all real numbers.