<s>[INST] Help with a general solution for $\int \tan^a \theta$ Working out the integrals of $\tan^6 \theta$ I saw a pattern.  I would like to put it in series representation. The pattern is as follows:
$$\int \tan^a d\theta= \int\tan^{a-2}\theta(\sec^2\theta-1)\ d\theta= $$ $$ \int \tan ^{a-2}\theta\sec^2\theta\ d\theta-\int\tan^{a-2}\theta\ d\theta=$$ solving the first integral, let $u=\tan \theta, du=\sec^2\theta\ d\theta$ so $$ \int u^{a-2} du=\frac{1}{a-2+1}u^{a-2+1}=$$ $$\frac{1}{a-1}u^{a-1}= $$$$\frac{1}{a-1}\tan^{a-1}\theta-\int \tan^{a-2}\theta\ d\theta $$ 
then $$ \int u^{(a-2)-2} du=\frac{1}{(a-2)-1}u^{(a-2)-1}=$$ $$\frac{1}{a-3}u^{a-3}= $$$$\frac{1}{a-3}\tan^{a-3}\theta-\int \tan^{a-4}\theta\ d\theta $$ It goes on like this forever
$$\frac{1}{a-1}\tan^{a-1}\theta-\frac{1}{a-3}\tan^{a-3}\theta-\frac{1}{a-5}\tan^{a-5}\theta \text {....} \theta\ d\theta $$ So then my series should be....$$\frac{1}{a-1}\tan^{a-1}\theta-\big[\sum_{n=3}^{a-2} {\frac{1}{a-n}\tan^{a-n}\theta}\big] -\int \tan^{2}\theta\ d\theta\space \text{if a is even. OR}$$
$$\frac{1}{a-1}\tan^{a-1}\theta-\big[\sum_{n=3}^{a-2} {\frac{1}{a-n}\tan^{a-n}\theta}\big] -\int \tan\ d\theta\space \text{if a is odd}.$$
I am having problems tweaking this series so it only includes the odd values of "n"?
$addendum$
For those not reading the entire thread as discussed below. the value of n is $n=2k-1$. 
The lower limit should be $k=1$ and the upper limit should be $\frac {a}{2}-1$ for even "a"'s and $\frac {a-1}{2}$ for odd. Thanks again to SemSem.
 [/INST] Simply you have
$$I_a=\int \tan^a d\theta= \int\tan^{a-2}(\sec^2-1)d\theta
\\=\frac{1}{a-1}\tan^{a-1}\theta-\int \tan^{a-2} d\theta
\\ I_a=\frac{1}{a-1}\tan^{a-1}\theta-I_{a-2}$$from this last one you can start by applying it many times to get your required formula. If $n$ is even we get
$$I_a=\frac{1}{a-1}\tan^{a-1}\theta-\frac{1}{a-3}\tan^{a-3}\theta+ \frac{1}{a-5}\tan^{a-5}\theta ....I_{2}
\\=\sum_{k\ =\ 1}^{\frac{a}{2}-1}(-1)^{k+1}\frac{1}{a-(2k-1)}\tan^{a-(2k-1)}\theta+(-1)^{\frac{a}{2}}I_2$$ 
If $n$ is odd we get
$$I_a=\frac{1}{a-1}\tan^{a-1}\theta-\frac{1}{a-3}\tan^{a-3}\theta+ \frac{1}{a-5}\tan^{a-5}\theta ....I_{1}
\\=\sum_{k\ =\ 1}^{\frac{a-1}{2}}(-1)^{k+1}\frac{1}{a-(2k-1)}\tan^{a-(2k-1)}\theta+(-1)^{\frac{a+1}{2}}I_2$$ 
</s>