Answer: The general solution is \(y=e^{-x}(A\cos\sqrt{3}x+B\sin\sqrt{3}x)+x^2-x+2\).
First solve the associated homogeneous equation
\(\frac{\mathrm{d}^2y}{\mathrm{d}x^2}+2\frac{\mathrm{d}y}{\mathrm{d}x}+4y=0\).
Try \(y=e^{mx}\). Then
\(m^2+2m+4=0\).
So
\(m=\frac{-2\pm\sqrt{4-16}}{2}=-1\pm\sqrt{3}\,i\).
Hence the complementary function is
\(y_c=e^{-x}(A\cos\sqrt{3}x+B\sin\sqrt{3}x)\),
where \(A\) and \(B\) are arbitrary constants.
Now find a particular integral. Since the right-hand side is a quadratic, try
\(y_p=px^2+qx+r\).
Then
\(y_p'=2px+q\), \(y_p''=2p\).
Substitute into the differential equation:
\(2p+2(2px+q)+4(px^2+qx+r)=4x^2+8\).
Expanding gives
\(4px^2+(4p+4q)x+(2p+2q+4r)=4x^2+8\).
Equating coefficients of like powers of \(x\):
\(4p=4\Rightarrow p=1\),
\(4p+4q=0\Rightarrow 1+q=0\Rightarrow q=-1\),
\(2p+2q+4r=8\Rightarrow 2-2+4r=8\Rightarrow r=2\).
So a particular integral is
\(y_p=x^2-x+2\).
Therefore the general solution is
\(y=e^{-x}(A\cos\sqrt{3}x+B\sin\sqrt{3}x)+x^2-x+2\).