<s>[INST] How can I solve the following 2nd Order DE? $$y''-\frac{1}{x}y'=2x\cdot cos(x)$$
For the homogeneous part I multiplied through with $x^2$ and got a second order Cauchy Euler equation with the general solution: $$y_h (x)=A x^2 +B$$
Then for the particular solution I tried using the method of undetermined coefficients but the whole thing became too entangled to solve and I couldn't get anywhere!
Maple tells me the solution is: $$2sin(x) - 2x\cdot cos(x)+ \frac{C_1\cdot x^2 }{2}+C_2$$
but I can't figure it out...
Any help would be appreciated!
 [/INST] This reduces the problem to a first order Diff Eq.
$u= y'\\
xu' - u = 2x^2\cos x$
Choose a candidate for the particular solution that could work.
$u_p = x\sin x$
"Generalize" this by adding terms that might come up in the derivative that we hope will cancel out.  Give every term a coefficient.
$u_p = Ax\sin x + Bx\cos x + C\sin x+ D\cos x$
Differentiate and plug into the original equation.
$u_p' = A\sin x + Ax\cos x + B\cos x - Bx\sin x + C\cos x - D\sin x\\
u_p' = - Bx\sin x + Ax\cos x + (A-D)\sin x + (B+C)\cos x$
$xu_p' - u_p = - Bx^2\sin x +  Ax^2\cos x -Dx\sin x + Cx\cos x - C\sin x - D\cos x = 2x^2\cos x$
$A = 2, B,C,D = 0$
$u_p = 2x\sin x\\
y_p' = 2x\sin x\\
y_p = \int x\sin x \ dx = -2x\cos x + 2\sin x + C$
$y = y_h + y_p = Ax^2 + B - 2x\cos x + 2\sin x$
</s>