Finding a particular solution to a differential equation what is the particular solution for the following differential equation?
$$D^3 (D^2+D+1)(D^2+1)(D^2-3D+2)y=x^3+\cos\left(\frac{\sqrt{3}}2x \right)+xe^{2x}+\cos(x)$$
I tried Undetermined Coefficients and it took so long to solve it,not to mention it was on an exam. I was wondering if there could be any faster and simpler solution. 
 A: Because this is an equation with constant coefficients, this in principle can be attacked using a Laplace transform.  Here, for the sake of simplicity, I will assume that $y(0)$ and the first eight derivatives of $y$ at $x=0$ are zero.  Then the Laplace transform of $y(x)$, $Y(p)$, is
$$\begin{align} Y(p) &= \left [ \frac{6}{p^4}+\frac{p}{p^2+1}+\frac{p}{p^2+\frac{3}{4}}+\frac{1}{(p-2)^2}\right ] \frac1{p^3 (p^2+p+1) (p^2+1) (p-2) (p-1)}\\ &= \frac{8 p^9-28 p^8+39 p^7+3 p^6-68 p^5+141 p^4-168 p^3+186 p^2-72 p+72}{ p^7 (p-1) (p-2)^3 \left(p^2+1\right)^2 \left(4 p^2+3\right)(p^2+p+1)} \end{align}$$
Inverting this Laplace Transform, as one might expect, will be an extremely messy business but is indeed possible by using the definition of the inverse LT and the Residue Theorem.  The poles, their orders, and their residues are as follows:
$$\begin{array} \\ \text{pole} & \text{order} & \text{residue} \\ 0 & 7 & \frac{1}{960} \left(4 x^6+12 x^5-90 x^4+300 x^3+1950 x^2+310 x+125\right) \\ (i, -i) & 2 & \frac{1}{500} ((25 x+502) \sin{x}+(75 x+761) \cos{x}) \\ 1 & 1 & -\frac{113}{84} e^x \\ 2 & 3 & \frac{ 1}{52136000} \left(93100 x^2-747460 x+1929133\right) e^{2 x} \\ \left ( e^{i 2 \pi/3},e^{i 4 \pi/3} \right ) & 1 & \frac{1}{13377} \left( 13045 \sqrt{3} \sin \left(\frac{\sqrt{3} x}{2}\right)-9883 \cos \left(\frac{\sqrt{3} x}{2}\right) \right) e^{-x/2} \\ \left ( i \frac{\sqrt{3}}{2},- i \frac{\sqrt{3}}{2}\right ) & 1 & \frac{512 }{15561} \left(12 \cos \left(\frac{\sqrt{3} x}{2}\right)-41 \sqrt{3} \sin \left(\frac{\sqrt{3} x}{2}\right)\right)\end{array} $$
$y(x)$ is simply the sum of the residues in the right column of the above table.
A: I will not write to you the particular solution, but let me indicate how you can make an ansatz.
The ansatz depends on how the solutions look like for the homogeneous equation.
Homogeneous equation
The roots to the characteristic equation are
$$
0,\ 0,\ 0,\ -\frac{1}{2}\pm i\frac{\sqrt{3}}{2},\ \pm i,\ 1,\ 2.
$$
Thus, the solution $y_h$ to the homogeneous differential equation 
$$
D^3 (D^2+D+1)(D^2+1)(D^2-3D+2)y=0
$$
is given by
$$
\begin{aligned}
y_h(x)&=A+Bx+Cx^2+e^{-x/2}\bigl(D\cos(\sqrt{3}x/2)+E\sin(\sqrt{3}x/2)\bigr)\\
&+F\cos x+G\sin x+He^x+Ie^{2x}
\end{aligned}
$$
where $A$, $B$, $C$, $D$, $E$, $F$, $G$, $H$ and $I$ are arbitrary constants.
The ansatz
Your right-hand side consists of a sum of several types of functions. One can consider each of them separately, and then add all of them together.
For $x^3$ you would like to make the ansatz $a+bx+cx^2+dx^3$. By looking at the solution of the homogeneous equation, we find that we already have a second degree polynomial there. We thus multiply our original ansatz with $x^3$ (the lowest degree that makes our ansatz differ from the solution of the homogeneous equation). Thus, the ansats for that part becomes
$$
x^3(a+bx+cx^2+dx^3).
$$
Next, the $\cos(\sqrt{3}x/2)$ part. We have no such part in the solution of the homogeneous equation, and thus, the ansatz becomes
$$
f\cos(\sqrt{3}x/2)+g\sin(\sqrt{3}x/2)
$$
(remember that sine and cosine should come together).
For the part $xe^{2x}$ we would like to make the ansatz $(h+jx)e^{2x}$. But since we have $Ie^{2x}$ in the solution of the homogeneous equation, we have to multiply by $x$. The ansatz becomes
$$
x(h+jx)e^{2x}
$$
Finally, for the $\cos(x)$ we would like to make the ansatz $k\cos x+l\sin x$. However, these functions are present in the solution of the homogeneous equation, and our ansatz becomes
$$
x(k\cos x+l\sin x).
$$
To sum up, an ansatz that will work is
$$
\begin{align}
y_p(x) &= x^3(a+bx+cx^2+dx^3)+f\cos(\sqrt{3}x/2)+g\sin(\sqrt{3}x/2)\\
 &+x(h+jx)e^{2x}+x(k\cos x+l\sin x).
\end{align}
$$
I leave it to you 1) differentiate to determine the coefficients and 2) lock up the person who told you to calculate the particular solution to this problem and throw away the key...
A: For the term $x^3$, use the indeterminate coefficients method ($6^{th}$ degree polynomial).
For the terms $\cos\left(\frac{\sqrt{3}}2x \right)$ and $\cos(x)$ use the complex exponential form and keep the real part of $e^{i\lambda x}/Y(i\lambda)$.
For the term $xe^{2x}$, also use indeterminate coefficients. Rewriting the characteristic polynomial as a function of $D-2$ coud help as
$$(D-2)x^ke^{2x}=kx^{k-1}e^{2k}+2x^ke^{2x}-2x^ke^{2x}=kx^{k-1}e^{2x}.$$
