I'd like to compute: $$ I_n = \int_{-\infty}^{+\infty}\mathrm{d}x\frac{x^{2n}}{\cosh^2 x}. $$ We have, quite easily: $$ I_0 = \int_{-\infty}^{+\infty}\mathrm{d}x\frac{1}{\cosh^2 x}=\left[\tanh x\right]_{-\infty}^{+\infty}=2. $$ So to begin with, I gave a try at $$ I_1 = \int_{-\infty}^{+\infty}\mathrm{d}x\frac{x^{2}}{\cosh^2 x}. $$ My idea was to use the following contour $\Gamma_{\varepsilon, M}$ to integrate on in the complex plane: the rectangle with vertices $M$, $M+i\frac{\pi}{2}$, $-M+i\frac{\pi}{2}$, $-M$, and an indent of radius $\varepsilon$ at $i\frac{\pi}{2}$, where $\cosh z=0$. Then by Residues Theorem: $$ \oint_{\Gamma_{\varepsilon, M}} \mathrm{d}z\frac{z^{2}}{\cosh^2 z} = 0. $$
Problem is, when I make the calculations the integrand is still singular $O(\frac{1}{\varepsilon})$ on my semicircle. More explicitly: $$ \int_{0}^{-\pi} \mathrm{d}\theta i\varepsilon e^{i\theta}\frac{(i\frac{\pi}{2}+\varepsilon e^{i\theta})^{2}}{\cosh^2 (i\frac{\pi}{2}+\varepsilon e^{i\theta})} = \int_{0}^{-\pi} \mathrm{d}\theta i\varepsilon e^{i\theta} \frac{-\frac{\pi^2}{4} + O(\varepsilon)}{\varepsilon^2e^{2i\theta}+O(\varepsilon^3)}. $$ To avoid this problem I tried: $$ \oint_{\Gamma_{\varepsilon, M}} \mathrm{d}z\frac{(z-i\frac{\pi}{2})^{2}}{\cosh^2 z}=0. $$
But then I only get: $$ \int \mathrm{d}x\frac{(x-i\frac{\pi}{2})^{2}}{\cosh^2x}-\int \mathrm{d}x\frac{x^{2}}{\cosh^2(x-i\frac{\pi}{2})}=0 $$ $$ \int \mathrm{d}x\left(\frac{x^2}{\cosh^2x}+\frac{x^2}{\sinh^2x}\right) = \frac{\pi^2}{2} $$
since $\cosh(x+i\frac{\pi}{2}) = i\sinh x$.
Why not simply go up to $\Im{z} = \pi$ so that the rectangle $C$ has vertices $\pm R$ and $\pm R+i \pi$? Then we consider
$$\oint_C dz \frac{z^{2 n+1}}{\cosh^2{z}}$$
which is equal to
$$\int_{-R}^R dx \frac{x^{2 n+1}}{\cosh^2{x}} + i \int_0^{\pi} dy \frac{(R+i y)^{2 n+1}}{\cosh^2{(R + i y)}} \\ + \int_R^{-R} dx \frac{(x+i \pi)^{2 n+1}}{\cosh^2{x}} + i \int_{\pi}^0 dy \frac{(-R+i y)^{2 n+1}}{\cosh^2{(-R + i y)}}$$
As $R \to \infty$, the second and fourth integrals vanish. Thus the contour integral is equal to
$$\int_{-\infty}^{\infty} dx \frac{x^{2 n+1}-(x+i \pi)^{2 n+1}}{\cosh^2{x}}$$
Note that the highest power in the numerator is $x^{2 n}$, and that all odd powers vanish upon integration. Thus the contour integral is expressible in terms of integrals of lower powers:
$$-i \pi (2 n+1)\int_{-\infty}^{\infty} dx \frac{x^{2 n}}{\cosh^2{x}} +i \sum_{k=0}^{n-1} (-1)^k \binom{2 n+1}{2 k} \pi^{2 (n-k)+1}\int_{-\infty}^{\infty} dx \frac{x^{2 k}}{\cosh^2{x}}$$
By the residue theorem, the contour integral is also equal to $i 2 \pi$ times the residue of the integrand at the pole $z=i \pi/2$, which is a double pole.
$$\operatorname*{Res}_{z=i \pi/2} \frac{z^{2 n+1}}{\cosh^2{z}} = \lim_{z\to i \pi/2} \frac{d}{dz}\frac{(z-i \pi/2)^2 z^{2 n+1}}{\cosh^2{z}} = (-1)^{n+1} (2 n+1) \left ( \frac{\pi}{2}\right )^{2 n}$$
In order to verify this you can proceed as follows: $$ \lim_{z\to i \pi/2} \frac{d}{dz}\frac{(z-i \pi/2)^2 z^{2 n+1}}{\cosh^2{z}} = \lim_{u\to 0} \frac{d}{dz}\frac{u^2 (u+i\pi/2)^{2 n+1}}{-\sinh^2{u}} = \lim_{u\to 0} (u+i\pi/2)^n\ \frac{-\left((2n+1)u^2+2(u+i\pi/2)u\right)2\sinh u+2(u+i\pi/2)u^2\cosh u}{\sinh^3u} = \lim_{u\to 0} (u+i\pi/2)^n\ \frac{-(2n+3)u^3-i\pi u +2u^3 + i\pi u + O(u^4)}{u^3+O(u^4)}= (-1)^{n+1}(2n+1)\left(\frac{\pi}{2}\right) ^{2n}. $$
You then need to find the integrals of lower powers. Actually, you can get around this by setting up a system of equations for each $k$ from $0$ to $n$. Let
$$I_k = \int_{-\infty}^{\infty} dx \frac{x^{2 k}}{\cosh^2{x}}$$
and
$$R_k = (-1)^{k} (2 k+1) \left ( \frac{\pi}{2}\right )^{2 k}$$
Then we have
$$(2 n+1) I_n - \sum_{k=0}^{n-1} (-1)^k \binom{2 n+1}{2 k} \pi^{2 (n-k)} I_k = 2 R_n$$ $$(2 n-1) I_{n-1} - \sum_{k=0}^{n-2} (-1)^k \binom{2 n-1}{2 k} \pi^{2 (n-1-k)} I_k = 2 R_{n-1}$$ $$\cdots$$ $$3 I_1 - \pi^2 I_0 = 2 R_1$$ $$I_0 = 2 $$