<s>[INST] How find this ODE:$y''-y'+y=x^2e^x\cos{x}$ Find this follow ODe solution
$$y''-y'+y=x^2e^x\cos{x}$$
I konw  solve this follow three case
$$y''-y'+y=x^2\cos{x}$$
$$y''-y'+y=e^x\cos{x}$$
$$y''-y'+y=x^2e^x$$
But for $f(x)=x^2e^x\cos{x}$, I can't.
Thank you  very much!
 [/INST] One more way to solve it is using the Laplace transformation $\mathcal{L}.$
Let $\mathcal{L}(y)=Y(p).$  Then
$$
\mathcal{L}(y')=p Y(p)-y(0),\\
\mathcal{L}(y'')=p^2 Y(p)-y'(0)-p y(0),\\ \text{and, using the standard rules  for L.t.}\\
\mathcal{L}({x}^{2}{{\rm e}^{x}}\cos \left( x \right))=\frac{1}{\left( p-1-i \right) ^{3}}+ \frac{1}{\left( p-1+i \right) ^{3}}
$$
We have  now 
$$
 \left( {p}^{2}-p+1 \right) Y \left( p \right) -py \left( 0 \right) +y
 \left( 0 \right) -  y'  \left( 0 \right) =
 \frac{1}{\left( p-1-i \right) ^{3}}+ \frac{1}{\left( p-1+i \right) ^{3}},
$$
or 
$$
Y(p)={\frac {1}{ \left( p-1-i \right) ^{3} \left( {p}^{2}-p+1 \right) }}+{\frac {1}{ \left( p-1+i \right) ^{3} \left( {p}^{2}
-p+1 \right) }}-{\frac {-py \left( 0 \right) +y \left( 0 \right) -
 y''   \left( 0 \right) }{{p}^{2}-p+1}}.
$$
To find $y$ we  compute the inverse Laplace transform for $Y(p).$ After some calculation we get
$$
y(x)=\mathcal{L}^{-1}(Y(p))=\left( 2\,\cos \left( x \right)  \left( -3+x \right) +\sin \left( x \right)  \left( 6-4\,x+{x}^{2} \right)  \right) {{\rm e}^{x}}+1/3\,
 \left( 3\,\cos \frac{\sqrt {3}x}{2}  \left( 6+y \left( 0
 \right)  \right) +\sin \frac{\sqrt {3}x}{2}  
 \left( -10+2\, y''   \left( 0 \right) -y \left( 0
 \right)  \right)  \right) {{\rm e}^{\frac 12\,x}}.
$$
After simplification taking into account that $y(0), y'(0)$  are constant we get 
$$
y(x)={{e}^{\frac 12\,x}}(\sin \frac{\sqrt {3}x}{2} { C_1}+\cos \frac{\sqrt {3}x}{2} {C_2})+ \left( 2\,\cos \left( x \right)  \left( x-3
 \right) +\sin \left( x \right)  \left( 6-4\,x+{x}^{2} \right) 
 \right) {{ e}^{x}},
$$
for  some constant $C_1, C_2.$
</s>