Question about general solution of inhomogeneous ODE $u''+4u= 8x^2 +13e^{3x}+16\cos(2x)$ Given the initial conditions: $u(0)=0$ and $u'(0)=0,$
I need to solve:

$u''+4u= 8x^2 +13e^{3x}+16\cos(2x)$ 

The solution from the book is : $ u = A\cos 2x + B\sin 2x + 2x^
2 − 1 + e^{3x} + 4x\sin(2x), A = 0, B = -\frac{3}{2}.$
And the solution I got was: 
$ u = A\cos 2x + B\sin 2x + 2x^
2 − 1 + e^{3x} + Ex\cos(2x) + Fx\sin(2x)$
$Ex\cos(2x) + Fx\sin(2x)$ was found by applying annihilator method on $16\cos(2x)$: $$(D^2+4)(D^2+4)=0$$
Now since $u(0)=0$,
you get $A=0$.
$u'(x):$ $$=-2A\sin(2x) +2B\cos(2x)+4x+3e^{3x}+E\cos(2x) +F\sin(2x)+x[-2E\sin(2x) +2F\cos(2x)].$$
$u'(0)= 2B+E+3=0$ .
So just by observing, this $E$ is somehow $0$, and $F$ is $4$. I realised if I did the initial conditions separately, then $E$ is indeed $0$, but why is $F=4?$ (also by doing it separately for the homogeneous solution, then $A=0$ and $B=-\frac{3}{2}$
 A: $$u''+4u= 8x^2 +13e^{3x}+16\cos~2x $$
$$\implies (D^2+4)u=8x^2 +13e^{3x}+16\cos~2x \qquad \text{where $~D\equiv\frac{d}{dx}~$}$$
Clearly, complementary function (C.F.) is $$C_1 ~\cos 2x~+~C_2~\sin~2x\qquad \text{where $~C_1~, ~ C_2~$are arbitrary constants.}$$
Particular integral (P.I.) is
P.I.$~~=~~\frac{1}{D^2+4}~\left\{8x^2 +13e^{3x}+16\cos~2x \right\}$
$~~~~~~~=~\frac{8}{4}~\left(1+\frac{D^2}{4}\right)^{-1}~x^2~+~13~\frac{1}{D^2+4}~e^{3x}~+~16~\frac{1}{D^2+4}~\cos~2x$
$~~~~~~~=~2~\left(1-\frac{D^2}{4}+\cdots\right)~x^2~+~13~\frac{e^{3x}}{3^2+4}~+~16~\frac{x}{4}~\sin~2x$
$~~~~~~~=~2~\left(x^2-\frac{1}{2}\right)~+~e^{3x}~+~4~x~\sin~2x$
$~~~~~~~=(2~x^2-1)~+~e^{3x}~+~4~x~\sin~2x$
So the general solution is
$$u(x)=\text{C.F.$~+~$P.I.}$$
$$\implies u(x)~=C_1 ~\cos 2x~+~C_2~\sin~2x~+~(2~x^2-1)~+~e^{3x}~+~4~x~\sin~2x$$
Given that $~u(0)=0~\implies C_1~-1+1=0\implies C_1=0~,$
$~u'(0)=0~\implies 2~C_2~+~3=0\implies C_2=-\frac{3}{2} $
So the required solution of the given solution is $$u(x)~=~-\frac{3}{2}~\sin~2x~+~(2~x^2-1)~+~e^{3x}~+~4~x~\sin~2x$$
which is of the form $$u = A\cos 2x + B\sin 2x + 2x^
2 − 1 + e^{3x} + 4x\sin(2x), \qquad \text{where}~~~A = 0,~~ B = -\frac{3}{2}.$$



*

*If $f(D)$ can be expressed as $\phi(D^2)$ and $\phi(-a^2)\neq 0$, then

$1.$ $\frac{1}{f(D)} \sin ax=\frac{1}{\phi(D^2)} \sin ax = \frac{1}{\phi(-a^2)} \sin ax$
$2.$ $\frac{1}{f(D)} \cos ax=\frac{1}{\phi(D^2)} \cos ax = \frac{1}{\phi(-a^2)} \cos ax$
Note: If $f(D)$ can be expressed as $\phi(D^2)=D^2+a^2$, then $\phi(-a^2)= 0$.
$1.$ $\frac{1}{f(D)} \sin ax =\frac{1}{\phi(D^2)} \sin ax=x\frac{1}{\phi'(D^2)} \sin ax= x \frac{1}{2D} \sin ax= -\frac{x}{2a} \cos ax$.
$2.$ $\frac{1}{f(D)} \cos ax =\frac{1}{\phi(D^2)} \cos ax=x\frac{1}{\phi'(D^2)} \cos ax=  x \frac{1}{2D} \cos ax= \frac{x}{2a} \sin ax$.

${}$

Consider a differential equation of the form $f(D)y=X$
If $X=e^{ax}$, then
$1.$ P.I.$\quad = \frac{1}{f(D)}e^{ax}=\frac{e^{ax}}{f(a)}$, if $f(a)\neq 0$
$2.$ P.I.$\quad =\frac{1}{(D-a)^n}e^{ax}=\frac{x^n}{n!}e^{ax}$

