Example 16 Find gof and fog, if f : R → R and g : R → R are given by f(x) = cos x
and g(x) = 3x2 Show that gof ≠ fog Solution We have gof(x) =  g (f(x)) = g(cos x) = 3 (cos x)2 = 3 cos2 x Similarly,
fog(x) =  f(g(x)) =  f (3x2) = cos (3x2)