What is wrong with this approach evaluating $\int \sec \theta \ d \theta$?

When integrating a function like $\sin^m \theta \cdot \cos^n \theta$ where where $m,n$ are nonnegative integers and $n$ is odd, a common approach is to peel off one power of $\cos \theta$ and then rewrite the resulting even power of $\cos \theta$ in terms of $\sin \theta$ using $\cos^2 \theta = 1 - \sin^2 \theta$. What remains is a polynomial in $\sin \theta$, multiplied by $\cos \theta$, so the substitution $u = \sin \theta$ can be used. Since $\sec \theta =(\sin \theta)^0 (\cos \theta)^{-1}$ and $-1$ is odd, it seems like a good idea to try out the same approach here.

\begin{align*} \int \sec \theta \ d \theta &= \int \frac{\cos \theta}{\cos^2 \theta} \ d \theta && \text{Splitting off a power of $\cos \theta$}\\ &=\int \frac{ \cos \theta}{1-\sin^2 \theta} \ d \theta && \text{Eliminating the even power of $\cos \theta$} \\ &=\int \frac{1}{1-u^2}\ du && \text{Substituting $u=\sin \theta$}\\ &=\frac{1}{2} \int \left( \frac{1}{1+u} + \frac{1}{1-u} \right) \ du&& \text{Partial fractions}\\ &=\frac{1}{2} \left( \log |1+u| + \log |1-u| \right) && \\ &=\frac{1}{2} \log |1-u^2| && \\ &=\frac{1}{2} \log| \cos^2 \theta| && \text{Restoring $u=\sin \theta$} \\ &=\frac{1}{2} \log (\cos^2 \theta) && \text{Eliminating redundant absolute signs}\\ &= \log \sqrt{ \cos^2 \theta}&& \\ &= \log|\cos \theta|. \\ \end{align*}

I didn't bother adding the customary constant because the domain of $\sec \theta$ is disconnected and so you would actually need to add a piecewise constant function in order to specify the general antiderivative.

My questions are:

Question 1: Since $\frac{d}{d \theta} \log|\cos \theta| = - \tan \theta$, where does this calculation go wrong?

And also:

Question 2: Can this approach be salvaged?

• $\log |1+u| + \log |1-u|$ should be $\log |1+u| - \log |1-u|$. I think you will find that this gives you the right answer. – David Feb 19 '15 at 1:21
• @David Make that an answer? – Cameron Williams Feb 19 '15 at 1:22
• @David: Whoops, that's right! I kept redoing the calculation and repeating my error. Was starting to think something sinister was going on... I will check whether things are now fixed. – Mike F Feb 19 '15 at 1:26
• @CameronWilliams thanks for the suggestion, done. – David Feb 19 '15 at 1:27

In your fifth line, $$\log |1+u| + \log |1-u|$$ should be $$\log |1+u| - \log |1-u|\ .$$ This then gives \eqalign{ \frac12\log\Bigl|\frac{1+u}{1-u}\Bigr| &=\frac12\log\Bigl(\frac{1+\sin\theta}{1-\sin\theta}\Bigr)\cr &=\frac12\log\Bigl(\frac{1+\sin\theta}{1-\sin\theta} \frac{1+\sin\theta}{1+\sin\theta}\Bigr)\cr &=\log\frac{1+\sin\theta}{\cos\theta}\cr &=\log(\sec\theta+\tan\theta)\ .\cr}
• Right. And the absolute value signs are, once again, redundant since $1+ \sin \theta$ and $1-\sin \theta$ are clearly nonnegative. – Mike F Feb 19 '15 at 1:28