<s>[INST] Find $\int [e^{\tan x} (1-\tan x)^2\cos^2 x]dx$ Let $\tan x=t$
$$\int [e^t (1-\tan x)^2 \cos^2 x \frac{1}{\sec^2x} ]dt$$
$$\int [e^t (\cos x-\sin x)^2 \cos^2 x ]dt$$
$$\int [e^t (1-\sin 2x)\cos^2 x] dt$$
How do I solve further?
 [/INST] $(1-\tan x)^2 = 1+\tan^2x-2\tan x $
So, if you let $\tan x = t \Rightarrow dx = \dfrac{dt}{\sec^2x} = \dfrac{dt}{1+t^2}$ and $\cos^2x = \dfrac{1}{1+t^2}$
$\begin{align}\Rightarrow I = \int e^{t}(1+t^2-2t)\dfrac{dt}{(1+t^2)^2} & = \int e^t\left[\dfrac{1}{1+t^2 }-\dfrac{2t}{(1+t^2)^2}\right]dt\end{align}$
Now, $\dfrac{d}{dt}\left(\dfrac{1}{1+t^2}\right) = \dfrac{-2t}{(1+t^2)^2}$
We have

$\begin{align}\int e^x(f(x)+f'(x))dx = e^xf(x)\end{align}$

So, you have $I = \begin{align}e^t\dfrac{1}{1+t^2} +c = e^{\tan x}(\cos^2 x) +c\end{align}$
</s>