Q: How to find integral of the form $e^xf(x)$? I always face trouble with these type of integrals.
I need to find $$\int{e^x \frac{x(\cos x -\sin x)-\sin x}{x^2}}dx$$
My problem would be solved if can express $f(x)$ like $g(x)+g'(x)$ but identifying $g(x)$ by trial and error method is sometimes tedious.Is there any easier approach?

A: As already said in comments, I do not think that there is a solution in terms of elementary functions.
However, the problem can be approached using $$\cos(x)=\frac{1}{2} \left(e^{i x}+e^{-i x}\right)\qquad \sin(x)=-\frac{1}{2} i \left(e^{i x}-e^{-i x}\right)$$ So, the numerator of the integrand becomes$$\left(\frac{1}{2}-\frac{i}{2}\right) e^{(1-i) x}
   x+\left(\frac{1}{2}+\frac{i}{2}\right) e^{(1+i) x} x-\frac{1}{2} i e^{(1-i)
   x}+\frac{1}{2} i e^{(1+i) x}$$ and we are then left with integrals looking like$$I=\int \frac{e^{\alpha x}} x \, dx\qquad J=\int \frac{e^{\alpha x}}{x^2} \, dx$$ Changing variable $\alpha x=y$ then makes $$I=\int \frac{e^y}{y}\,dy=\text{Ei}(y)$$ $$J= \alpha\int\frac{  e^y}{y^2}\,dy=\alpha  \left(\text{Ei}(y)-\frac{e^y}{y}\right)$$ where appears the exponential integral function (for the computation of $J$, one integration by parts is needed).
Using these last results and back to $x$ $$\int{e^x \frac{x(\cos x -\sin x)-\sin x}{x^2}}\, dx=i \Big(\text{Ei}((1+i) x)- \text{Ei}((1-i) x)\Big)+\frac{e^x \sin (x)}{x}$$
Edit
Looking at $$\int e^x\frac{ x (\cos (x)\pm \sin (x))\pm  \sin (x)}{x^2}\,dx$$ the only combination which leads to elementary functions is the combination $(+,-)$ and then $$\int e^x\frac{ x (\cos (x)+ \sin (x))-  \sin (x)}{x^2}\,dx=\frac{ \sin (x)}{x}e^x$$ So, one more typo in a textbook.

A: The typo can be not in the signs of the fraction but in the sign of the argument of the exponential function, that is if we replace $e^{x}$ by $e^{-x}$ the fraction remains as it is and the answer would be 
$$\frac{ \sin (x)}{x}e^{-x}+C,$$ since 
$$\int e^{-x}\frac{ x (\cos (x)- \sin (x))-  \sin (x)}{x^2}\,dx=\frac{ \sin (x)}{x}e^{-x}+C
$$ which can be obtained easly by parts. 
I think it is obvious to see that the fraction is nothing but $$f^\prime(x)-f(x)$$ where $f(x)$ is the product $f(x)=(\frac{1}{x}) \sin(x).$ Recall $ (\frac{1}{x})^\prime=-\frac{1}{x^2}$.
