Step 1: Use trigonometric inverse identities.
Let
\[
t=\tan^{-1}x
\]
Then,
\[
\frac{dt}{dx}=\frac{1}{1+x^2}
\]
Also,
\[
\sec t=\sqrt{1+\tan^2t}
\]
Since
\[
\tan t=x,
\]
we get
\[
\sec t=\sqrt{1+x^2}
\]
Therefore,
\[
\sec^{-1}\sqrt{1+x^2}=t=\tan^{-1}x
\]
Also,
\[
\cos 2t=\frac{1-\tan^2t}{1+\tan^2t}
\]
So,
\[
\cos 2t=\frac{1-x^2}{1+x^2}
\]
Hence,
\[
\cos^{-1}\left(\frac{1-x^2}{1+x^2}\right)=2t=2\tan^{-1}x
\]
Step 2: Convert the integral in terms of \(t\).
The given integral becomes
\[
\int e^t\left(t^2+2t\right)dt
\]
Step 3: Recognize the derivative form.
We know that
\[
\frac{d}{dt}\left(e^t t^2\right)
=
e^t t^2+e^t\cdot 2t
\]
\[
=
e^t(t^2+2t)
\]
Therefore,
\[
\int e^t(t^2+2t)dt=e^t t^2+C
\]
Step 4: Substitute back \(t=\tan^{-1}x\).
Thus,
\[
e^t t^2+C
=
e^{\tan^{-1}x}\left(\tan^{-1}x\right)^2+C
\]
Step 5: Final conclusion.
Therefore,
\[
\boxed{e^{\tan^{-1}x}\left(\tan^{-1}x\right)^2+C}
\]