<s>[INST] How to integrate $\int dx \frac{1}{\cosh^2 x +a^2}$ How to integrate that function
$$\int  \frac{1}{\cosh^2 x +a^2}dx$$,
What I did was rewrite $$\cosh^2 x  = ({\frac {{e}^x+{e}^{-x}}{2}})^2 $$
then $$\int  \frac{1}{({\frac {{e}^x+{e}^{-x}}{2}})^2 +a^2}dx=$$ $$\frac{1}{4}\int  \frac{1}{e^{2x}+e^{-2x}+4{a}^2 }dx$$,
Multiplu by ${e}^x $
 $$\frac{1}{4}\int  \frac{e^{x}}{e^{x}(e^{2x}+e^{-2x}+4{a}^2) }dx$$,
Let's take  ${e}^x=t $, it follows
$$\frac{1}{4}\int  \frac{dt}{t(t^{2}+t^{-2}+4{a}^2) }dx$$,
this integral is,
$$\frac{1}{4}\ \frac{t}{t(4a^{2}+t^{2}+{t}^{-2}) }$$
Finally, we only need to rewrite this expression taking care ${e}^x=t $
 [/INST] Expand of the comment from lab.
\begin{align}
&\int \frac{1}{\cosh^2 x +a^2} dx\\
=&\int \frac{\mathrm{sech} ^2x}{1  +a^2\mathrm{sech} ^2x} dx \\
=&\int \frac{1}{1 +a^2(1-\tanh^2x)} d\tanh x \qquad\text{let $y=\tanh x$}\\
=&\int \frac{d y}{(1+a^2)-a^2y^2}\\
=&\frac{1}{a^2}\int \frac{d y}{-y^2+\frac{1+a^2}{a^2}}\qquad \text{let $y=\sqrt{\frac{1+a^2}{a^2}}\mathrm{tanh}\,z$}\\
=&\frac{1}{a^2}\sqrt{\frac{a^2}{1+a^2}} z\\
=&\frac{1}{a^2}\sqrt{\frac{a^2}{1+a^2}}\mathrm{arctanh}\frac{y}{\frac{\sqrt{1+a^2}}{a}} \\
=&\frac{1}{a\sqrt{1+a^2}}\mathrm{arctanh} \frac{ay}{\sqrt{1+a^2}}\\
=&\frac{1}{a\sqrt{1+a^2}}\mathrm{arctanh}\frac{a \tanh x}{\sqrt{1+a^2}}
\end{align}
</s>