\documentclass[a4paper]{article}
\begin{document}
\begin{eqnarray*}
f (x)
 & = & \cos^{n} (ax) \\
& = & \frac{1}{\cos^{- n} (ax)} \\
& = & \sec^{- n} (ax) \\
n
 & = & \mbox{oneven} \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
\int h (x) \, \mbox{d}g (x)
 & = & g (x) h (x) - \int g (x) \, \mbox{d}h (x) \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
f (x)
 & = & g (h (x)) \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
f^{\prime} (x)
 & = & g^{\prime} (h (x)) h^{\prime} (x) \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & \int \cos^{n} (ax) \, \mbox{d}x \\
& = & \int \frac{1}{\cos^{- n} (ax)} \, \mbox{d}x \\
& = & \int \frac{1}{\cos^{- n - 2} (ax)} \frac{1}{\cos^{2} (ax)} \, \mbox{d}x \\
& = & \int \frac{1}{a} \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}(\tan (ax)) \\
& = & \frac{1}{a} \frac{1}{\cos^{- n - 2} (ax)} \tan (ax) + c - \int \frac{1}{a} \tan (ax) \, \mbox{d} \left ( \frac{1}{\cos^{- n - 2} (ax)} \right ) \\
& = & \frac{1}{a} \frac{1}{\cos^{- n - 2} (ax)} \frac{\sin (ax)}{\cos (ax)} + c +
 (n + 2) \int \frac{\sin (ax)}{\cos (ax)} \frac{1}{\cos^{- n - 1} (ax)} \sin (ax) \, \mbox{d}x \\
& = & \frac{1}{a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c +
 (n + 2) \int \frac{\sin^{2} (ax)}{\cos^{- n} (ax)} \, \mbox{d}x \\
& = & \frac{1}{a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c +
 (n + 2) \int \frac{1 - \cos^{2} (ax)}{\cos^{- n} (ax)} \, \mbox{d}x \\
& = & \frac{1}{a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c +
 (n + 2) \int \left ( \frac{1}{\cos^{- n} (ax)} - \frac{\cos^{2} (ax)}{\cos^{- n} (ax)} \right ) \, \mbox{d}x \\
& = & \frac{1}{a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c +
 (n + 2) \int \left ( \frac{1}{\cos^{- n} (ax)} - \frac{1}{\cos^{- n - 2} (ax)} \right ) \, \mbox{d}x \\
& = & \frac{1}{a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c +
 (n + 2) \int \frac{1}{\cos^{- n} (ax)} \, \mbox{d}x - (n + 2) \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
& = & \frac{1}{a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c + (n + 2) F (x) - (n + 2) \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
(n + 1) F (x)
 & = & - \frac{1}{a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c + (n + 2) \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
F (x)
 & = & - \frac{1}{(n + 1) a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c + \frac{n + 2}{n + 1} \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & - \frac{1}{(n + 1) a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c + \frac{n + 2}{n + 1} \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
& = & - \frac{1}{(-3 + 1) a} \frac{\sin (ax)}{\cos^{- (-3) - 1} (ax)} + c + \frac{-3 + 2}{-3 + 1} \int \frac{1}{\cos^{- (-3) - 2} (ax)} \, \mbox{d}x \\
& = & \frac{1}{2 a} \frac{\sin (ax)}{\cos^{2} (ax)} + c + \frac{1}{2} \int \frac{1}{\cos (ax)} \, \mbox{d}x \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & \frac{1}{2 a} \frac{\sin (ax)}{\cos^{2} (ax)} + c + \frac{1}{2} \int \frac{1}{\cos (ax)} \, \mbox{d}x \\
& = & \frac{1}{2 a} \frac{\sin (ax)}{\cos^{2} (ax)} +
 \frac{1}{2} \left ( \frac{1}{a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | \right ) + c \\
& = & \frac{1}{2 a} \frac{\sin (ax)}{\cos^{2} (ax)} + \frac{1}{2 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & - \frac{1}{(n + 1) a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c + \frac{n + 2}{n + 1} \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
& = & - \frac{1}{(-5 + 1) a} \frac{\sin (ax)}{\cos^{- (-5) - 1} (ax)} + c + \frac{-5 + 2}{-5 + 1} \int \frac{1}{\cos^{- (-5) - 2} (ax)} \, \mbox{d}x \\
& = & \frac{1}{4 a} \frac{\sin (ax)}{\cos^{4} (ax)} + c + \frac{3}{4} \int \frac{1}{\cos^{3} (ax)} \, \mbox{d}x \\
& = & \frac{1}{4 a} \frac{\sin (ax)}{\cos^{4} (ax)} +
 \frac{3}{4} \left ( \frac{1}{2 a} \frac{\sin (ax)}{\cos^{2} (ax)} + \frac{1}{2 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | \right ) + c \\
& = & \frac{3}{8 a} \frac{\sin (ax)}{\cos^{2} (ax)} + \frac{1}{4 a} \frac{\sin (ax)}{\cos^{4} (ax)} +
 \frac{3}{8 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & - \frac{1}{(n + 1) a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c + \frac{n + 2}{n + 1} \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
& = & - \frac{1}{(-7 + 1) a} \frac{\sin (ax)}{\cos^{- (-7) - 1} (ax)} + c + \frac{-7 + 2}{-7 + 1} \int \frac{1}{\cos^{- (-7) - 2} (ax)} \, \mbox{d}x \\
& = & \frac{1}{6 a} \frac{\sin (ax)}{\cos^{6} (ax)} + c + \frac{5}{6} \int \frac{1}{\cos^{5} (ax)} \, \mbox{d}x \\
& = & \frac{1}{6 a} \frac{\sin (ax)}{\cos^{6} (ax)} + \frac{5}{6} \left ( \frac{3}{8 a} \frac{\sin (ax)}{\cos^{2} (ax)} +
 \frac{1}{4 a} \frac{\sin (ax)}{\cos^{4} (ax)} + \frac{3}{8 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | \right ) + c \\
& = & \frac{5}{16 a} \frac{\sin (ax)}{\cos^{2} (ax)} + \frac{5}{24 a} \frac{\sin (ax)}{\cos^{4} (ax)} +
 \frac{1}{6 a} \frac{\sin (ax)}{\cos^{6} (ax)} + \frac{5}{16 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & - \frac{1}{(n + 1) a} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} + c + \frac{n + 2}{n + 1} \int \frac{1}{\cos^{- n - 2} (ax)} \, \mbox{d}x \\
& = & - \frac{1}{(-9 + 1) a} \frac{\sin (ax)}{\cos^{- (-9) - 1} (ax)} + c + \frac{-9 + 2}{-9 + 1} \int \frac{1}{\cos^{- (-9) - 2} (ax)} \, \mbox{d}x \\
& = & \frac{1}{8 a} \frac{\sin (ax)}{\cos^{8} (ax)} + c + \frac{7}{8} \int \frac{1}{\cos^{7} (ax)} \, \mbox{d}x \\
& = & \frac{1}{8 a} \frac{\sin (ax)}{\cos^{8} (ax)} + \frac{7}{8} \left ( \frac{5}{16 a} \frac{\sin (ax)}{\cos^{2} (ax)} +
 \frac{5}{24 a} \frac{\sin (ax)}{\cos^{4} (ax)} + \frac{1}{6 a} \frac{\sin (ax)}{\cos^{6} (ax)} +
 \frac{5}{16 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | \right ) + c \\
& = & \frac{35}{128 a} \frac{\sin (ax)}{\cos^{2} (ax)} + \frac{35}{192 a} \frac{\sin (ax)}{\cos^{4} (ax)} +
 \frac{7}{48 a} \frac{\sin (ax)}{\cos^{6} (ax)} + \frac{1}{8 a} \frac{\sin (ax)}{\cos^{8} (ax)} +
 \frac{35}{128 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & \frac{35}{128 a} \frac{\sin (ax)}{\cos^{2} (ax)} + \frac{35}{192 a} \frac{\sin (ax)}{\cos^{4} (ax)} +
 \frac{7}{48 a} \frac{\sin (ax)}{\cos^{6} (ax)} + \frac{1}{8 a} \frac{\sin (ax)}{\cos^{8} (ax)} +
 \frac{35}{128 a} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
& = & \frac{1}{a} \frac{n + 2}{n + 1} \frac{n + 4}{n + 3} \frac{n + 6}{n + 5} \frac{1}{n + 7} \frac{\sin (ax)}{\cos^{- n - 7} (ax)} \\
 & & \qquad + \, \frac{1}{a} \frac{n + 2}{n + 1} \frac{n + 4}{n + 3} \frac{1}{n + 5} \frac{\sin (ax)}{\cos^{- n - 5} (ax)} \\
 & & \qquad \qquad + \, \frac{1}{a} \frac{n + 2}{n + 1} \frac{1}{n + 3} \frac{\sin (ax)}{\cos^{- n - 3} (ax)} \\
 & & \qquad \qquad \qquad + \, \frac{1}{a} \frac{1}{n + 1} \frac{\sin (ax)}{\cos^{- n - 1} (ax)} \\
 & & \qquad \qquad \qquad \qquad + \, \frac{1}{a} \frac{n + 2}{n + 1} \frac{n + 4}{n + 3} \frac{n + 6}{n + 5} \frac{1}{n + 7}
 \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
& = & \frac{1}{a} \sin (ax) \Biggl ( \frac{(n + 2) (n + 4) (n + 6)}{(n + 1) (n + 3) (n + 5) (n + 7)} \cos^{n + 7} (ax) +
 \frac{(n + 2) (n + 4)}{(n + 1) (n + 3) (n + 5)} \cos^{n + 5} (ax) \\
 & & \qquad \qquad \qquad + \, \frac{n + 2}{(n + 1) (n + 3)} \cos^{n + 3} (ax) + \frac{1}{n + 1} \cos^{n + 1} (ax) \Biggr ) \\
 & & \qquad \qquad \qquad \qquad + \,
 \frac{1}{a} \frac{(n + 2) (n + 4) (n + 6)}{(n + 1) (n + 3) (n + 5) (n + 7)} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
& = & \frac{1}{a} \sin (ax) \Biggl ( \frac{\frac{(- n - 2)!!}{(- n - 8)!!}}{\frac{(- n - 1)!!}{(- n - 9)!!}} \cos^{n + 7} (ax) +
 \frac{\frac{(- n - 2)!!}{(- n - 6)!!}}{\frac{(- n - 1)!!}{(- n - 7)!!}} \cos^{n + 5} (ax) \\
 & & \qquad + \, \frac{\frac{(- n - 2)!!}{(- n - 4)!!}}{\frac{(- n - 1)!!}{(- n - 5)!!}} \cos^{n + 3} (ax) +
 \frac{\frac{(- n - 2)!!}{(- n - 2)!!}}{\frac{(- n - 1)!!}{(- n - 3)!!}} \cos^{n + 1} (ax) \Biggr ) +
 \frac{1}{a} \frac{(- n - 2)!!}{(- n - 1)!!} \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | + c \\
& = & \frac{1}{a} \frac{(- n - 2)!!}{(- n - 1)!!} \Biggl ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | +
 \sin (ax) \Biggl ( \frac{(- n - 9)!!}{(- n - 8)!!} \cos^{n + 7} (ax) + \frac{(- n - 7)!!}{(- n - 6)!!} \cos^{n + 5} (ax) \\
 & & \qquad + \, \frac{(- n - 5)!!}{(- n - 4)!!} \cos^{n + 3} (ax) + \frac{(- n - 3)!!}{(- n - 2)!!} \cos^{n + 1} (ax) \Biggr ) \Biggr ) + c \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
n \mbox{ is oneven: } \qquad n!!
 & = & 1 \cdot 3 \cdot 5 \cdot \ldots \cdot n \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
n \mbox{ is even: } \qquad n!!
 & = & 2 \cdot 4 \cdot 6 \cdot \ldots \cdot n \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & \frac{1}{a} \frac{(- n - 2)!!}{(- n - 1)!!} \Biggl ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | +
 \sin (ax) \Biggl ( \frac{(- n - 9)!!}{(- n - 8)!!} \cos^{n + 7} (ax) + \frac{(- n - 7)!!}{(- n - 6)!!} \cos^{n + 5} (ax) \\
 & & \qquad + \, \frac{(- n - 5)!!}{(- n - 4)!!} \cos^{n + 3} (ax) + \frac{(- n - 3)!!}{(- n - 2)!!} \cos^{n + 1} (ax) \Biggr ) \Biggr ) + c \\
& = & \frac{1}{a} \frac{(- n - 2)!!}{(- n - 1)!!} \left ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | +
 \sin (ax) \sum_{i = 0}^{i = - \frac{1}{2} (n + 1) - 1} \frac{(2i)!!}{(2i + 1)!!} \cos^{- 2i - 2} (ax) \right ) + c \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & \frac{1}{a} \frac{(- n - 2)!!}{(- n - 1)!!} \left ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | +
 \sin (ax) \sum_{i = 0}^{i = - \frac{1}{2} (n + 1) - 1} \frac{(2i)!!}{(2i + 1)!!} \cos^{- 2i - 2} (ax) \right ) + c \\
& = & \frac{1}{a}
 \frac{\frac{(- n - 1)!}{2^{\frac{1}{2} (- n - 1)} \left ( \frac{1}{2} (- n - 1) \right ) !}}
{2^{\frac{1}{2} (- n - 1)} \left ( \frac{1}{2} (- n - 1) \right ) !}
 \left ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | +
 \sin (ax) \sum_{i = 0}^{i = - \frac{1}{2} (n + 1) - 1} \frac{2^{i} i!}{\frac{(2i + 1)!}{2^{i} i!}} \cos^{- 2i - 2} (ax) \right ) + c \\
& = & \frac{1}{a}
 \frac{(- n - 1)!}{2^{- n - 1} \left ( \left ( \frac{1}{2} (- n - 1) \right ) ! \right )^{2}}
 \left ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | +
 \sin (ax) \sum_{i = 0}^{i = - \frac{1}{2} (n + 1) - 1} \frac{2^{2i} (i!)^{2}}{(2i + 1)!} \cos^{- 2i - 2} (ax) \right ) + c \\
& = & \frac{1}{a}
 \frac{2^{n + 1} (- (n + 1))!}{\left ( \left ( - \frac{1}{2} (n + 1) \right ) ! \right )^{2}}
 \left ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | +
 \sin (ax) \sum_{i = 0}^{i = - \frac{1}{2} (n + 1) - 1} \frac{2^{2i} (i!)^{2}}{(2i + 1)!} \cos^{- 2i - 2} (ax) \right ) + c \\
\end{eqnarray*}
\newpage
\begin{eqnarray*}
F (x)
 & = & \frac{1}{a}
 \frac{2^{n + 1} (- (n + 1))!}{\left ( \left ( - \frac{1}{2} (n + 1) \right ) ! \right )^{2}}
 \Biggl ( \ln \left | \, \frac{1 + \sin (ax)}{\cos (ax)} \, \right | \\
 & & \qquad + \, \sin (ax) \sum_{i = 0}^{i = - \frac{1}{2} (n + 1) - 1} \frac{2^{2i} (i!)^{2}}{(2i + 1)!} \cos^{- 2i - 2} (ax) \Biggr ) + c \\
\end{eqnarray*}
\end{document}
