# Integral of the secant function

In calculus, the integral of the secant function can be evaluated using a variety of methods and there are multiple ways of expressing the antiderivative, all of which can be shown to be equivalent via trigonometric identities,

$\int \sec \theta \,d\theta ={\begin{cases}{\dfrac {1}{2}}\ln \left|{\dfrac {1+\sin \theta }{1-\sin \theta }}\right|+C\\[15pt]\ln \left|\sec \theta +\tan \theta \right|+C\\[15pt]\ln \left|\tan \left({\dfrac {\theta }{2}}+{\dfrac {\pi }{4}}\right)\right|+C\\[15pt]\end{cases}}$ This formula is useful for evaluating various trigonometric integrals. In particular, it can be used to evaluate the integral of the secant cubed, which, though seemingly special, comes up rather frequently in applications.

## Proof that the different antiderivatives are equivalent

### Trigonometric forms

$\int \sec \theta \,d\theta =\left\{{\begin{array}{l}{\dfrac {1}{2}}\ln \left|{\dfrac {1+\sin \theta }{1-\sin \theta }}\right|+C\\[15pt]\ln \left|\sec \theta +\tan \theta \right|+C\\[15pt]\ln \left|\tan \left({\dfrac {\theta }{2}}+{\dfrac {\pi }{4}}\right)\right|+C\end{array}}\right\}{\text{ (equivalent forms)}}$ The second of these follows by first multiplying top and bottom of the interior fraction by 1 + sin θ. This gives 1 − sin2θ = cos2θ in the denominator, and the result follows by moving the factor of 1/2 into the logarithm as a square root. Leaving out the constant of integration for now,

{\begin{aligned}{\dfrac {1}{2}}\ln \left|{\dfrac {1+\sin \theta }{1-\sin \theta }}\right|&={\dfrac {1}{2}}\ln \left|{\dfrac {1+\sin \theta }{1-\sin \theta }}\cdot {\dfrac {1+\sin \theta }{1+\sin \theta }}\right|\\&={\dfrac {1}{2}}\ln \left|{\dfrac {(1+\sin \theta )^{2}}{1-\sin ^{2}\theta }}\right|\\&={\dfrac {1}{2}}\ln \left|{\dfrac {(1+\sin \theta )^{2}}{\cos ^{2}\theta }}\right|\\&={\dfrac {1}{2}}\ln \left({\dfrac {1+\sin \theta }{\cos \theta }}\right)^{2}\\&=\ln {\sqrt {\left({\dfrac {1+\sin \theta }{\cos \theta }}\right)^{2}}}\\&=\ln \left|{\dfrac {1+\sin \theta }{\cos \theta }}\right|\\&=\ln |\sec \theta +\tan \theta |.\end{aligned}} The third form follows by rewriting sin θ as − cos(θ + π/2) and expanding using the double-angle identities for cos 2x. It may also be obtained directly by means of the following substitutions:

{\begin{aligned}\sec \theta ={\frac {1}{\sin \left(\theta +{\dfrac {\pi }{2}}\right)}}={\frac {1}{2\sin \left({\dfrac {\theta }{2}}+{\dfrac {\pi }{4}}\right)\cos \left({\dfrac {\theta }{2}}+{\dfrac {\pi }{4}}\right)}}={\frac {\sec ^{2}\left({\dfrac {\theta }{2}}+{\dfrac {\pi }{4}}\right)}{2\tan \left({\dfrac {\theta }{2}}+{\dfrac {\pi }{4}}\right)}}\,.\end{aligned}} The conventional solution for the Mercator projection ordinate may be written without the absolute value signs since the latitude φ lies between π/2 and π/2,

$y=\ln \tan \!\left({\frac {\varphi }{2}}+{\frac {\pi }{4}}\right).$ ### Hyperbolic forms

Let

{\begin{aligned}\psi &=\ln(\sec \theta +\tan \theta ),\\[4pt]e^{\psi }&=\sec \theta +\tan \theta ,\\[4pt]\sinh \psi &={\frac {e^{\psi }-e^{-\psi }}{2}}=\tan \theta ,\\[4pt]\cosh \psi &={\sqrt {1+\sinh ^{2}\psi }}=|\sec \theta \,|,\\[4pt]\tanh \psi &=\sin \theta .\end{aligned}} Therefore,

{\begin{aligned}\int \sec \theta \,d\theta &=\operatorname {artanh} \left(\sin \theta \right)+C\\[-2mu]&=\operatorname {sgn}(\cos \theta )\operatorname {arsinh} \left(\tan \theta \right)+C\\[7mu]&=\operatorname {sgn}(\sin \theta )\operatorname {arcosh} {\left|\sec \theta \right|}+C.\end{aligned}} ## History

The integral of the secant function was one of the "outstanding open problems of the mid-seventeenth century", solved in 1668 by James Gregory. He applied his result to a problem concerning nautical tables. 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. 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 that

$\int _{0}^{\varphi }\sec \theta \,d\theta =\ln \tan \left({\frac {\theta }{2}}+{\frac {\pi }{4}}\right).$ This conjecture became widely known, and in 1665, Isaac Newton was aware of it.

## Evaluations

### By a standard substitution (Gregory's approach)

A standard method of evaluating the secant integral presented in various references involves multiplying the numerator and denominator by sec θ + tan θ and then using the substitution u = sec θ + tan θ. This substitution can be obtained from the derivatives of secant and tangent added together, which have secant as a common factor.

Starting with

${\frac {d}{d\theta }}\sec \theta =\sec \theta \tan \theta \quad {\text{and}}\quad {\frac {d}{d\theta }}\tan \theta =\sec ^{2}\theta ,$ {\begin{aligned}{\frac {d}{d\theta }}(\sec \theta +\tan \theta )&=\sec \theta \tan \theta +\sec ^{2}\theta \\&=\sec \theta (\tan \theta +\sec \theta ).\end{aligned}} The derivative of the sum is thus equal to the sum multiplied by sec θ. This enables multiplying sec θ by sec θ + tan θ in the numerator and denominator and performing the following substitutions:

{\begin{aligned}u&=\sec \theta +\tan \theta \\du&=\left(\sec \theta \tan \theta +\sec ^{2}\theta \right)\,d\theta .\end{aligned}} The integral is evaluated as follows:

{\begin{aligned}\int \sec \theta \,d\theta &=\int {\frac {\sec \theta (\sec \theta +\tan \theta )}{\sec \theta +\tan \theta }}\,d\theta \\[6pt]&=\int {\frac {\sec ^{2}\theta +\sec \theta \tan \theta }{\sec \theta +\tan \theta }}\,d\theta &u&=\sec \theta +\tan \theta \\[6pt]&=\int {\frac {1}{u}}\,du&du&=\left(\sec \theta \tan \theta +\sec ^{2}\theta \right)\,d\theta \\[6pt]&=\ln |u|+C\\[4pt]&=\ln |\sec \theta +\tan \theta |+C,\end{aligned}} as claimed. This was the formula discovered by James Gregory.

### By partial fractions and a substitution (Barrow's approach)

Although Gregory proved the conjecture in 1668 in his Exercitationes Geometricae, the proof was presented in a form that renders it nearly impossible for modern readers to comprehend; Isaac Barrow, in his Lectiones Geometricae of 1670, gave the first "intelligible" proof, though even that was "couched in the geometric idiom of the day." Barrow's proof of the result was the earliest use of partial fractions in integration. Adapted to modern notation, Barrow's proof began as follows:

$\int \sec \theta \,d\theta =\int {\frac {1}{\cos \theta }}\,d\theta =\int {\frac {\cos \theta }{\cos ^{2}\theta }}\,d\theta =\int {\frac {\cos \theta }{1-\sin ^{2}\theta }}\,d\theta$ Substituting u = sin θ, du = cos θ , reduces the integral to

{\begin{aligned}\int {\frac {1}{1-u^{2}}}\,du&=\int {\frac {1}{(1+u)(1-u)}}\,du\\[6pt]&=\int {\frac {1}{2}}\!\left({\frac {1}{1+u}}+{\frac {1}{1-u}}\right)du&&{\text{partial fraction decomposition}}\\[6pt]&={\frac {1}{2}}{\bigl (}\ln \left|1+u\right|-\ln \left|1-u\right|{\bigr )}+C\\[6pt]&={\frac {1}{2}}\ln \left|{\frac {1+u}{1-u}}\right|+C\end{aligned}} Therefore,

$\int \sec \theta \,d\theta ={\frac {1}{2}}\ln \left|{\frac {1+\sin \theta }{1-\sin \theta }}\right|+C,$ as expected.

### By the tangent half-angle substitution

#### Standard

The formulas for the tangent half-angle substitution are as follows. Let t = tan θ/2, where π < θ < π. Then

{\begin{aligned}\cos {\frac {\theta }{2}}&={\frac {1}{\sec {\frac {\theta }{2}}}}={\frac {1}{\sqrt {1+\tan ^{2}{\frac {\theta }{2}}}}}={\frac {1}{\sqrt {1+t^{2}}}}\\[4pt]\sin {\frac {\theta }{2}}&=\tan {\frac {\theta }{2}}\cdot \cos {\frac {\theta }{2}}={\frac {t}{\sqrt {1+t^{2}}}}.\end{aligned}} Hence, by the double-angle formulas,

$\sin \theta ={\frac {2t}{1+t^{2}}},\qquad \cos \theta ={\frac {1-t^{2}}{1+t^{2}}},\qquad {\text{and}}\qquad d\theta ={\frac {2}{1+t^{2}}}\,dt.$ As for the integral of the secant function,

{\begin{aligned}\int \sec \theta \,d\theta =\int {\frac {1}{\cos \theta }}d\theta &=\int \left({\frac {1+t^{2}}{1-t^{2}}}\right)\!\left({\frac {2}{1+t^{2}}}\right)\,dt&&t=\tan {\frac {\theta }{2}}\\[6pt]&=\int {\frac {2}{1-t^{2}}}\,dt\\[6pt]&=\int {\frac {2}{(1-t)(1+t)}}\,dt\\[6pt]&=\int \left({\frac {1}{1+t}}+{\frac {1}{1-t}}\right)\,dt&&{\text{partial fraction decomposition}}\\[6pt]&=\ln |1+t|-\ln |1-t|+C\\[6pt]&=\ln \left|{\frac {1+t}{1-t}}\right|+C\\[6pt]&=\ln \left|{\frac {1+t}{1-t}}\cdot {\frac {1+t}{1+t}}\right|+C\\[6pt]&=\ln \left|{\frac {1+2t+t^{2}}{1-t^{2}}}\right|+C\\[6pt]&=\ln \left|{\frac {1+t^{2}}{1-t^{2}}}+{\frac {2t}{1-t^{2}}}\right|+C\\[6pt]&=\ln \left|{\frac {1+t^{2}}{1-t^{2}}}+{\frac {2t}{1+t^{2}}}\cdot {\frac {1+t^{2}}{1-t^{2}}}\right|+C\\[6pt]&=\ln \left|{\frac {1}{\cos \theta }}+\sin \theta \cdot {\frac {1}{\cos \theta }}\right|+C\\[6pt]&=\ln |\sec \theta +\tan \theta |+C,\end{aligned}} as before.

#### Non-standard

The integral can also be derived by using a somewhat non-standard version of the tangent half-angle substitution, which is simpler in the case of this particular integral, published in 2013, is as follows:

{\begin{aligned}x&=\tan \left({\frac {\pi }{4}}+{\frac {\theta }{2}}\right)\\[10pt]{\frac {2x}{1+x^{2}}}&={\frac {2\tan \left({\frac {\pi }{4}}+{\frac {\theta }{2}}\right)}{\sec ^{2}\left({\frac {\pi }{4}}+{\frac {\theta }{2}}\right)}}=2\sin \left({\frac {\pi }{4}}+{\frac {\theta }{2}}\right)\cos \left({\frac {\pi }{4}}+{\frac {\theta }{2}}\right)\\[6pt]&=\sin \left({\frac {\pi }{2}}+\theta \right)=\cos \theta &&{\text{by the double-angle formula}}\\[10pt]dx&={\frac {1}{2}}\sec ^{2}\left({\frac {\pi }{4}}+{\frac {\theta }{2}}\right)d\theta ={\frac {1}{2}}\left(1+x^{2}\right)d\theta \\[10pt]d\theta &={\frac {2}{1+x^{2}}}\,dx.\end{aligned}} Substituting:

{\begin{aligned}\int \sec \theta \,d\theta =\int {\frac {1}{\cos \theta }}\,d\theta &=\int {\frac {1+x^{2}}{2x}}\cdot {\frac {2}{1+x^{2}}}\,dx\\[6pt]&=\int {\frac {1}{x}}\,dx\\[6pt]&=\ln |x|+C\\[6pt]&=\ln \left|\tan \left({\frac {\pi }{4}}+{\frac {\theta }{2}}\right)\right|+C.\end{aligned}} ### By two successive substitutions

The integral can also be solved by manipulating the integrand and substituting twice. Using the definition sec θ = 1/cos θ and the identity cos2θ + sin2θ = 1, the integral can be rewritten as

$\int \sec \theta \,d\theta =\int {\frac {1}{\cos \theta }}\,d\theta =\int {\frac {\cos \theta }{\cos ^{2}\theta }}\,d\theta =\int {\frac {\cos \theta }{1-\sin ^{2}\theta }}\,d\theta .$ Substituting u = sin θ, du = cos θ reduces the integral to

$\int {\frac {1}{1-u^{2}}}\,du.$ The reduced integral can be evaluated by substituting u = tanh t, du = sech2t dt, and then using the identity 1 − tanh2t = sech2t.

$\int {\frac {\operatorname {sech} ^{2}t}{1-\tanh ^{2}t}}\,dt=\int {\frac {\operatorname {sech} ^{2}t}{\operatorname {sech} ^{2}t}}\,dt=\int dt.$ The integral is now reduced to a simple integral, and back-substituting gives

{\begin{aligned}\int dt&=t+C\\&=\operatorname {artanh} u+C\\[4pt]&=\operatorname {artanh} (\sin \theta )+C,\end{aligned}} which is one of the hyperbolic forms of the integral.

A similar strategy can be used to integrate the cosecant, hyperbolic secant, and hyperbolic cosecant functions.

### Other hyperbolic forms

It is also possible to find the other two hyperbolic forms directly, by again multiplying and dividing by a convenient term:

$\int \sec \theta \,d\theta =\int {\frac {\sec ^{2}\theta }{\sec \theta }}\,d\theta =\int {\frac {\sec ^{2}\theta }{\pm {\sqrt {1+\tan ^{2}\theta }}}}\,d\theta ,$ where $\pm$ stands for $\operatorname {sgn}(\cos \theta )$ because ${\sqrt {1+\tan ^{2}\theta }}=|\sec \theta \,|.$ Substituting u = tan θ, du = sec2θ , reduces to a standard integral:

{\begin{aligned}\int {\frac {1}{\pm {\sqrt {1+u^{2}}}}}\,du&=\pm \operatorname {arsinh} u+C\\&=\operatorname {sgn}(\cos \theta )\operatorname {arsinh} \left(\tan \theta \right)+C,\end{aligned}} where sgn is the sign function.

Likewise:

$\int \sec \theta \,d\theta =\int {\frac {\sec \theta \tan \theta }{\tan \theta }}\,d\theta =\int {\frac {\sec \theta \tan \theta }{\pm {\sqrt {\sec ^{2}\theta -1}}}}\,d\theta .$ Substituting u = |sec θ|, du = |sec θ| tan θ , reduces to a standard integral:

{\begin{aligned}\int {\frac {1}{\pm {\sqrt {u^{2}-1}}}}\,du&=\pm \operatorname {arcosh} u+C\\&=\operatorname {sgn}(\sin \theta )\operatorname {arcosh} \left|\sec \theta \right|+C.\end{aligned}} ### Using Complex Exponential Form

Secant is defined in terms of the complex exponential function as:

{\begin{aligned}\sec \theta ={\frac {2}{e^{i\theta }+e^{-i\theta }}}\end{aligned}} This allows the integral to be rewritten as:

{\begin{aligned}\int \sec \theta \,d\theta =\int {\frac {2}{e^{i\theta }+e^{-i\theta }}}d\theta =\int {\frac {2e^{i\theta }}{e^{2i\theta }+1}}d\theta \end{aligned}} Making the substitution:

{\begin{aligned}z=e^{i\theta }\end{aligned}} {\begin{aligned}dz=ie^{i\theta }\,d\theta \end{aligned}} Simplifies the equation to:

{\begin{aligned}\int {\frac {-2i}{z^{2}+1}}dz\end{aligned}} From here it's possible to solve using partial fractions:

{\begin{aligned}\int {\frac {-2i}{z^{2}+1}}dz&=\int {\frac {1}{z+i}}-{\frac {1}{z-i}}dz\\&=\ln(z+i)-\ln(z-i)+C\\&=\ln \left({\frac {z^{2}-1+2iz}{z^{2}+1}}\right)+C\end{aligned}} Then we undo the substitution:

{\begin{aligned}\ln \left({\frac {e^{2i\theta }-1+2ie^{i\theta }}{e^{2i\theta }+1}}\right)+C=\ln \left({\frac {e^{i\theta }-e^{-i\theta }+2i}{e^{i\theta }+e^{-i\theta }}}\right)+C\end{aligned}} At this point it's important to know the exponential form of tangent:

{\begin{aligned}\tan \theta =i\,{\frac {e^{-i\theta }-e^{i\theta }}{e^{-i\theta }+e^{i\theta }}}\end{aligned}} {\begin{aligned}\ln \left({\frac {e^{i\theta }-e^{-i\theta }}{e^{i\theta }+e^{-i\theta }}}+{\frac {2i}{e^{i\theta }+e^{-i\theta }}}\right)+C&=\ln(i\,\tan \theta +i\,\sec \theta )+C\\&=\ln(\tan \theta +\sec \theta )+\ln(i)+C\\&=\ln(\tan \theta +\sec \theta )+C\end{aligned}} Because the constant of integration can be anything, the additional constant term can be absorbed into it. Finally, if theta is real-valued, we can indicate this with absolute value brackets in order to get the equation into its most familiar form:

{\begin{aligned}\int \sec \theta \,d\theta =\ln |\tan \theta +\sec \theta |+C\end{aligned}} ## Gudermannian and Lambertian The Gudermannian function relates the area of a circular sector to the area of a hyperbolic sector, via a common stereographic projection. If twice the area of the blue hyperbolic sector is ψ, then twice the area of the red circular sector is ϕ = gd ψ. Twice the area of the purple triangle is the stereographic projection s = tan 1/2ϕ = tanh 1/2ψ. The blue point has coordinates (cosh ψ, sinh ψ). The red point has coordinates (cos ϕ, sin ϕ). The purple point has coordinates (0, s).

The integral of the hyperbolic secant function defines the Gudermannian function:

$\int _{0}^{\psi }\operatorname {sech} u\,du=\operatorname {gd} \psi .$ The integral of the secant function defines the Lambertian function, which is the inverse of the Gudermannian function:

$\int _{0}^{\phi }\sec t\,dt=\operatorname {lam} \phi =\operatorname {gd} ^{-1}\phi .$ These functions are encountered in the theory of map projections: the Mercator projection of a point on the sphere with longitude λ and latitude ϕ may be written as:

$(x,y)={\bigl (}\lambda ,\operatorname {lam} \phi {\bigr )}.$ 