# Integral $\int \tan^{5}(x)\text{ d}x$

I would like guidance on evaluating $$\displaystyle\int \tan^{5}(x)\text{ d}x\text{.}$$ I have attempted using the Pythagorean identities to get $$\int\tan^{5}(x)\text{ d}x = \int \tan(x)\left[\sec^{2}(x)-1\right]^{2}\text{ d}x\text{.}$$ This doesn't look helpful. So I thought, why not turn only ONE of the $\tan^{2}$ terms to the $\sec^{2}-1$ form? This gives $$\int\tan^{5}(x)\text{ d}x = \int\tan^{3}(x)\sec^{2}(x)\text{ d}x-\int \tan^{3}(x)\text{ d}x\text{.}$$ Clearly the second term is $\dfrac{\tan^{4}(x)}{4}$ (ignoring the constant term for now). Using a similar trick, \begin{align} \int\tan^{3}(x)\text{ d}x &= \int \tan(x)\sec^{2}(x)\text{ d}x-\int\tan(x)\text{ d}x \\ &= \dfrac{\tan^{2}(x)}{2} - (-1)\ln|\cos(x)| \\ &= \dfrac{\tan^{2}(x)}{2}+\ln|\cos(x)|\text{.} \end{align} So this suggests to me that $$\int\tan^{5}(x)\text{ d}x = \dfrac{\tan^{4}(x)}{4} - \dfrac{\tan^{2}(x)}{2}-\ln|\cos(x)| + C\text{.}$$ But the answer in Stewart (section 7.2., #31) is $$\dfrac{1}{4}\sec^{4}(x)-\tan^{2}(x)+\ln|\sec(x)|+C\text{.}$$ It's very clear where the $\ln|\sec(x)|$ term is coming from - and I tried to take the difference of my answer and Stewart's answer using Wolfram Alpha and unfortunately, the difference is not a constant.

Where did I go wrong?

• The difference is a constant. $(\tan^4(x)/4 - \tan^2(x)/2) - (\sec^4(x)/4 - \tan^2(x))=-1/4$ (wolframalpha.com/input/…), and like you said, it's clear that $\log|\sec(x)|=-\log|\cos(x)|$. – mjqxxxx Oct 18 '14 at 4:11
• You left the absolute value signs out when you entered the expression into Wolfram Alpha. – mjqxxxx Oct 18 '14 at 4:12
• @mjqxxxx - Thank you! – Clarinetist Oct 18 '14 at 4:13

Your answer is correct. We have $tan^2x=sec^2x-1$ so $tan^4x=sec^4x-2sec^2x+1$ Replacing your $tan^4x$ accordingly gives $0.25sec^4x-0.5sec^2x+0.25$ Replacing that $0.25sec^2x$ with $tan^2x+1$ results into Stewart's solution. The answers do differ by some constant though
Here's the derivation of a formula that could be of some help to you. Let $$n>1$$ be an integer.
Consider the integral $$I_n=\int\tan^nx\ dx$$ $$I_n=\int\tan^{n-2}x\tan^2x\ dx$$ $$I_n=\int\tan^{n-2}x(\sec^2x-1)dx$$ $$I_n=\int\tan^{n-2}x\sec^2x\ dx-\int\tan^{n-2}x\ dx$$ $$I_n=\int\tan^{n-2}x\sec^2x\ dx-I_{n-2}$$ Substitution: $$u=\tan x\Rightarrow du=\sec^2x\ dx$$ $$\Rightarrow I_n=\int u^{n-2}du-I_{n-2}$$ $$I_n=\frac{u^{n-1}}{n-1}-I_{n-2}$$ $$I_n=\frac{\tan^{n-1}x}{n-1}-I_{n-2}$$ $$\int\tan^nx\ dx=\frac{\tan^{n-1}x}{n-1}-\int\tan^{n-2}x\ dx$$