Judicious guess for the solution of differential equation $y''-2y'+5y=2(\cos t)^2 e^t$ I want to find the solutions of the differential equation: $y''-2y'+5y=2(\cos t)^2 e^t$.
I want to do this with the judicious guessing method and therefore I want to write the right part of the differential equations as the imaginary part of a something. How can I do this?

We use the technique of the operator $D$. Note that $y^{\prime \prime} - 2y^{\prime} + 5y = (D^2 - 2D + 5)y$. Hence,
$$
(D^2 - 2D + 5)y = 2\cos^2(t) e^t =  e^t[1 + \cos (2t)] = e^t + e^t\cos(2t) \quad \Rightarrow
$$
$$
y(t) = \dfrac{1}{D^2 -2D + 5}\cdot 0 + \dfrac{1}{D^2 -2D + 5}e^{1t} + \dfrac{1}{D^2 -2D + 5}e^t\cos(2t) \quad \Rightarrow 
$$
$$
 y(t) = \dfrac{1}{(D-1)^2 + 2^2}\cdot 0 + \dfrac{1}{1^2 -2\cdot 1 + 5}e^t + e^t\dfrac{1}{D^2 + 4}\cos(2t) \quad \Rightarrow
$$
$$
 \quad  (1) \quad y(t) = e^t[C_1\cos(2t) + C_2\sin(2t)] + \dfrac{1}{4}e^t + e^t\dfrac{1}{D^2 + 4}\cos(2t) \quad \Rightarrow
$$
But, 
$$
\dfrac{1}{D^2 + 4}e^{2it} = e^{2it}\dfrac{1}{(D + 2i)^2 + 4}\cdot 1 = e^{2it}\dfrac{1}{(D + 4i)}\cdot \dfrac{1}{D}\cdot 1 = \dfrac{e^{2it}}{4i}\dfrac{1}{1 + \dfrac{D}{4i}}t
$$
$$
= \dfrac{e^{2it}}{4i}(1 - \dfrac{D}{4i} + \ldots)\cdot t =  \dfrac{e^{2it}}{4i}(t - \dfrac{1}{4i}) = \dfrac{e^{2it}(1 - 4it)}{16}
$$
Thus,
$$
\dfrac{1}{D^2 + 4}\cos(2t) = Re\biggl[\dfrac{e^{2it} - 4ite^{2it}}{16}\biggr] = \dfrac{\cos(2t)}{16} + \dfrac{t\sin(2t)}{4} \quad (2)
$$
Replacing (2) in (1), we have
$$
y(t) = e^t[C_1\cos(2t) + C_2\sin(2t)] + \dfrac{1}{4}e^t + \dfrac{e^t\cos(2t)}{16} + \dfrac{te^t\sin(2t)}{4}
$$
