How to figure out which contour shape to use when evaluating Fourier transform of $x\mapsto \operatorname{sech}(\pi x)$? I understand that when we have a polynomial a semicircle is used because the poles are included in the contour when doing so but in the following example a rectangle has been used and I am struggling to understand how to come up with this i.e. what the reasoning behind it is.

10.3.2 Computing $\widehat{f}(\xi)$, and hence $\phi(\xi, x)$, by using the CRT:
Next we are going to show that the function $f: \mathbb{R}^{1} \rightarrow \mathbb{R}^{1}, f(x)=\operatorname{sech}(\pi x)$, has Fourier transform
$$
\hat{f}(\xi)=\operatorname{sech}(\xi / 2), \quad \xi \in \mathbb{R}^{1}
$$
To do that, consider the contour integral
$$
\int_{\gamma_{n}} e^{i \xi z} \operatorname{sech}(\pi z) d z \quad \text { with } \xi>0
$$
around the finite rectangle $\gamma_{n}$ in $\mathbb{C}=\{x+i y\}$ bounded by the lines
$$
y=0, \quad y=n+1, \quad x=-n-1, \quad x=n+1
$$
with $n$ a positive integer.

 A: Fourier transform integrals are commonly treated using a rectangular contour, possibly with semicircular bumps to avoid poles on the real axis. The reason for a rectangular contour is that the factor $e^{i\xi z}$ is easily understood on such a contour. If we write $z = x+iy$, then on vertical lines $x = M$, $e^{i\xi z} = e^{i M\xi}e^{-i\xi y}$. Similarly on horizontal lines $y=N>0$ we have $e^{i\xi z} = e^{i\xi x}e^{-\xi N}$.
For reasonable choices of $f$ in the contour integral $\int e^{i\xi z}f(z)~dz$, you can control three of the pieces of the contour easily. On the vertical lines you will want to use decay of $f(x+iy)$ in the horizontal direction, as you let $M \to \pm\infty$. On the horizontal line $y=N>0$, you can use the exponential decay from $e^{-\xi N}$ to help you bound the integral.
A: It appears this question is nearly four years old, but I'll answer it anyway for future reference. As you know, if we want to evaluate the Fourier transform of the function $f:x\mapsto \operatorname{sech}(\pi x)$ we need to compute the integral
$$\mathcal{F}(f)(\xi)=\int_{\mathbb{R}}\operatorname{sech}(\pi x)e^{-2\pi i\xi x}\mathrm{d}x$$
In the complex plane this looks like this:

To appeal to the Residue Theorem, we think of another rectangular contour
$$R(L)=R_1(L)\cup R_2(L)\cup R_3(L)\cup R_4(L)$$
Using
$$R_1(L)=\{z\in\mathbb{C}:\operatorname{Im}z=0\text{ and }|z|<L\}$$
$$R_2(L)=\{z\in\mathbb{C}:\operatorname{Re}(z)=L\text{ and }0\leq\operatorname{Im}z\leq L\}$$
$$R_3(L)=\{z\in\mathbb{C}:\operatorname{Im}z=L\text{ and }-L\leq\operatorname{Re}z\leq L\}$$
$$R_4(L)=\{z\in\mathbb{C}:\operatorname{Re}(z)=-L\text{ and }0\leq\operatorname{Im}z\leq L\}$$
Oriented counterclockwise. In the complex plane this looks as such:

The trick is, if we can show that as we take $L\to\infty$, that the contribution to the integral from the parts of the contour off the real line vanishes, then we can say
$$\lim_{L\to\infty}\oint\limits_{R(L)}\operatorname{sech}(\pi z)e^{-2\pi i\xi z}\mathrm{d}z=\int_{\mathbb{R}}\operatorname{sech}(\pi x)e^{-2\pi i\xi x}\mathrm{d}x$$
Once we've done this, we recall that the singularities of $f$ in the upper half plane occur at
$$i\left(n+\frac{1}{2}\right)~~~~n\in\mathbb{N}_0$$
So
$$\lim_{L\to\infty}\oint\limits_{R(L)}\operatorname{sech}(\pi z)e^{-2\pi i\xi z}\mathrm{d}z=2\pi i\sum_{n=0}^\infty \operatorname{Res}\left(f,i\left(n+\frac{1}{2}\right)\right)$$
I won't detail all of the computations here, but hopefully this is a good outline of the overall method.
