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$
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]\mathrm d x\\ &= \int e^{x\sin x+\cos x}\left[\frac{\cos x - x \sin x + x^4 \cos^3 x}{x^2\cos^2x}\right]\mathrm d x\tag{1}\\ &=\int e^{x\sin x+\cos x} \left[ \frac{1}{x^2 \cos x} -\frac{\sin x}{x\cos ^2x}+x^2\cos x\right]\mathrm d x\tag{2}\\ &=\int e^{x\sin x+\cos x} \left[ \frac{1}{x^2 \cos x} -\frac{\sin x}{x\cos ^2x}+1+x^2\cos x-1\right]\mathrm dx\tag{3}\\ &=\int e^{x\sin x+\cos x} \left[ \left(\frac{1}{x^2 \cos x} -\frac{\sin x}{x\cos^2x}+1\right) +(x\cos x)\left(x-\frac{1}{x\cos x}\right)\right] \mathrm dx \tag{4} \\ \end{align}$$
Notice that
$$\frac{ \mathrm d }{ \mathrm d x }\left[x- \frac{1}{x\cos x}\right]=\frac{1} { x^2\cos x } -\frac{\sin x}{x\cos^2x}+1$$ $$\frac{\mathrm d}{\mathrm dx}(x\sin x+\cos x)=x\cos x$$ Now use
$$\int e^t[ f ( t ) + f ' ( t ) ] \mathrm d t = e^t\cdot f(t ) +C$$
to get
$$\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)\mathrm d x=e^{x\sin x+\cos x}\left(x-\frac{1}{x\cos x}\right)+C$$
$\text{ Explanations }\\ 1 .\text{ Rearranging terms}\\ 2 .\text{ Seperating out terms}\\ 3 .\text{ Adding zero}\\ 4 .\text{ Grouping terms and factor }$
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$$