Learning Scientific Programming with Python (2nd edition)

P8.2.2: Integral of the secant function

Question P8.2.2

The integral of the secant function, $$ \int_0^\theta \sec\phi \;\mathrm{d}\phi $$ for $-\pi/2 < \theta < \pi/2$ is important in navigation and the theory of map projections. It can be expressed in closed form as the inverse Gudermannian function, $$ \mathrm{gd}^{-1}(\theta) = \ln |\sec\theta + \tan\theta|. $$ Use scipy.integrate.quad to calculate values for the integral across the relevant range for $\theta$ given above and compare graphically with the exact answer.