Ways to evaluate $\int \sec \theta \, \mathrm d \theta$

Another way is:

$$\int \sec x \,dx = \int \frac{\cos x}{\cos^2 x} \,dx = \int \frac{\cos x}{1-\sin^2 x} \,dx = \frac{1}{2} \int \left( \frac{1}{1-\sin x} + \frac{1}{1+\sin x} \right) \cos x dx $$ $$= \frac{1}{2} \log \left| \frac{1+\sin x}{1-\sin x} \right| + C.$$

It's worth noting that the answer can appear in many disguises. Another is $$\log \left| \tan \left( \frac{\pi}{4} + \frac{x}{2} \right) \right| $$


A useful technique is to use the half angle formulas in terms of $\tan (\theta/2)$ in order to convert trigonometric (rational) functions into rational functions.

For example if $t = \tan(\theta/2)$ we have that $\sec \theta = \frac{1+t^2}{1-t^2}$

We have $2\,\mathrm dt = (1 + \tan^2(\theta/2))\,\mathrm d\theta$

And so

$$\int \sec \theta \,\mathrm d\theta = \int \frac{2\;\mathrm dt}{1-t^2}$$

Which can easily be evaluated.

Similarly we get

$$\int \csc \theta \,\mathrm d\theta = \int \frac{\mathrm dt}{t}$$

using $\csc \theta = \frac{1+t^2}{2t}$

Check this page out.


Using the definitions $$\sec \theta = 1/\cos \theta \quad \text{and} \quad \cos \theta = (\exp(i \theta) + \exp(-i \theta))/2$$ gives $$\int \sec \theta \, d \theta = \int \frac{2 \, d \theta}{\exp(i \theta) + \exp(-i \theta)}.$$ The only insight needed is to find the substitution $u = \exp( i \theta )$ (what else is there to try?), leading to a multiple of $\int \frac{du}{1+u^2}$, the inverse tangent. Thus, in an essentially mechanical fashion you obtain the generic solution $$-2 i \arctan(\exp(i \theta)).$$ Unwinding this via the usual algebraic identities between exponential and trig functions not only shows it is equal to the usual solutions, but also reveals why half angles might be involved and where an offset of $\pi /4$ might come from (as in @Derek Jennings' answer): it's a constant of integration, of course.