Residue of $\text{sech}^2(z)$ I am trying to find the residue of $\text{sech}^2(z)$ at $z=\pi/2 i$. The function has a second order pole at $\pi/2 i$. I find the residue to be zero. 
However, the integral $\int \limits_{-\infty}^\infty dx~ \text{sech}^2(x)=2$ which can also be evaluated using Cauchy's formula using a rectangular path connecting points $(-R,0), (R,0), (R, i\pi)$ and $(-R,i\pi)$ in the complex plane and letting $R\to\infty$. However, since the residue is zero, the integral is also zero. 
Don't know what is wrong. Any input would be appreciated. Thanks. 
 A: Think carefully about what's actually going on before making that kind of $R\to\infty $ argument, in particular how the integrals along the edges contribute to the overall contour.
Let $\Gamma $ be the contour you've described. Then if the residue sum inside $\Gamma $ is zero for some well-behaved $f:\mathbb{C}\to\mathbb{C}$, Cauchy's integral theorem tells us
$$ 0 = \int _\Gamma  dz f(z) = \int ^\infty_{-\infty} dzf(z) -  \int ^\infty_{-\infty} dz f(z+i\pi ) + \int ^{R+i\pi}_R dzf(z) - \int ^{-R+i\pi}_{-R} dzf(z)   $$
Ordinarily you would want to rearrange for $ \int ^\infty_{-\infty} dzf(z) $ and prepare for the limit, but in your case the $i\pi $-periodicity of $\newcommand{sech}{{\operatorname{sech}}} \sech ^2(z)$ means the second integral on the rhs is identical to the first and so they simply cancel each other out.
In other words, the theorem can afford no insight here, and you don't even get to the stage of taking $R\to\infty$.
A: Applying the Taylor expansion, near $z=\dfrac{i\pi}2$,
$$
f(z)=f\left(\frac{i\pi}2\right)+f'\left(\frac{i\pi}2\right)\left(z-\frac{i\pi}2\right)+\frac12f''\left(\frac{i\pi}2\right)\left(z-\frac{i\pi}2\right)^2+O\left(z-\frac{i\pi}2\right)^3
$$
to the function $z \mapsto f(z)=\cosh z$, using 
$$(\cosh z)'=\sinh z ,\quad (\sinh z)'=\cosh z, \quad \cosh \left(\frac{i\pi}2\right)=0,\quad \sinh \left(\frac{i\pi}2\right)=i,
$$ you get
$$
\cosh z=i \left(z-\frac{i \pi }{2}\right)+\frac{1}{6} i \left(z-\frac{i \pi }{2}\right)^3+O\left(z-\frac{i\pi}2\right)^4
$$ giving

$$
\cosh^2 z=- \left(z-\frac{i \pi }{2}\right)^2-\frac13  \left(z-\frac{i \pi }{2}\right)^4+O\left(z-\frac{i\pi}2\right)^5.
$$ 

Then, recalling that, as $u \to 0$,
$$
\frac1{1+u}=1-u+O(u^2)
$$ we obtain

$$
\begin{align}
\frac1{\cosh^2 z}&=-\frac1{\left(z-\frac{i \pi }{2}\right)^2}\frac1{1+\frac13  \left(z-\frac{i \pi }{2}\right)^2+O\left(z-\frac{i \pi }{2}\right)^3}\\\\
&=-\frac1{\left(z-\frac{i \pi }{2}\right)^2}\left( 1-\frac13  \left(z-\frac{i \pi }{2}\right)^2+O\left(z-\frac{i \pi }{2}\right)^3\right)\\\\
&=-\frac{1}{\left(z-\frac{i \pi }{2}\right)^2}+\frac{1}{3}+O \left(z-\frac{i \pi }{2}\right).
\end{align}
$$

Now observe that
$$\left( \tanh z\right)'=\text{sech}^2(z)
$$ thus
$$
\int_{-M}^{M}\text{sech}^2(z) dz=[\tanh z]_{-M}^{M}
$$ and

$$
\int_{-\infty}^{\infty}\text{sech}^2(z) dz=2\lim_{M \to \infty}\left(\tanh M\right)=2.
$$

A: 
Ok, I think I have a solution. The residue of $sech^2(z)$ at $z=i\pi/2$ is zero. Now take a triangular contour with vertices $(R,0), (0,\pi)$ and $(-R,0)$. On the path $(R,0) \to (0,\pi)$, $z=x(1-i\pi/R)$ and $dy=-(\pi/R)dx$. On the other side of the contour, $z=x(1+i\pi/R)$ and $dy=(\pi/R)dx$. Thus the integral $\int dz~ \text{sech}^2(z) =-\tanh(R)$ on both sides of the triangle. Applying Cauchy's formula, we get,

$\int_{-R}^R dx~ \text{sech}^2(x) = 2~\text{tanh(R)}$ 
Taking $R \to \infty $, $\tanh(R)\to 1$, and we have the desired result.
