We want to compute the integral \(I=\int_0^\infty \frac{dx}{x^n + 1 }\) where \(n\) is an integer. As it is typically done, we first upgrade real valued parameter \(x\) to a complex number \(z\), and define \(f(z)\): \[\begin{equation} f(z)\equiv\frac{1}{z^n +1}.\tag{1} \end{equation}\] \(f(z)\) has \(n\) poles at \(z_k=e^{\frac{\pi i (1+2k)}{n}}\) with \(0\leq k<n\).
Let’s be extravagant and solve the problem with three different methods.
A sneaky method
We need to decide on the complex contour. It needs to include the real line from \(0\) to \(\infty\), and we need to come back to \(0\) to close the loop. Since we have \(x^n\) term, if we return to the origin at an angle of \(\frac{2\pi}{n}\), i.e., \(z=r e^{\frac{2\pi i}{n}}\) , the \(n^\text{th}\) power will remove the phase and will leave behind \(r^n\). So, we can try the contour in Fig 2.\[\begin{eqnarray} \oint f(z)dz &=& \int_{\gamma_0} dz f(z)+\int_{\gamma_R} dz f(z)+\int_{\gamma_1} dz f(z)= 2\pi i \text{Res}(f,z_1)\nonumber\\ &=& \int_0^R \frac{dx}{x^n + 1 }+ i\int_0^{\frac{2\pi}{n}} d\theta e^{i\theta}\frac{R}{R^n e^{in\theta}+ 1 }+e^{i\frac{2\pi}{n}}\int_R^0 \frac{dx}{x^n + 1 }\nonumber\\ &=& (1-e^{i\frac{2\pi}{n}}) \int_0^R \frac{dx}{x^n + 1 }+ i\int_0^{\frac{2\pi}{n}} d\theta e^{i\theta}\frac{R}{R^n e^{in\theta}+ 1 }. \tag{2} \end{eqnarray}\] It is easy to show that the angle integral will vanish as \(R\rightarrow\infty\). This is because \(\left|\frac{R}{R^n e^{in\theta}+ 1 }\right|\rightarrow \frac{1}{R^{n-1} }\rightarrow 0\) for large \(R\). We can simplify the factor in front of the integral as follows: \[\begin{eqnarray} (1-e^{i\frac{2\pi}{n}})=e^{i\frac{\pi}{n}}\left(e^{-i\frac{\pi}{n}}-e^{i\frac{\pi}{n}}\right)=-2i e^{i\frac{\pi}{n}} \sin(\frac{\pi}{n}). \tag{3} \end{eqnarray}\] Putting it back into Eq. (2) gives \[\begin{eqnarray} \int_0^\infty \frac{ dx}{x^n + 1 }=-\frac{\pi \text{Res}(f,z_1)}{e^{i\frac{\pi}{n}} \sin(\frac{\pi}{n})}. \tag{4} \end{eqnarray}\] All there is left is to compute the residue of \(f(z)\) at \(z=z_1=e^{\frac{i\pi}{n}}\): \[\begin{eqnarray} \text{Res}(f,z_1)=\lim_{z\rightarrow z_1}\frac{z-z_1}{z^n+1}=\lim_{z\rightarrow z_1}\frac{1}{\frac{d}{dz}(z^n+1)}=\frac{1}{n z_1^{n-1}}=\frac{e^{\frac{-i\pi(n-1)}{n}}}{n}, \tag{5} \end{eqnarray}\] where we used L’Hôpital’s rule. Inserting the result into Eq. (4) we get \[\begin{eqnarray} \int_0^\infty \frac{dx}{x^n + 1 }=-\frac{\pi e^{\frac{-i\pi(n-1)}{n}}}{e^{i\frac{\pi}{n}} n \sin(\frac{\pi}{n})}=\frac{\pi}{ n\sin(\frac{\pi}{n})}, \tag{6} \end{eqnarray}\] which is the final answer.
A typical method
When \(n\) is even, we can extend the lower limit of the integral from \(0\) to \(-\infty\) and divide the result by \(2\). We can try the contour in Fig 3.It may look like we got ourselves into a lot of work as we will need to compute all the residues for the poles in the upper half and add them up. Maybe, it won’t be as hard as it looks. We do this for fun, anyways. One trick we will use is this: since \(z_j^n+1=0\), we have \(z_j^{n-1}=\frac{z_j^n}{z_j}=-\frac{1}{z_j}\) \[\begin{eqnarray} I&=& i \pi \sum_{j=0}^{\frac{n}{2}-1}\text{Res}(f,z_j)=-i \pi \sum_{j=0}^{\frac{n}{2}-1}\frac{1}{nz_j^{n-1}}=-i \pi \sum_{j=0}^{\frac{n}{2}-1}z_j =-ie^{\frac{\pi i}{n}}\frac{\pi}{n} \sum_{j=0}^{\frac{n}{2}-1}e^{\frac{2 \pi i j}{n}} =-ie^{\frac{\pi i}{n}} \frac{\pi}{n} \frac{1-e^{\frac{2 \pi i n/2}{n}}}{1-e^{\frac{2 \pi i}{n}}}\nonumber\\ &=& \frac{\pi}{n}\frac{2}{ie^{\frac{-\pi i}{n}}(1-e^{\frac{2 \pi i}{n}})} =\frac{\pi}{n}\frac{2}{i(e^{\frac{-\pi i}{n}}-e^{\frac{ \pi i}{n}})}=\frac{\pi}{n}\frac{2}{2 sin(\frac{\pi}{n})}=\frac{\pi}{ n\sin(\frac{\pi}{n})} \tag{7} \end{eqnarray}\]