We're finding the function of (p+3), which means wherever there's an x, we're replacing it with (p+3).
2 (p+3)^2 + 3 (p+3) + 6
Foil out (p+3)^2.
2 (p^2 + 6p + 9) + 3 (p+3) + 6
Distribute.
2p^2 + 12p + 18 + 3p + 9 + 6
Add like terms.
g (p+3) = 2p^2 + 15p + 33