Solution to the $\displaystyle \phi'' + 4\phi' + 3\phi = x \cos {3x}. $ I came across the following differential equation while practicing  $ \displaystyle \phi'' + 4\phi' + 3\phi  = x \cos {3x} .$
Now, I used VARIATION OF PARAMETERS to solve it. I found general solution the equation $ \displaystyle \phi'' + 4\phi' + 3\phi  = 0 $ to be $\displaystyle C_1 e^{-3x} + C_2 e^{-x}.$
Now we need to find two functions $\lambda \ \text{and} \ \nu $ such that $\displaystyle \lambda'e^{-3x} + \nu'e^{-x} = 0 $ and $\displaystyle -3\lambda'e^{-3x} - \nu'e^{-x} = x \cos {3x} .$
Then the general solution would be : $\displaystyle \lambda e^{-3x} + \nu e^{-x} .$
On solving I got : $$\displaystyle \lambda = -\frac {1}{2} \int x \cdot \cos{3x} \cdot e^{3x} \mathrm {d}x \\  \nu = \frac {1}{2} \int x \cdot \cos{3x} \cdot e^{x} \mathrm {d}x  $$
These integrals took me a long time to solve. I used the traditional DI method to solve for it.
Finally getting the answer as : $$ \displaystyle C_1 e^{-3x} + C_2 e^{-x} + \frac {x}{30} ( 2 \sin {3x} - \cos {3x}  ) + \frac {47}{1800}\cos {3x}  +\frac {19}{200}\sin {3x} .  $$
I want my answer to get verified and am open to some good way to the integral quickly.
Thank you in advance.
 A: Why don't you try the Laplace transform? It gives
$$
s^2\Phi(s)-s\phi(0)-\phi'(0) + 4(s\Phi(s)-\phi(0))+3\Phi(s) = \frac{s^2-9}{\left(s^2+9\right)^2}
$$
and then
$$
\Phi(s) = \frac{1}{s^2-4s+3}\frac{s^2-9}{\left(s^2+9\right)^2}+\frac{1}{s^2-4s+3}\left((s-4)\phi(0)+\phi'(0)\right)
$$
The first part corresponds to a particular solution and the second to the homogeneous solution. Thus
$$
\cases{
\Phi_p(s) = \frac{1}{s^2-4s+3}\frac{s^2-9}{\left(s^2+9\right)^2}\\
\Phi_h(s) = \frac{1}{s^2-4s+3}\left((s-4)\phi(0)+\phi'(0)\right)
}
$$
and
$$
\phi_p(x) = \frac{1}{450} \left(18 e^x-30 x \sin (3 x)-\sin (3 x)-15 x \cos (3 x)-18 \cos(3 x)\right)
$$
etc. all using calculated tables.
A: HINT
Here it is another way to solve it for the sake of curiosity:
\begin{align*}
y'' + 4y' + 3y = x\cos(3x) & \Longleftrightarrow (y'' + y') + (3y' + 3y) = x\cos(3x)\\\\
& \Longleftrightarrow (y' + y)' + 3(y' + y) = x\cos(3x)\\\\
& \Longleftrightarrow u' + 3u = x\cos(3x)\\\\
& \Longleftrightarrow \exp(3x)u' + 3\exp(3x)u = x\cos(3x)\exp(3x)\\\\
& \Longleftrightarrow (\exp(3x)u)' = x\cos(3x)\exp(3x)\\\\
& \Longleftrightarrow \exp(3x)u = \int x\cos(3x)\exp(3x)\mathrm{d}x + k\\\\
& \Longleftrightarrow y' + y = \exp(-3x)\int x\cos(3x)\exp(3x)\mathrm{d}x + k\exp(-3x)
\end{align*}
Can you take it from here?
A: You can also apply the method of undetermined coefficients to find the particular solution. The solution to the complementary differential equation   $\phi'' + 4\phi' + 3\phi=0$ is
$$\phi_c(x) =c_1e^{-3x}+c_2e^{-x}.$$
Thus to find the particular solution to $\phi'' + 4\phi' + 3\phi = x \cos {3x}$ we try a particular solution of the form
$$\phi_p(x)=(Ax+B)\cos(3x)+(Cx+D)\sin(3x).$$
Hence
$$\phi_p'(x)=(A + 3Cx + 3D)\cos(3 x)+(-3 A x - 3 B + C) \sin(3 x), $$
$$\phi_p''(x)= (-9 A x - 9 B + 6 C)\cos(3 x) +  (-6 A -9Cx-9D)\sin(3 x).$$
Plugging these into the differential equation gives
\begin{equation}
\begin{split}
(-6A+12C)x\cos(3x) +(-6C-12A)x\sin(3x)+(4A-6B+6C+12D)\cos(3x)\\
+(-6A-12B+4C-6D)\sin(3x)=x\cos(3x).
\end{split}
\end{equation}
Therefore by relating coefficients
$$-6C-12A =0 \implies C=-2A,$$
$$-6A+12C=1 \implies \boxed{A=-\frac{1}{30}}, \quad \boxed{C=\frac{1}{15}},$$
$$4A-6B+6C+12D=0 \implies -6B+12D = -\frac{4}{15}\implies D = \frac{B}{2} -\frac{1}{45},$$
$$-6A-12B+4C-6D=0 \implies -15B+\frac{2}{15}=-\frac{7}{15}\implies \boxed{B=\frac{1}{25}}, \quad \boxed{D= -\frac{1}{450}}.$$
So the particular solution becomes
$$\phi_p(x)=\left(-\frac{1}{30}x+\frac{1}{25}\right)\cos(3x)+\left(\frac{1}{15}x-\frac{1}{450}\right)\sin(3x).$$
