Artificial intelligent assistant

Integrating secans over the imaginary axis using the residue theorem I am trying to integrate $\sec(z)$ over the whole imaginary axis using the residue theorem. i.e., I want to calculate the integral $$\int_{\Gamma} \frac{dz}{\cos{z}}$$ where $\Gamma$ is the (open) contour that moves along the straight line $x=0$ from $y=-\infty$ to $y=\infty$. $1/\cos(z)$ has infintely many simple poles at either side of the contour. The residues at these poles are $$\text{Res}_{z=-\frac{\pi}{2}+ 2n\pi}\left(\frac{1}{\cos(x)}\right)=1$$ and $$\text{Res}_{z=\frac{\pi}{2}+ 2n\pi}\left(\frac{1}{\cos(x)}\right)=1$$ for $n\in \mathbb{Z}$. My question doesn't really concern the calculation, I just want to find the appropriate contour(s). My initial idea was to use two contours so that the infinite poles on either side of $x=0$ would somehow cancel out, but I haven't gotten very far.

Use a rectangular contour with vertices $-i R$, $i R$, $-\pi + i R$, and $-\pi - i R$. The contour integral is then

$$i \int_{-R}^R \frac{dy}{\cosh{y}} + \int_0^{-\pi} \frac{dx}{\cos{(x+i R)}} - i \int_R^{-R} \frac{dy}{\cosh{y}} + \int_{-\pi}^0 \frac{dx}{\cos{(x-i R)}}$$

As $R \to \infty$, the second and fourth integrals vanish. Thus, by the residue theorem, your contour integral is

$$i 2 \int_{-\infty}^{\infty} \frac{dy}{\cosh{y}} = i 2 \pi $$

because the residue at the simple pole $z=-\pi/2$ is $1$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2a4d8d20cf234d98e37d30606a5173df