Indefinite integral of secant cubed $\int \sec^3 x\>dx$ 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$.
 A: Immediate calculation of $$\int \sec ^{3}xdx.$$
We need the basic formulas of the first two derivatives of $\sec x:$\begin{eqnarray*}
(\sec x)^{\prime } &=&\sec x\tan x \\
(\sec x)^{\prime \prime } &=&2\sec ^{3}x-\sec x
\end{eqnarray*}
Then 
\begin{eqnarray*}
\int \sec ^{3}xdx &=&\frac{1}{2}\int \sec xdx+\frac{1}{2}\int (\sec
x)^{\prime \prime }dx \\
&=&\frac{1}{2}\ln \left\vert \sec x+\tan x\right\vert +\frac{1}{2}(\sec
x)^{\prime }+C \\
&=&\frac{1}{2}\ln \left\vert \sec x+\tan x\right\vert +\frac{1}{2}\sec x\tan
x+C.
\end{eqnarray*}
A: 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. 
A: It appears that Mathematica is using the "universal change" for trigonometric integrals $\tan(x/2)=t$:
http://en.wikibooks.org/wiki/Calculus/Integration_techniques/Tangent_Half_Angle.
A: $\int  \sqrt (1 + x^2) dx$
let $x = \tan \theta $
then $dx = \sec ^2\theta  d\theta $
we have the integral is then:
$\int  \sec ^3\theta  d\theta $ 
recall:
$\tan ^2\theta  + 1 = \sec ^2\theta $
and write as:
$\int  \sec \theta (\sec ^2\theta )d\theta  $
continue with integration by parts,
by letting:
$u = \sec \theta $
and
$dv = \sec ^2\theta  d\theta $
we have:
$v = \tan \theta $
and
$du = \sec \theta \tan \theta  d\theta $  
and thus,
$uv - \int vdu$ 
is then:
$\sec \theta \tan \theta  - \int \sec \theta \tan ^2\theta  d\theta $
recall: 
$\tan ^2\theta  + 1 = \sec ^2\theta $
we have:
$\sec \theta \tan \theta  - \int \sec \theta (\sec ^2\theta  - 1) d\theta $
after distribution, altogether we have:
$\int \sec ^3\theta  d\theta  = \sec \theta \tan \theta  - \int \sec ^3\theta  d\theta  - \int \sec \theta  d\theta $
rearranging and collecting like-terms:
$2\int \sec ^3\theta  d\theta  = \sec \theta \tan \theta  - \int \sec \theta  d\theta $
$2\int \sec ^3\theta  d\theta  = \sec \theta \tan \theta  - \ln |\sec \theta  + \tan \theta |$
$\int \sec ^3\theta  d\theta  = (1/2)[\sec \theta \tan \theta  - \ln |\sec \theta  + \tan \theta |]$
+++++++++++++++++++++++++++
without u\sin g integration tables, we can derive 
$\int \sec \theta  d\theta $
..........
$=\int 1/\cos \theta  d\theta $
$=\int \cos \theta /\cos ^2\theta  d\theta $
$=\int \cos \theta /(1 - \sin ^2\theta ) d\theta $
let $u = \sin \theta $
then $du = \cos \theta  d\theta $
we have:
$\int 1/(1 - u^2) du$
partial fractions:
$A/(1 - u) + B/(1 + u) = 1$
$A + B = 1$
$A - B = 0$
$A = 1/2$
$B = 1/2$
we have:
$-(1/2)\ln |1 - u| + (1/2)\ln |1 + u|$
by rules of logarithms:
$(1/2)\ln |(1 + u)/(1 - u)|$
$(1/2)\ln |(1 - u^2)/(1 - u)^2|$
by rules of logarithms:
$\ln |\sqrt (1 - u^2)/(1 - u)|$
recall:
$u = \sin \theta $ 
$\ln |\sqrt (1 - \sin ^2\theta )/(1 - \sin \theta )|$
$\ln |\sqrt \cos ^2\theta /(1 - \sin \theta )|$
$\ln |\cos \theta /(1 - \sin \theta )|$
$\ln |\cos \theta (1 + \sin \theta )/(1 - \sin ^2\theta )|$
$\ln |\cos \theta (1 + \sin \theta )/\cos ^2\theta |$
$\ln |1/\cos \theta  + \sin \theta /\cos \theta |$
$\ln |\sec \theta  + \tan \theta |$
++++++++++++++++++++++++++++
but the integral of $\int \sec ^3\theta  d\theta $ is:
$\int \sec ^3\theta  d\theta  = (1/2)[\sec \theta \tan \theta  - \ln |\sec \theta  + \tan \theta |]$ + CONS\tan T
and \sin ce 
$\tan \theta  = x = x/1 =$ opposite/adjacent,
with the pythagorean theorem, we derive:
hypotenuse = $\sqrt (1 + x^2)$
and thus, $\sec \theta $ = hypotenuse/adjacent = $\sqrt (1 + x^2)$
$\int  \sqrt (1 + x^2) dx$
$= (1/2)[x\sqrt (1 + x^2) - \ln |\sqrt (1 + x^2) + x|]$ + CONS\tan T
A: $\newcommand{\+}{^{\dagger}}%
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\down}{\downarrow}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\fermi}{\,{\rm f}}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\half}{{1 \over 2}}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}%
 \newcommand{\ol}[1]{\overline{#1}}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
\begin{align}
&\color{#c00000}{\int\sec^{3}\pars{x}\,\dd x}= \int\sec\pars{x}\,\dd\tan\pars{x}
=
\tan\pars{x}\sec\pars{x} - \int\tan\pars{x}\bracks{\sec\pars{x}\tan\pars{x}}\,\dd x  
\\[3mm]&=
\tan\pars{x}\sec\pars{x} - \int\sec^{3}\pars{x}\,\dd x
+\int\sec\pars{x}\,\dd x
\\[3mm]&=
\tan\pars{x}\sec\pars{x} - \color{#c00000}{\int\sec^{3}\pars{x}\,\dd x}
+ \ln\pars{\sec\pars{x} + \tan\pars{x}}  
\end{align}

$$\color{#0000ff}{\large%
\int\sec^{3}\pars{x}\,\dd x
=
\half\bracks{\tan\pars{x}\sec\pars{x} + \ln\pars{\vphantom{\LARGE A}\sec\pars{x} + \tan\pars{x}}}} + \pars{\mbox{a constant}}
$$

A: Hint: rewrite the integral as
$$\int \sec ^3 (x) \, dx$$
Recall the identity $\sec^2(x)=\tan^2(x)+1$.
So, substituting, you get
$$\int\sec(x)(\tan^2(x)+1) \, dx=\int\tan(x)\tan(x)\sec(x) \, dx+\int\sec(x) \, dx.$$
The first integral can be solved by $u$-substitution and integration by parts, while the second, is an identity.
$$\int\tan(x) \, d\sec(x) = \tan(x)\sec(x)-\int\sec(x) \, d\tan(x)$$
But $\int\sec(x) \, d\tan(x)$ is the original integral.  So write an equation and solve for $\int \sec^3(x)dx$
A: Let $I =  \int \sec^3 x dx$
$$\begin{align}
I &=  \int \sec^3   \;\; \text{(by parts)} \\  
  &= \int \sec^2 x \sec x dx \\
  &= \tan x \sec x - \int \tan x  (\sec \tan x) dx \\
  &= \tan x \sec x - \int \sec x (\sec^2 x - 1) dx\\
  &=  \tan x \sec x - I \int \sec x dx         \;\;  \text{(       No need for "c" yet; still an integral to go)}
\end{align}$$
Rearrange:
$$2I = \sec x \tan x + \int \sec x dx$$
so
$$ I - (1/2) \sec x \tan x + \ln (A (\sec x + tan x))
$$
         (here, $c = ln|A|$)
For int sqrt (1 + z^2) dz       put z = sinh u
and obtain an equivalent result
A: For the integral:
$$\int \sqrt{1+x^2}dx$$ 
Put $x=\sinh(u), dx=\cosh(u)du$
The integral becomes:
$$\int (\cosh(u))^2 du$$
Use the definition $$\cosh(u)=\frac{e^u+e^{-u}}{2}$$
to see the integral becomes:
$$\int \frac{e^{2u}+2+e^{-2u}}{4}du$$
So remembering $$\int e^{au}du=\frac{e^{au}}{a}$$
The integral evaluates to: $$\frac{e^{2u}}{8}+\frac{e^{-2u}}{-8}+\frac{u}{2}+C=\frac{\sinh(2u)}{4} +\frac{u}{2}+ C=\frac{\sinh(u)\cosh(u)}{2} +\frac{u}{2}+ C
$$
Putting every thing in terms of x, the integral is
$$\frac{x\sqrt{x^2+1}}{2}+\frac{\sinh^{-1}(x)}{2}+C$$
