Solution:
The auxiliary equation is $D^{2}-16=0$
$\therefore D=4,-4$
$\therefore$ The C.F. is $y=C_{1} e^{4 x}+C_{2} e^{-4 x}$
Now, to find $\mathrm{P.I.}$
P.I. $=\frac{1}{D^{2}-16}\left(x^{2} e^{3 x}+e^{2 x}-\cos 3 x+2^{x}\right)$
Now, $\frac{1}{D^{2}-16} x^{2} e^{3 x}=e^{3 x} \cdot \frac{1}{(D+3)^{2}-16} \cdot x^{2}$
$\quad=e^{3 x} \cdot \frac{1}{D^{2}+6 D+9-16} \cdot x^{2}=e^{3 x} \cdot \frac{1}{D^{2}+6 D-7} \cdot x^{2}$
$=-\frac{e^{3 x}}{7} \cdot \frac{1}{\left(1-\frac{D^{2}+6 D}{7}\right)} \cdot x^{2}$
$=-\frac{e^{3 x}}{7} \cdot\left(1-\frac{D^{2}+6 D}{7}\right)^{-1} \cdot x^{2}$
$=-\frac{e^{3 x}}{7}\left(1+\frac{D^{2}+6 D}{7}+\frac{D^{4}+6 D^{3}+36 D^{2}}{49}+\cdots\right) \cdot x^{2}$
$=-\frac{e^{3 x}}{7}\left(x^{2}+\frac{12 x+2}{7}+\frac{72}{49}\right)=-\frac{e^{3 x}}{7}\left(x^{2}+\frac{12 x}{7}+\frac{86}{49}\right)$
$\therefore \frac{1}{D^{2}-16} \cdot e^{2 x}=e^{2 x} \frac{1}{2^{2}-16}=e^{2 x} \cdot \frac{1}{2^{2}-16}=e^{2 x} \cdot \frac{1}{12}$
$\therefore \frac{1}{D^{2}-16} \cdot \cos 3 x=\frac{\cos 3 x}{-9-16}=\frac{\cos 3 x}{-25}$
$\therefore \frac{1}{D^{2}-16} \cdot 2^{x}=\frac{1}{D^{2}-16} \cdot e^{x \log 2}=\frac{e^{x \log 2}}{(\log 2)^{2}-16} \cdot=\frac{2^{x}}{(\log 2)^{2}-16}$
$\therefore P .I=-\frac{e^{3 x}}{7}\left(x^{2}+\frac{12 x}{7}+\frac{86}{49}\right)+e^{2 x} \cdot \frac{1}{12}+\frac{\cos 3 x}{25}+\frac{2^{x}}{(\log 2)^{2}-16}$
$\therefore$ The complete equation is,
$y=C_{1} e^{4 x}+C_{2} e^{-4 x}-\frac{e^{3 x}}{7}\left(x^{2}+\frac{12 x}{7}+\frac{86}{49}\right)+e^{2 x} \cdot \frac{1}{12}+\frac{\cos 3 x}{25}+\frac{2^{x}}{(\log 2)^{2}-16}$