Solve $x^2 \frac{d^2y}{dx^2}+4x \frac{dy}{dx} + 2y= \cos x$ Solve $$x^2 \frac{d^2y}{dx^2}+4x \frac{dy}{dx} + 2y= \cos x$$
My attempt: Let $x=e^u$, and $D=\frac{d}{du}$ then the given equation becomes $$(D+2)(D+1)y=\cos(e^u)$$
Solving the corresponding homogeneous equation, taking $y=e^{mx}$, 
I got $m=-1,-2$, so the C.F. is $$y_c=c_1e^{-u}+c_2e^{-2u}$$
My trouble is with finding the particular integral.
$y_p=\dfrac{\cos(e^u)}{(D+1)(D+2)}$
Now, I can break the denominator part like this: 
$$\dfrac{1}{(D+1)(D+2)}=\dfrac{(1+D)^{-1}(1+\frac D2)^{-1}}{2}=\dfrac{(1-D)(1-\frac D2)}{2}$$
Now, $D(\cos(e^u))=-e^u\sin(e^u)$, 
So $$y_p=\dfrac{\cos(e^u)}{(D+1)(D+2)}=\dfrac{(1-D)(1-\frac D2)(\cos(e^u))}{2}$$
gives me $$y_p=\dfrac{\cos(e^u)+e^u\sin(e^u)-\frac{e^{2u}\sin(e^u)}{2}}{2}$$
But I am supposed to get just:  $$y_p=-e^{-2u}\cos(e^u)$$
Can somebody please explain what I'm doing wrong? Thank you!
 A: Hint
$$(x^2y)''=(x^2y'+2xy)'=x^2y''+4xy'+2y$$
A: You're wrong regarding your Complementary function; here youre trying the ansatz y=exp(mx)... The homog. part of this problem is one of Euler-Cauchy form.... I.e. you should be trying y=x^n .... dy/dx= n x^(n-1) .... dy^2/dx^2 =n(n-1)x^(n-2)... sub in to the LHS=0 , divide both sides by x^n, and you're left with a quadratic for which two n you need, your C.F. side will be of the form y=a x^(n1)+bx^(n2) , where n1 and n2 are the roots of the quadratic from your substitution... Your particular integral , one of trig form, is rather simple... so I'll leave that for you to do.
A: I think this method is a bit strange, and I'm not familiar with it so well that I can say what is going wrong. The only thing I see is the point I mentioned in the comment.
However, let me try to make sense of
$$
(D+1)^{-1}(D+2)^{-1}\cos(e^u).
$$
You make this rigorous. 
First, we note that
$$
\begin{aligned}
(D+a)\cos(e^u)&=-e^u\sin(e^u)+a\cos(e^u),\quad\text{and}\\
(D+b)\sin(e^u)&=e^u\cos(e^u)+b\sin(e^u)
\end{aligned}
$$
Thus
$$
\begin{aligned}
\cos(e^u)&=(D+a)^{-1}\bigl[-e^u\sin(e^u)+a\cos(e^u)\bigr]\qquad(*)\\
&=-e^u(D+a+1)^{-1}\sin(e^u)+a(D+a)^{-1}\cos(e^u)
\end{aligned}
$$
and
$$
\begin{split}
\sin(e^u)&=(D+b)^{-1}\bigl[e^u\cos(e^u)+b\sin(e^u)\bigr]\qquad(**)\\
&=e^u(D+b+1)^{-1}\cos(e^u)+b(D+b)^{-1}\sin(e^u).
\end{split}
$$
We find that
$$
\begin{split}
(D+2)^{-1}\cos(e^u)&\stackrel{(**)}{=}e^{-u}\sin(e^u)-e^{-u}(D+1)^{-1}\sin(e^u)\\
&\stackrel{(*)}{=}e^{-u}\sin(e^u)+e^{-2u}\cos(e^u)
\end{split}
$$
Applying $(D+1)^{-1}$, and using $(D+c)^{-1}e^{dx}=e^{dx}(D+c+d)^{-1}$,
$$
\begin{split}
(D+1)^{-1}(D+2)^{-1}\cos(e^u)&=(D+1)^{-1}e^{-u}\sin(e^u)+(D+1)^{-1}e^{-2u}\cos(e^u)\\
&=e^{-u}D^{-1}\sin(e^u)+e^{-2u}(D-1)^{-1}\cos(e^u)\qquad{(***)}
\end{split}
$$
Now, by $(*)$ with $a=-1$,
$$
e^{-u}D^{-1}\sin(e^u)=-e^{-2u}\cos(e^u)-e^{-2u}(D-1)^{-1}\cos(e^u).
$$
If we insert this in $(***)$, we find that one term cancels, and we are left with

$$
(D+1)^{-1}(D+2)^{-1}\cos(e^u)=-e^{-2u}\cos(e^u).
$$

In the end, this means that the general solution to the original differential equation is
$$
y(x)=\frac{c_1}{x}+\frac{c_2}{x^2}-\frac{\cos x}{x^2},
$$
which of course could have been found with simpler methods, or by just recognizing the second derivative of $x^2y$, as in the answer by @n-s.
