Question on indefinite integrals I have to integrate:
$$I_2 = \int \frac{e^{2x} - e^{x} + 1}{(e^x\cos(x) - \sin(x))\cdot \left(e^x\sin(x) + \cos(x)\right)} \text{d}x$$ 
I simply can't understand from where to begin with. Please help me in solving this problem.

I have a better solution to your problem
Here it goes:
\begin{aligned}
& \int \frac{e^{2 x}-e^{x}+1}{\left(e^{x} \sin x+\cos x\right)\left(e^{x} \cos x-\sin x\right)} dx \\
=& \int \frac{e^{2 x}-e^{x}+1}{\left(e^{2 x}+1\right) \sin \left(x+\tan ^{-1} \frac{1}{e^{x}}\right) \cdot \cos \left(x+\tan ^{-1} \frac{1}{e^{x}}\right)} d x \\
=&2 \int \frac{e^{2 x}-e^{x}+1}{\left(e^{2 x}+1\right) \sin \left(2 x+2 \operatorname{ta}^{-1}\left(\frac{1}{e^{x}}\right)\right)} d x \\
=&2 \int \frac{e^{2 x}-e^{x}+1}{\left(e^{2 x}+1\right) \sin \left(2 x+2 \cot ^{-1}\left(e^{x}\right)\right)} dx \\=&\int \operatorname{cosec}t~ dt=\ln \left|\tan \frac{t}{2}\right|+c \end{aligned}
where $t=2 x+2 \cot ^{-1}\left(e^{x}\right)$. Note that
$$\frac{d t}{d x}=2-\frac{2}{1+e^{2 x}} \cdot e^{x}=\frac{2\left(e^{2 x}-e^{x}+1\right)}{e^{2 x}+1}$$
Also, $\frac{t}{2}=x+\tan ^{-1}\left(\frac{1}{e^{x}}\right)$ so we have $$
\tan \frac{t}{2}=\frac{\tan x+\frac{1}{e^{x}}}{1-\frac{t x}{e^{x}}} =\frac{e^{x} \sin x+\cos x}{e^{x} \cos x-\sin x}$$
Thus the integral is $$ \boxed{\ln \left|\frac{e^{x} \sin x+\cos x}{e^{x} \cos x-\sin x}\right|+c} $$
