# How to integrate $\tan(x)^n$?

First, did use wolfram alpha and it does give me the answer in terms of a hypergeometric sequence.

I am a grade 12 student, and I am trying to investigate into this integral for my assessment. Could someone please explain how I can go from the LHS to the RHS:

$$\int \tan^n(x)\, dx = \frac {\tan^{n + 1}(x)\; _2F_1(1, \frac {n + 1}2, \frac {n + 3}2, -\tan^2(x))}{n + 1}\, + \,\text {constant}$$

Where, as usual, $$_2F_1$$ denotes the HyperGeometric Function

• The image is unreadable – Don Thousand Jan 10 '19 at 14:34
• I'm not sure in the image if they are meant to be $()$ brackets or if there is a reason for the different shape – Henry Lee Jan 10 '19 at 14:36
• Note: I added what I believe to be the correct integral to your post, the link you included could not be read. Please advise if what I wrote was not what you intended. I left your link in place though, if what I wrote is what you wanted, then you might want to delete the broken link. – lulu Jan 10 '19 at 14:40
• This seems like quite a high level integral compared to what you will have learnt. If you can avoid it that would probably be better – Henry Lee Jan 10 '19 at 14:41
• Worth remarking; if $n\in \mathbb N$ then, generally, one just uses a simple reduction to integrate this. – lulu Jan 10 '19 at 14:44

Let's consider the case when $$n=2k+1$$ is odd: we can write $$\int\tan^nx\,dx=\int\tan^{2k+1}x\,dx= \int\frac{(\sin^2x)^k}{\cos^{2k+1}x}\sin x\,dx= -\int\frac{(1-\cos^2x)^k}{\cos^{2k+1}x}\,d(\cos x)$$ which is elementary. Example with $$k=2$$: we reduce to \begin{align} -\int\frac{(1-\cos^2x)^2}{\cos^5x}\,d(\cos x) &=-\int\left(\frac{1}{\cos^5x}-\frac{2}{\cos^3x}+\frac{1}{\cos x}\right)\,d(\cos x)\\ &=\frac{1}{4\cos^4x}-\frac{1}{\cos^2x}-\log\lvert\cos x\rvert+c \end{align}

For $$n=2k$$ even, it's a bit different: $$\int\tan^nx\,dx=\int\frac{\sin^{2k}x}{\cos^{2k}x}\,dx= \int\frac{(1-\cos^2x)^k}{\cos^{2k}x}\,dx$$ and the problem is reduced to computing $$\int\frac{1}{\cos^{2m}x}\,dx$$ which can be dealt with the substitution $$t=\tan x$$. Example with $$m=2$$; since $$\cos^2x=\frac{1}{1+\tan^2x}$$ we have $$\int\frac{1}{\cos^4x}=\Bigl[t=\tan x,dt=\frac{1}{\cos^2x}\,dx\Bigr]= \int(1+t^2)\,dt=t+\frac{t^3}{3}+c=\tan x+\frac{1}{3}\tan^3x\,dx$$ In general, for $$m\ge1$$, with the same substitution, $$\int\frac{1}{\cos^{2m}x}=\int(1+t^2)^{m-1}\,dt$$

• Could you show how to integrate 1/(cos(x))^(2m)? And is it possible to further breakdown the first case where you split tan(x)^n in terms of odd powers of sin and cos? sorry if it an obvious question, I just find it slightly hard to understand this. – Redlion11 Jan 10 '19 at 15:55
• @Redlion11 I added a couple of examples – egreg Jan 10 '19 at 16:08
• Thank you, I get it now. – Redlion11 Jan 10 '19 at 16:13

Notice that $$(\tan x)'=\tan^2x+1$$ so that

$$\tan^n x=\tan^{n-2} x\,(\tan x)'-\tan^{n-2}x.$$

This gives you a recurrence relation that ends with the integrand $$\tan x$$ or $$1$$ depending on the parity of $$n$$.

$$I_n=\frac{\tan^{n-1}x}{n-1}-I_{n-2}.$$

This leads to better expressions than those given by Alpha, even with a numerical exponent.

E.g.

https://www.wolframalpha.com/input/?i=integrate+tan%5E8x

versus

$$\frac{\tan^7 x}7-\frac{\tan^5 x}5+\frac{\tan^3 x}3-\tan x+x.$$

• Thanks for the response, but could you elaborate a bit more on how you arrived at \tan^n x=\tan^{n-2} x\,(\tan x)'-\tan^{n-2}x – Redlion11 Jan 10 '19 at 16:18
• @Redlion11: no, this is immediate. Expand. – Yves Daoust Jan 10 '19 at 17:23

Depending on the limits, the Beta function can be used: $$B(m+1,n+1)=2\int_0^{\pi/2}\cos^{2m+1}(x)\sin^{2n+1}(x)dx=\frac{m!n!}{(m+n+1)!}$$ For outside of this range you can use that: $$B(z;a,b)=\int_0^zx^{a-1}(1-x)^{b-1}dx=z^a\sum_{n=0}^\infty\frac{(1-b)_n}{n!(a+n)}z^n$$ All this can be found here: http://mathworld.wolfram.com/BetaFunction.html

http://mathworld.wolfram.com/IncompleteBetaFunction.html