Find the general solution to $y''+2y'+4y=\sin x \cos x + 3x^2$ Given this equation $y''+2y'+4y=\sin x \cos x + 3x^2$, how do I find the general solution? It is obvious that this is a differential equation, so that's a start. However, this is a second order differential equation. And it doesn't have any elementary solutions. But then I realized I can convert $\sin x \cos x$ to $\frac{\sin (2x)}{2}$. Now, I can solve for $\lambda^2 + 2\lambda + 4 = 0$.
Now I have started on solving this equation and trying to get a general solution. So now I need some help, thank you!

First, solve the homogeneous equation. Here, you got $\lambda^2+2\lambda+4=0$, which gives $\lambda_1 = -1+ i\sqrt3, \lambda_2 = -1-i\sqrt3,$ so the homogeneous solution is $$y_h(x)=c_1 e^{-x}\cos(\sqrt3 x) + c_2 e^{-x}\sin(\sqrt3 x).$$
Now to get the particular solution, note that we have $f(x)=\frac{1}{2} \sin(2x) + 3x^2$, so using undetermined coefficients we will guess a solution of the form $y_p(x)=a_1 + a_2 x + a_3 x^2 + a_4 \cos(2x) + a_5 \sin(2x).$
Note that then:
$$y'_p(x) =a_2 +2a_3x - 2a_4 \sin(2x) + 2a_5 \cos(2x)$$
and
$$y''_p(x) = 2a_3 - 4a_4 \cos(2x) -4a_5 \sin(2x).$$
Replacing in the original ODE:
$$2a_3 - 4a_4 \cos(2x) -4a_5 \sin(2x) + 2(a_2 +2a_3x - 2a_4 \sin(2x) + 2a_5 \cos(2x)) + 4 (a_1 + a_2 x + a_3 x^2 + a_4 \cos(2x) + a_5 \sin(2x)) = \frac{1}{2} \sin(2x) + 3x^2$$
simplifying:
$$4a_1 + 2a_2 +2a_3 + (4a_2 + 4a_3) x + 4a_3 x^2 + 4a_5 \cos(2x) - 4a_4 \sin(2x) = 3x^2 + \frac{1}{2} \sin(2x)$$
Comparing coefficients:
\begin{align}
4a_1 + 2a_2 +2a_3 &= 0\\
4a_2 + 4a_3 &= 0\\
4a_3 &= 3\\
4a_5 &= 0\\
-4a_4 &= 1/2\\
\end{align}
Solving this system gives $a_1 = a_5 = 0, a_2 = -a_3 = 3/4, a_4=-1/8$
Replacing those values in $y_p(x)$ gives
$$y_p(x) = \frac{3}{4} x^2 - \frac{3}{4}x - \frac{1}{8} \cos(2x)$$
In that case, the general solution will be
$$y(x) = y_h(x) + y_p(x)$$
or
$$y(x) = \frac{3}{4} x^2 - \frac{3}{4}x - \frac{1}{8} \cos(2x) + c_1 e^{-x} \cos(\sqrt3 x) + c_2 e^{-x} \sin(\sqrt3 x).$$
