Evaluating $\int e^{x\sin x+\cos x}\left(\frac{x^4\cos^3 x-x\sin x+\cos x}{x^2\cos^2 x}\right)dx$ Evaluate 

$$\displaystyle \int e^{x\sin x+\cos x}\left(\frac{x^4\cos^3 x-x\sin x+\cos x}{x^2\cos^2 x}\right)dx$$

$\bf{My\; Try::}$ 
Let $$\begin{align}I &= \int e^{x\sin x+\cos x}\left(\frac{x^4\cos^3 x-x\sin x+\cos x}{x^2\cos^2 x}\right)dx\\
&=\int e^{x\sin x+\cos x}\left(x^2\cos x+\frac{\cos x-x\sin x}{x^2\cos^2 x}\right)dx\\
&= \int x\cdot e^{x\sin x+\cos x}\left(x\cos x\right)dx+\int e^{x\sin x+\cos x}\left(\frac{\cos x-x\sin x}{x^2\cos^2 x}\right)dx\\
\end{align}$$
Now Let $x\sin x+\cos x = t\;,$ Then $x\cos x\,dx = dt$ and Integration by parts for $\bf{1^{st}}$ Integral
So $$\displaystyle I = x\cdot e^{x\sin x+\cos x}-\int e^{x\sin x+\cos x}dx+\int e^{x\sin x+\cos x}\left(\frac{\cos x-x\sin x}{x^2\cos^2 x}\right)dx$$
Now I do not understand how to solve after that.

Of course $\left( e^{x\sin x + \cos x}\right)' = x\cos x . e^{x\sin x + \cos x}$. But in the integrand we have terms such as $x^2\cos x.e^{...}$. So let's try
$$\left(x e^{x\sin x + \cos x}\right)' = (x^2 \cos x + 1)e^{...}$$
Hence the integral
$$I = x e^{x\sin x + \cos x} + \int e^{x\sin x + \cos x} \left( \frac{-\sin x}{x\cos^2 x} + \frac{1}{x^2\cos x} - 1 \right) \ dx$$
If we're lucky, the integrand of this new integral is exact in as much as it equals $$\left( f(x) e^{x\sin x + \cos x} \right)' = e^{x\sin x + \cos x} \left( f'(x) + x\cos x . f(x) \right) $$
Based on first two terms, something like $\displaystyle f(x) = -\frac{1}{x \cos x}$ looks like a good candidate. In fact that works. Hence
$$I = e^{x\sin x + \cos x} \left( x - \frac{1}{x\cos x} \right) + C$$
