Contour integration in a Sum $\frac{1}{(2i)^n} \sum\limits_{k=0}^n (-1)^k \binom{n}{k} \int_{-\infty}^\infty \frac{e^{(n-2k)ix}}{x} dx$ The following question comes from the A sine integral post, in which user26872 proved the following:
$$\int_{-\infty}^\infty \left(\frac{\sin x}{x}\right)^n dx=\frac{1}{(2i)^n}\sum_{k=0}^n(-1)^k \binom{n}{k}\int_{-\infty}^\infty \frac{e^{(n-2k)ix}}{x^n}dx$$$$=\frac{1}{(2i)^n}\sum_{k=0}^{\lfloor n/2 \rfloor}(-1)^k \binom{n}{k}\int_{-\infty}^\infty \frac{e^{(n-2k)ix}}{x^n}dx$$
This then leads to the use of Cauchy's differentiation formula to get:
$$\int_{-\infty}^\infty \left(\frac{\sin x}{x}\right)^n dx=\frac{\pi}{(n-1)!}\sum_{k=0}^{\lfloor n/2\rfloor} (-1)^k \binom{n}{k}\left(\frac{n}{2}-k\right)^{n-1}$$
which gives the exact value of the integral for any positive integer value of n. I was able to prove this with a long and cumbersome derivation using the Laplace transform, but this user used contour integration. However, they did not specify how the contour was defined. I think it is a diameter from -R to R on the real axis then a semicircle in the lower half-plane back to -R, in the limit as $R\rightarrow\infty$, as it is easy to show that the integral over the arc tends to 0, thus making the integral over the contour equal to the integral over the real axis.
I'm fairly new to contour integration and complex analysis, which is why I wasn't able to understand why, using this technique, the upper limit of the sum changes from n to $\lfloor n/2 \rfloor$. The user specified a condition that if $n-2k\geq0$ (which means the max value of k would be $\lfloor n/2 \rfloor$), they would close the contour in the upper half-plane. But why?
Thanks!
 A: These are the steps to solve the improper integral
$$\int_\mathbb R \frac{e^{i ax}}{(x-i \epsilon)^{n}} dx, \tag{$\ast$}$$
where $a = n-2k$.
We consider the domain of integration $\mathbb R$ as a subset of $\mathbb C$, also extending the integrand to all complex $z$. Just substitute $z$ for $x$ in $(*)$. For now, we move the singularity at $z=0$ in the integrand "up a notch" in the complex plane to $z = i\epsilon$, so that there are no convergence issues.
Since the original integration goes from $x=-\infty$ to $x=\infty$, in the complex plane this corresponds to a line integral over the whole real line. We approximate this integral as a line integral on the real line from some $-R$ to $R$, remembering at the end of the calculation to send $R \to \infty$.
Before taking this limit, however, supposing $a \geq 0$, we can "close off" the contour in the upper half-plane, by adding a semicircle of radius $R$ centered at the origin. This has the advantage that the $n$-th order pole of the integrand at $x=i\epsilon$ is enclosed in the interior of the closed contour. Does the semicircle change the value of the integral? Not in the limit as $R \to \infty$, since as we go "upward" in the complex plane the integrand function "dies off" fast enough. (The precise statement of this is called Jordan's lemma.)
Therefore, the integral may be calculated in this case ($a \geq 0$) by calculating the residue at $i\epsilon$, multiplying it by $2\pi i$, then sending $R \to \infty$ and $\epsilon \to 0$. (Only the latter limit will matter.)
If $a < 0$, instead, it is more convenient to close the contour off in the opposite direction, because now the integrand dies off in the lower half-plane. But as there are no poles below the real line (the integrand is holomorphic on everywhere but $z = i\epsilon$), integral $(*)$ vanishes.
Thus we have found that integral $(*)$ does not vanish only when $n \geq 2k$, or $k \leq \lfloor n/2 \rfloor$. This is the reason why one may truncate the sum in the original answer.
A: The key observation here is as follows: if $z = a + ib$ with $a,b\in \Bbb R$, then $e^{itz} = e^{-tb+ita}$ and hence $|e^{itz}| = e^{-tb}$, where $t\in \Bbb R$.
In order for the countour integration to work, we want the integral in the circular arc to vanish as the radius goes to infinity, so that only the integral along the real line remains.
This means that
$$\left|\frac{e^{iz(n-2k)}}{z^n}\right|$$
must approach $0$ as the radius goes to infinity.
If $t = n-2k\geqslant 0$, then the observation above guarantees that the semi-circular arc in the upper half-plane does the job, because in this case $|e^{iz(n-2k)}|$ remains bounded.
If $t = n-2k<0$, then the situation is reversed, and we must take the semi-circular arc in the lower half-plane to ensure boundedness.
A: If $z$ is in the upper half plane, then $|e^{iz}|\leq 1$.  This is what allows us to control the contour integral as $R\to\infty$.
In this case, you want to bound $e^{iz(n-2k)},$ which means we want $z(n-2k)$ to be in the upper half plane.  This means $z$ should be in the upper half plane if $n-2k\geq 0$ and $z$ should be in the lower half plane otherwise.
That is, the contours will be semicircles, but they depend on $k$.  That is, if $2k\leq n$ then it will be in the upper half plane while if $2k > n$ it will be in the lower half plane.
