Improper integral $\int_{-\infty}^\infty \frac{1}{x^n + 1}$ for $n$ integer, especially $n$ odd The exercise is to analyze the integral $\int_{-\infty}^\infty \frac{1}{x^n + 1}$ for $n$ integer.
For $n$ even, the integrand is well defined, and I discovered that the integral converges in this case.
My problem is analysing the $n$ odd case. The problem arises because for $x=-1$ the integrand is not defined. This way, I tried breaking the integral in:
$\int_{-\infty}^{-A} \frac{1}{x^n + 1}$ + $\int_{-A}^{-1} \frac{1}{x^n + 1}$ + $\int_{-1}^B \frac{1}{x^n + 1}$+ + $\int_{B}^{\infty} \frac{1}{x^n + 1}$
I tried analysing these integrals, but was unable to proceed.
When I asked to fiends, I heard things like Cauchy principal value, but this exercise was from my course of calculus for engineers, so I was looking for a simple study of improper integrals like this one.
 A: For the case of odd $n$,
$$I_n= \int_{-\infty}^\infty \frac{1}{x^n + 1}=\int_0^\infty \frac{2dt}{1-t^{2n}}= \frac2n \int_0^\infty \frac{t^{\frac1n-1}}{1-t^{2}}dt 
$$
It is known that the $PV \int_0^\infty \frac{t^adt}{1-t^2} = \frac\pi2 \tan\frac{\pi a}2$ (See here, for example.) Thus, the principal value for odd $n$ is
$$I_n = \frac\pi n \cot\frac{\pi}{2n}, \>\>\>\>\> n: \>odd$$
For completeness,
$$I_n = \frac{2\pi}n \csc\frac{\pi}{n}, \>\>\>\>\> n: \>even$$
A: It can be shown using the residue theorem from complex analysis that
$$I_n = \int_{-\infty}^{\infty} \frac{1}{x^{2n}+1} =\frac{\pi}{n\sin\left(\frac{\pi}{2n}\right)}.$$
See here for a better explanation than I could hope to give.
A: Let
\begin{equation}
I=\int\limits_{-\infty}^{+\infty} \frac{1}{x^{n}+1}\,dx
\end{equation}
for some  positive integer $n$. For any odd positive integer, the integral diverges, so we will only have to compute the case for even positive integers. Given that $n$ is even, we can write the integral as follows:
\begin{equation}
I=2\int\limits_{0}^{+\infty} \frac{1}{x^{n}+1}\,dx
\end{equation}
This integral can be expressed in terms of the beta function. Let $z=\frac{1}{x^{n}+1}$, which implies that $dx=-\frac{1}{n}\left(\frac{1}{z}-1\right)^{\frac{1}{n}-1}z^{-2}\,dz$. Plugging everything in leaves us with:
\begin{equation}
I=\frac{2}{n}\int\limits_{0}^{+\infty} z\left(\frac{1}{z}-1\right)^{\frac{1}{n}-1}z^{-2}\,dz
\end{equation}
\begin{equation}
I=\frac{2}{n}\int\limits_{0}^{+\infty} \left(\frac{1-z}{z}\right)^{\frac{1}{n}-1}z^{-1}\,dz
\end{equation}
\begin{equation}
I=\frac{2}{n}\int\limits_{0}^{+\infty} z^{-1}\left(1-z\right)^{\frac{1}{n}-1}z^{1-\frac{1}{n}}\,dz
\end{equation}
\begin{equation}
I=\frac{2}{n}\int\limits_{0}^{+\infty} z^{-\frac{1}{n}}\left(1-z\right)^{\frac{1}{n}-1}\,dz
\end{equation}
The last integral is equal to $B\left(1-\frac{1}{n},\frac{1}{n}\right)$, so:
\begin{equation}
I=\frac{2}{n}B\left(1-\frac{1}{n},\frac{1}{n}\right)
\end{equation}
Let $s=1/n$, which implies that:
\begin{equation}
I=\frac{2}{n}B\left(1-s,s\right)
\end{equation}
Using the definition of the beta function in terms of the gamma function:
\begin{equation}
I=\frac{2}{n}B\left(1-s,s\right)=\frac{2}{n}\frac{\Gamma(1-s)\Gamma(s)}{\Gamma(1)} = \frac{2}{n}\Gamma(1-s)\Gamma(s)
\end{equation}
From Euler's reflection formula, we conclude that for even $n$:
\begin{equation}
\boxed{I=\int\limits_{-\infty}^{+\infty} \frac{1}{x^{n}+1}\,dx=\frac{2\pi}{n\sin\left(\frac{\pi}{n}\right)}}
\end{equation}
