109

The standard approach for showing $\int \sec \theta \, \mathrm d \theta = \ln|\sec \theta + \tan \theta| + C$ is to multiply by $\dfrac{\sec \theta + \tan \theta}{\sec \theta + \tan \theta}$ and then do a substitution with $u = \sec \theta + \tan \theta$.

I like the fact that this trick leads to a fast and clean derivation, but I also find it unsatisfying: It's not very intuitive, nor does it seem to have applicability to any integration problem other than $\int \csc \theta \,\mathrm d \theta$. Does anyone know of another way to evaluate $\int \sec \theta \, \mathrm d \theta$?

Mike Spivey
  • 55,550
  • Perhaps using series, but that wouldn't be more elegant. – Weltschmerz Oct 13 '10 at 14:04
  • 14
    One can always use the half-angle substitution: $t=\tan(\theta/2)$. – Robin Chapman Oct 13 '10 at 14:13
  • 3
    If you make the substitution $u=\sec(\theta)$, the integrand becomes the derivative of the inverse hyperbolic cosine. – Jonas Meyer Oct 13 '10 at 21:54
  • 3
    While I like (and upvoted) the general approaches, I've decided to accept Derek Jennings' answer because it is the most useful to me: I plan to use it in class this coming week when we discuss integration by partial fractions decomposition! Thanks to everyone for their answers and comments; they greatly exceeded what I was expecting. Go Math Stack Exchange. – Mike Spivey Oct 14 '10 at 04:25
  • 3
    This came up a couple of years ago in an ap-calculus listserv, and I wound up writing an essay about the Gudermannian function that you might find of interest. I reposted the essay in sci.math at http://groups.google.com/group/sci.math/msg/dfb992fe3d16fc49. – Dave L. Renfro Jul 15 '11 at 21:18
  • 1
    No matter what anybody says, Wikipedia falls short of being infallible. But there is this:

    http://en.wikipedia.org/wiki/Integral_of_the_secant_function

    – Michael Hardy Jul 17 '11 at 01:37
  • 1
    Since the time when this question was posted, I've discovered a way to make the $(\sec+\tan)/(\sec+\tan)$ method intuitive. It will be published in the Monthly in June. – Michael Hardy Apr 09 '13 at 14:54
  • Funny fact: "In 1599, Edward Wright evaluated the integral by numerical methods – what today we would call Riemann sums. He wanted the solution for the purposes of cartography – specifically for constructing an accurate Mercator projection.[1] In the 1640s, Henry Bond, a teacher of navigation, surveying, and other mathematical topics, compared Wright's numerically computed table of values of the integral of the secant with a table of logarithms of the tangent function, and consequently conjectured [the $\log\tan$ formula]." (Wikipedia) – Martín-Blas Pérez Pinilla Mar 24 '19 at 16:35
  • https://math.stackexchange.com/questions/4221576/why-and-how-do-certain-manipulations-in-indefinite-integrations-just-work – HarshDarji Aug 22 '21 at 17:32

15 Answers15

105

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| $$

KingLogic
  • 1,441
  • 1
    Also nice. Plus it has the advantage of using only partial fractions and trig identities my students already know. (Unfortunately, I doubt any of them will remember the tangent half-angle identities - assuming that they have even seen them before.) – Mike Spivey Oct 13 '10 at 15:05
  • This is the method I use whenever I teach this material. Unfortunately, usually we do not cover the Weierstrass substitution. – Andrés E. Caicedo Oct 14 '10 at 02:05
  • 11
    I always like to present this solution to my students. Also I point to them than $\int \sec(\theta) d\theta$ falls into the cathegory $\cos(\theta)$ to an odd power, so the theory sais that we need to make the substitution $u = \sin(\theta)$.. Once I point that $d u$ needs to be at the top, the solution becomes obvious.... – N. S. Jul 15 '11 at 17:56
  • I think this method my be the historically oldest one, due to Isaac Barrow in the 1600s, and the first time partial fractions were used in antidifferentiation. – Michael Hardy Jul 11 '12 at 19:54
  • Multiplying numerator and denominator by $1+\sin(x)$ we get that the answer can also appear as $\log(\tan(x)+\sec(x))+C$. – robjohn Aug 10 '17 at 19:16
43

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.

Aryabhata
  • 82,206
  • 4
    The half angle formulas give an algorithm that can be used, in principle, to integrate any rational trigonometric function: make the substitution, then use partial fractions. (I say "in principle" because in practice one needs to numerically factor polynomials to do this.) – Qiaochu Yuan Oct 13 '10 at 14:26
  • 6
    I usually call this the "Weierstrass Magic $t$-Substitution" Method because (i) it originated with Weierstrass; and (ii) it works almost like magic. Same substitution will always do the trick. – Arturo Magidin Oct 13 '10 at 16:14
  • 6
    @Arturo, doesn't this, in essence, come down to the down-to-earth fact that one has a rational parametrization of the unit circle? – Mariano Suárez-Álvarez Oct 16 '10 at 00:16
  • 1
    @Mariano: Essentially, yes (that was Weierstrass observation, if I remember the history correctly). It still seems like magic... or at least sleight-of-hand... – Arturo Magidin Oct 16 '10 at 02:56
  • @Mariano: I'm quite late to the party here, but would you care to elaborate? I'm not quite sure I understand what you mean by "rational parametrization of the unit circle" and how it's related to Weierstrass substitution. – Bruno Stonek Jun 27 '11 at 01:57
  • 1
    @Bruno: Think of what happens when you replace the $t$ in $(\cos,t\quad\sin,t)^T$ with $t=2\arctan,u$... you should end up with a parametrization of the circle in rational functions. – J. M. ain't a mathematician Jul 16 '11 at 12:52
38

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.

whuber
  • 8,531
  • 4
    Not only that, but the same technique (essentially); u and t = tan theta/2 are related by invertible fractional linear transformations. – Qiaochu Yuan Oct 13 '10 at 16:28
  • 9
    @Qiaochu: Agreed, they are related; that's a good observation. But as a matter of technique there is a substantial difference. The other responses require tricks or auxiliary knowledge, such as the general effectiveness of using tan(t/2) or choosing the right trig formula. From another comment I now realize that using complex variables will not be appropriate for Mike Spivey's audience, but the original purpose of pointing out this method was to address the intent of his message: how can we do this integral without invoking some mysterious insight or relationship? – whuber Oct 13 '10 at 17:53
  • 1
    I really had two reasons for wanting an answer to my question: 1) something I could use in my integral calculus class, and 2) for my own interest. Thanks for a good response with respect to reason 2. – Mike Spivey Oct 13 '10 at 19:38
22

Here is a way an electrician solves the problem. Since $\cos(x)=\sin(\frac{\pi}{2} + x)$ it is easier consider the integral $$ I=\int \csc x \, dx = \int \dfrac1{\sin x} \, \mathrm dx$$

Now: $$ \frac1{\sin x} \, \mathrm dx= \frac1{2\sin \frac{x}{2}\cos\frac{x}{2}} \, \mathrm dx=\frac1{2\tan\frac{x}{2}\cos^2\frac{x}{2}} \, \mathrm dx =\frac{\mathrm d\tan\frac{x}{2}}{\tan\frac{x}{2}}=\mathrm d \ln \left | \tan\frac{x}{2} \right | $$

Thus $$I=\ln \left | \tan\frac{x}{2}\right | +C$$

Substituting $x$ with $\frac{\pi}{2}+x$ gives for the original integral:

$$\ln \left| \tan \left( \frac{\pi}{4} + \frac{x}{2} \right) \right|+C $$

Martin Gales
  • 6,878
18

Instead of presenting another way of evaluating this integral, I justify a more general case in an approach which uses partial fractions and trigonometric identities, at the level of a Calculus class, I think:

$$\int \dfrac{1}{a+b\cos x}dx=\dfrac{1}{\sqrt{b^{2}-a^{2}}}\ln \left\vert \dfrac{\sqrt{a+b}+\sqrt{b-a}\tan x/2}{\sqrt{a+b}-\sqrt{b-a}\tan x/2}\right\vert \quad a\lt b.\quad (\ast)$$

Since

$$a+b\cos x=(a-b)+2b\cos ^{2}x/2,$$

we have

$$\dfrac{1}{a+b\cos x}=\dfrac{\sec ^{2}x/2}{(a-b)\sec ^{2}x/2+2b}=\dfrac{\sec ^{2}x/2}{(a-b)\sec ^{2}x/2+2b}=\dfrac{\sec ^{2}x/2}{a+b-(b-a)\tan ^{2}x/2}.$$

But

$$\dfrac{1}{a+b-(b-a)\tan ^{2}x/2}=$$

$$=\dfrac{1}{2\sqrt{a+b}}\left( \dfrac{1}{% \sqrt{a+b}-\sqrt{b-a}\tan x/2}+\dfrac{1}{\sqrt{a+b}+\sqrt{b-a}\tan x/2}% \right) .$$

Hence

$$\int \dfrac{1}{a+b\cos x}dx=$$

$$=\dfrac{1}{2\sqrt{a+b}}\int \left( \dfrac{\sec ^{2}x/2}{\sqrt{a+b}-\sqrt{b-a}\tan x/2}+\dfrac{\sec ^{2}x/2}{\sqrt{a+b}+% \sqrt{b-a}\tan x/2}\right) dx$$

$$=\dfrac{1}{\sqrt{b^{2}-a^{2}}}\ln \left\vert \dfrac{\sqrt{a+b}+\sqrt{b-a}% \tan x/2}{\sqrt{a+b}-\sqrt{b-a}\tan x/2}\right\vert .$$

Thus, we have your particular case

$$\int \dfrac{1}{\cos x}dx=\int \dfrac{1}{0+1\cos x}dx=\ln \left\vert \dfrac{% 1+\tan x/2}{1-\tan x/2}\right\vert . \qquad (\ast\ast)$$

From $\tan \dfrac{x}{2}=\dfrac{\sin x}{1+\cos x}$ and $\sec x+\tan x=\dfrac{1+\sec x+\tan x}{1+\sec x-\tan x}$ it follows that

$$\dfrac{1+\tan x/2}{1-\tan x/2}=\dfrac{1+\dfrac{\sin x}{1+\cos x}}{1-\dfrac{% \sin x}{1+\cos x}}=\dfrac{1+\cos x+\sin x}{1+\cos x-\sin x}=\sec x+\tan x$$

and, finally

$$\int \sec x\; dx=\ln \left\vert \sec x+\tan x\right\vert .$$

13

Here is another way to compute $$\int \sec x\,dx $$

First, we need a trig identity \begin{eqnarray*} \cos^2 x &=&(1-\sin x)(1+\sin x) \\ \frac{1-\sin x}{\cos x} &=&\frac{\cos x}{1+\sin x} \\ \sec x &=&\tan x+\frac{\cos x}{1+\sin x} \end{eqnarray*} Next, it suffices to integrate each side \begin{eqnarray*} \int \sec x\,dx &=&\int \tan x\,dx+\int \frac{\cos x}{1+\sin x}\,dx \\[6pt] &=&-\ln \left\vert \cos x\right\vert +\ln \left\vert 1+\sin x\right\vert +C \\[6pt] &=&\ln \left\vert \frac{1+\sin x}{\cos x}\right\vert +C \\[6pt] &=&\ln \left\vert \sec x+\tan x\right\vert +C \end{eqnarray*}

Idris Addou
  • 4,193
9

These articles exist:

http://en.wikipedia.org/wiki/Integral_of_the_secant_function

http://en.wikipedia.org/wiki/Weierstrass_substitution

V. Frederick Rickey and Philip M. Tuchinsky, An Application of Geography to Mathematics: History of the Integral of the Secant, Mathematics Magazine, volume 53, number 3, May 1980, pages 162–166.

Rickey & Tuchinsky's article tells us that the integral of the secant function was a well known conjecture in the 17th century, that Isaac Barrow solved the problem, and that the original reason for raising the question came from cartography.

7

Here's the argument in my less-than-one-page paper in the Monthly in June 2013:$^\dagger$ \begin{align} x & = \tan \left( \frac \pi 4 + \frac \theta 2 \right) \\[10pt] \frac{x^2-1}{x^2+1} & = \sin\theta \quad (\text{But we won't use this line, so move on to the next.}) \\[10pt] \frac{2x}{x^2+1} & = \cos\theta \\[10pt] \frac{2\,dx}{x^2+1} & = d\theta \\[10pt] \int \sec\theta \, d\theta & = \int \frac{dx} x = \log|x|+\text{constant} = \log\left| \tan\left( \frac \pi 4 + \frac \theta 2 \right) \right| + \text{constant}. \end{align}

I regret that in that paper I used the term Weierstrass substitution, following Stewart's calculus text, because, as I later learned, Stewart's attribution to Karl Weierstrass is almost certainly erroneous. I wrote to Stewart asking about the evidence for the claim. He didn't have any, but said the term was in widespread use before his book appeared.

(Privately I think of the trigonometric identity $\displaystyle\tan\left(\frac\pi4 \pm \frac\theta2\right) = \sec\theta\pm\tan\theta$ as the
$\text{“}$cartographer's tangent half-angle formula,$\text{”}$ but I'm not sure how much sense that makes.)


$^\dagger$Michael Hardy, "Efficiency in Antidifferentiation of the Secant Function", American Mathematical Monthly, June–July 2013, page 580.

4

Dual way to compute $$\int \csc x\,dx.$$

First, we need a trigonometry identity \begin{eqnarray*} \sin^2x &=&(1-\cos x)(1+\cos x) \\ \frac{1-\cos x}{\sin x} &=&\frac{\sin x}{1+\cos x} \\ \csc x &=&\cot x+\frac{\sin x}{1+\cos x} \end{eqnarray*} Next, it suffices to integrate each side \begin{eqnarray*} \int \csc x\,dx &=&\int \cot x\,dx+\int \frac{\sin x}{1+\cos x}\,dx \\ &=&\ln \left\vert \sin x\right\vert -\ln \left\vert 1+\cos x\right\vert +C \\ &=&-\ln \left\vert \frac{1+\cos x}{\sin x}\right\vert +C \\ &=&-\ln \left\vert \csc x+\cot x\right\vert +C \end{eqnarray*}

Idris Addou
  • 4,193
3

Here is a slightly different approach to calculate

$$ \int \frac{1}{\cos(x)}\,dx $$

Define $u := \tan(\frac{x}{2}) $ so it follows $dx = \frac{2}{1+u^2}\,du$. It follows that $\cos(x) = \frac{1-u^2}{1+u^2}$ under this substitution. Now we can write the integral as:

$$ \int \frac{1}{\cos(x)}\,dx = \int \frac{1}{\frac{1-u^2}{1+u^2}} \frac{2}{1+u^2}\,du = 2 \int \frac{1}{1-u^2}\,du$$

We know that $(\tanh^{-1}(x))’ = \frac{1}{1-x^2}$, so the integral becomes

$$ \int \frac{1}{\cos(x)}\,dx = 2 \int \frac{1}{1-u^2}\,du = 2 \tanh^{-1}(u) + C = 2 \tanh^{-1}(\tan(\frac{x}{2})) + C$$

The solution looks a bit different than the others posted here but it’s the same. The trick here is to know the substitution and also how to express $\cos(x)$ in terms of $u$ but after that it’s just the basic substitution rule.

mdcq
  • 1,658
2

Here is another variation on a theme. It relies on the following two double angle formulae for sine and cosine, namely $$\sin 2\theta = 2 \sin \theta \cos \theta \qquad \text{and} \qquad \cos 2 \theta = \cos^2 \theta - \sin^2 \theta,$$ two obvious substitutions, and a simple partial fraction decomposition. It is similar to making the famous $t$-substitution of $t = \tan \frac{x}{2}$ without having to rely on knowing this.

If the substitution $x = 2u$ is made, we have \begin{align} \int \sec x \, dx &= 2 \int \sec 2u \, du\\ &= 2 \int \frac{du}{\cos 2u}\\ &= 2 \int \frac{du}{\cos^2 u - \sin^2 u}\\ &= 2 \int \frac{du}{\cos^2 u(1 - \tan^2 u)}\\ &= 2 \int \frac{\sec^2 u}{1 - \tan^2 u} \, du. \end{align} Now let $t = \tan u, dt = \sec^2 u \, du$. Thus \begin{align} \int \sec x \, dx &= 2 \int \frac{dt}{1 - t^2}\\ &= 2 \int \frac{dt}{(1 - t)(1 + t)}\\ &= \int \left [\frac{1}{1 - t} + \frac{1}{1 + t} \right ] dt\\ &= \ln \left |\frac{1 + t}{1 - t} \right | + C\\ &= \ln \left |\frac{1 + \tan u}{1 - \tan u} \right | + C \qquad \text{since} \,\, t = \tan u\\ &= \ln \left |\frac{\cos u + \sin u}{\cos u - \sin u} \right | + C\\ &= \ln \left |\frac{\cos u + \sin u}{\cos u - \sin u} \cdot \frac{\cos u + \sin u}{\cos u + \sin u} \right | + C\\ &= \ln \left |\frac{\cos^2 u + \sin^2 u + 2\sin u \cos u}{\cos^2 u - \sin^2 u} \right | + C\\ &= \ln \left |\frac{1 + \sin 2u}{\cos 2u} \right | + C\\ &= \ln \left |\frac{1 + \sin x}{\cos x} \right | + C \qquad \text{since} \,\, x = 2u\\ &= \ln |\sec x + \tan x| + C, \end{align} as expected.

omegadot
  • 11,736
2

Here is yet another way to find the indefinite integral for secant using what is known as a Gunther hyperbolic substitution.

We begin by writing the indefinite integral for secant as $$\int \sec x \, dx = \int \frac{\sec^2 x}{\sec x} \, dx = \int \frac{d(\tan x)}{\sec x}.$$ Now let $x = \sinh u, d(\tan x) = \cosh u$, and it is not too hard to see that $\sec x = \sinh u$. Thus \begin{align} \int \sec x \, dx &= \int \frac{\cosh u}{\cosh u} \, du\\ &= \int du\\ &= u + C\\ &= \ln (\cosh u + \sinh u) + C\\ &= \ln |\tan x + \sec x| + C, \end{align} since $\sinh u = \tan x$ and $\cosh u = \sec x$, as expected.

omegadot
  • 11,736
2

My favorite way:

$$\int\frac{d\theta}{\cos\theta}=\int\frac{\cos\theta\,d\theta}{\cos^2\theta}=\int\frac{d\sin\theta}{1-\sin^2\theta}=\text{artanh}(\sin\theta).$$

1

Method-1: $$\int \sec x \,dx = \int \frac{dx}{\cos^2 \frac x2-\sin^2\frac x2} $$$$= \int \frac{\sec^2\frac x2\ dx}{1-\tan^2 \frac x2} $$$$=\int\left(\frac{\frac12\sec^2\frac x2\ dx}{1+\tan\frac x2}+\frac{\frac12\sec^2\frac x2dx}{1-\tan\frac x2}\right) $$ $$=\int\frac{d\left(1+\tan\frac x2\right)}{1+\tan\frac x2}-\int\frac{d\left(1-\tan\frac x2\right)}{1-\tan\frac x2}$$ $$=\ln\left|1+\tan \frac x2\right|-\ln\left|1-\tan \frac x2\right|$$ $$=\ln\left|\frac{1+\tan \frac x2}{1-\tan\frac x2}\right|$$$$=\ln\left|\tan\left(\frac x2+\frac{\pi}{4}\right)\right|+C$$

Method-2: $$\int \sec x \,dx = \int \frac{\sec x(\sec x+\tan x)dx}{\sec x+\tan x} $$ $$= \int \frac{(\sec x\tan x+\sec^2x)dx}{\sec x+\tan x} $$ $$= \int \frac{d(\sec x+\tan x)}{\sec x+\tan x} $$ $$=\ln|\sec x+\tan x|+C$$

1

At Math Educators S.E., Steven Gubkin motivated $\int \sec(x) \, dx $ with partial fractions.

Develop a general strategy for integrals of powers of trigonometric functions: If a power is odd, you can use Pythagorean identity and a substitution. If both powers are even, use half-angle reduction formulas.

For instance, substitute $u = \cos(x)$ in

$\begin{align} = & \int \color{red}{\sin^{2k+1}} && \color{lightseagreen}{\cos^m(x)} & \, dx \\ = & \int \color{red}{(1-\cos^2(x))^k} && \color{lightseagreen}{\cos^m(x)} & \color{red}{\sin(x)} \, dx\\ = & \int -(1-u^2)^k && \color{lightseagreen}{u^m} & \, du \end{align}$

Start with some positive integer examples. Here, you just get a polynomial, so you can integrate by expanding and integrating termwise. Then observe the same strategy works for all integers : you just get rational functions of $u$ if an exponent is negative, which might have to be decomposed with partial fractions.

An example of this general strategy is

$$ \begin{align*} \int \sec(x) dx &= \int \cos(x)^{-1} dx \qquad \textrm{ (This is an odd power of cosine.)}\\ &= \int \color{violet}{\cos(x)^{-2}} \qquad \qquad \color{darkgoldenrod}{\cos(x) \, dx}\\ &=\int \color{orchid}{(1-\sin^2(x))^{-1}} \quad \, \color{darkgoldenrod}{\cos(x) \, dx}\\ &=\int \frac{1}{1-u^2} du\\ &=\frac{1}{2}\int \frac{1}{1-u}+\frac{1}{1+u} du\\ &=\frac{1}{2}\left( \ln(1+u) - \ln(1-u)\right)+C\\ &=\frac{1}{2}\ln(\frac{1+\sin(x)}{1-\sin(x)})+C\\ &=\frac{1}{2}\ln(\frac{(1+\sin(x))^2}{\cos^2(x)})+C\\ &=\ln\left| \frac{1+\sin(x)}{\cos(x)} \right|+C\\ &=\ln\left| \sec(x) +\tan(x)\right|+C \end{align*} $$

So now $\int \sec(x)$ fits into a more general story: it exemplifies our general strategy for integrating any function of the form $\sin^n(x)\cos^m(x)$.