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?
Short answer: the answers are equivalent, you have nothing to worry about. :)
Long answer: \begin{align} \frac{\tan^4 x}{4} - \frac{\tan^2 x}{2} &= \frac{\tan^4 x + 2\tan^2 x}{4} - \tan^2 x\\ &= \frac{\sec^4 x- 1}{4} - \tan^2 x\\ &= \frac{\sec^4x}{4} - \tan^2 x + C \end{align}