# Expressing $\int \tan^n x\,dx$ with a sum

I was playing around with integrals of $\tan x$, because I knew that both $\int\tan x\,dx$ and $\int\tan^2x\,dx$ were solvable. I then came across the fact that

\begin{align} \int \tan^n x\,dx &= \int \tan^{n-2}x\,(\sec^2 x - 1)\,dx \\ &= \int \tan^{n-2}x\,\sec^2 x\,dx - \int \tan^{n-2}x\,dx \\ &= \int u^{n-2}\,\,du - \int \tan^{n-2}x\,dx \\ &= \frac{1}{n-1}u^{n-1} - \int \tan^{n-2}x\,dx \\ &= \frac{1}{n-1}\tan^{n-1} x - \int \tan^{n-2}x\,dx \end{align}

which by a simple subtraction also meant that

$$\int \tan^n x\,dx = \frac{1}{n-1}\tan^{n-1} x - \int \tan^{n+2}x\,dx$$

so any integer power of $\tan$ could be easily integrated, including the negatives: just decompose down (or up, if $n<0$ ) until $n$ is either 0 or 1, which gave final integrals of $x + C$ and $-\ln |\cos x| + C$.

I also noted that this looked like an interesting idea for an induction problem that could be posed, the kind with a summation notation that would have to be broken up. The simplest way that I see would be the use of two sums, depending on whether $n$ was odd or even. I started with

$$\int \tan^{2k} x\,dx = (-1)^n x + \sum_{i=2}^k {\dfrac{(-1)^?}{2i-1} \tan^{2i-1}x} + C$$

but I couldn't figure out what to put for the $?$ part, and I didn't even bother tackling the $2k+1$ version.

Is there a way to salvage this? Could there be a way to express both cases with only one sum?

-

If you use the substitution $x = \arctan u$ you have: $$\int \tan^{2k} dx = \int \frac{u^{2k}}{u^2+1}\,du.$$ Now: $$\frac{u^{2k}}{u^2+1}=\frac{(-1)^k}{u^2+1}+\frac{u^{2k}-(-1)^k}{u^2+1}=\frac{(-1)^k}{u^2+1}-\sum_{j=1}^{k}(-1)^j\; u^{2k-2j},$$ so: $$\int \tan^{2k} dx = (-1)^k x -\sum_{j=1}^{k}\frac{(-1)^j}{2k-2j+1}(\tan x)^{2k-2j+1},$$ or:
$$\int \tan^{2k} dx = (-1)^k x -\sum_{j=0}^{k-1}\frac{(-1)^{k+j}}{2j+1}(\tan x)^{2j+1}.$$
And what about the $2k+1$ case? Is it similar? I'm not sure how you turned that $(u^{2k}-(-1)^k)/(u^2+1)$ into an explicit sum. –  algorithmshark Oct 25 '12 at 0:23
Just consider $-(u^2+1)\sum_{j=1}^{k}(-1)^j\,u^{2k-2j}$: it is a telescoping sum, equal to $u^{2k}-(-1)^k$. For the odd case, we have: $\frac{u^{2k+1}}{u^2+1} = \frac{(-1)^k \, u}{u^2+1} + u\,\frac{u^{2k}-(-1)^k}{u^2+1}=\frac{(-1)^k u}{u^2+1}-\sum_{j=1}^{k}(-1)^j\; u^{2k-2j+1},$ and now we can integrate termwise. –  Jack D'Aurizio Oct 25 '12 at 9:34