I need to calculate the following indefinite integral:
$$I=\int \frac{1}{\cos^3(x)}dx$$
I know what the result is (from Mathematica):
$$I=\tanh^{-1}(\tan(x/2))+(1/2)\sec(x)\tan(x)$$
but I don't know how to integrate it myself. I have been trying some substitutions to no avail.
Equivalently, I need to know how to compute:
$$I=\int \sqrt{1+z^2}dz$$
which follows after making the change of variables $z=\tan x$.
We have an odd power of cosine. So there is a mechanical procedure for doing the integration. Multiply top and bottom by $\cos x$. The bottom is now $\cos^4 x$, which is $(1-\sin^2 x)^2$. So we want to find $$\int \frac{\cos x\,dx}{(1-\sin^2 x)^2}.$$ After the natural substitution $t=\sin x$, we arrive at $$\int \frac{dt}{(1-t^2)^2}.$$ So we want the integral of a rational function. Use the partial fractions machinery to find numbers $A$, $B$, $C$, $D$ such that $$\frac{1}{(1-t^2)^2}=\frac{A}{1-t}+\frac{B}{(1-t)^2}+ \frac{C}{1+t}+\frac{D}{(1+t)^2}$$ and integrate.