Solution:
Key idea: The composite (fog)(x) means f(g(x)): put the expression g(x) in place of x in the rule of f. (gof)(x) means g(f(x)): put f(x) into g. Then expand and collect like terms.
Step 1 — Part (i): substitute g(x) into f. We replace every x in x2+3x+1 by 2x−3.
(fog)(x)=f(2x−3)
(fog)(x)=(2x−3)2+3(2x−3)+1
Step 2 — Part (i): expand the brackets. We expand (2x−3)2 and 3(2x−3).
(fog)(x)=4x2−12x+9+6x−9+1
Step 3 — Part (i): collect like terms. The x terms give −6x and the constants give 1.
(fog)(x)=4x2−6x+1
Step 4 — Part (ii): substitute f(x) into g. We replace x in 2x−3 by x2+3x+1.
(gof)(x)=g(x2+3x+1)
(gof)(x)=2(x2+3x+1)−3
Step 5 — Part (ii): expand and simplify. We multiply out the bracket and combine the constants.
(gof)(x)=2x2+6x+2−3
(gof)(x)=2x2+6x−1
Therefore, (i) (fog)(x)=4x2−6x+1 and (ii) (gof)(x)=2x2+6x−1.