# How to evaluate $\int_0^\infty \frac{1}{x^n+1} dx$ [duplicate]

Noticed that the integral $$\int_0^\infty \frac{1}{x^n+1} dx$$ is often approached with partial fraction decomposition, but this gets increasingly ugly as $n$ gets bigger. Is there a neat trick to do these all in one fell swoop? Or a famous name for these integrals that I can look up for more info?

## marked as duplicate by dustin, Jonas Meyer, OR., Joel Reyes Noche, Joe Johnson 126Mar 31 '15 at 1:16

This can also be done using complex variables when $n\ge 2.$ Use a pizza slice contour consisting of the line $\Gamma_1$ from zero to $R$ on the real axis, an arc $\Gamma_2$ along the circle $|z|=R$ from the real axis to $\theta = 2\pi/n$ and a line $\Gamma_3$ back to the origin parameterized by $z=\exp(2\pi i/n)t.$

Set $$f(z) = \frac{1}{z^n+1}$$ We integrate $f(z)$ around this contour and use the fact that the integral is equal to the residues times $2\pi i$ of the poles contained therein. Along $\Gamma_2$ we have $$|f(z)| \in \Theta(R^{-n})$$ so that the contribution is bounded by $$\frac{2\pi R}{n} \times R^{-n} \to 0$$ as $R\to\infty$ when $n\ge 2$ and the contribution from $\Gamma_2$ vanishes.

Along $\Gamma_1$ the integral goes to the value $I(n)$ being sought as $R\to\infty.$ Along $\Gamma_3$ we get in the limit $$\int_\infty^0 \frac{1}{(e^{2\pi i/n} t)^n + 1} e^{2\pi i/n} dt = - e^{2\pi i/n}\int_0^\infty \frac{1}{t^n+1} dt = - e^{2\pi i/n} I(n).$$

There is just one pole inside the pizza slice contour at $z=e^{i\pi/n}$ and we get $$I(n) (1 - e^{2\pi i/n}) = 2\pi i \times \mathrm{Res}\left(f(z); z=e^{i\pi/n}\right).$$

The pole is simple and hence the residue is $$\lim_{z\to e^{i\pi/n}}\frac{z-e^{i\pi/n}}{z^n+1} = \lim_{z\to e^{i\pi/n}}\frac{1}{n z^{n-1}} = \lim_{z\to e^{i\pi/n}}\frac{z}{n z^n} = \frac{e^{i\pi/n}}{n e^{i\pi}} = - \frac{e^{i\pi/n}}{n}.$$

This finally yields $$I(n) = - 2\pi i\frac{e^{i\pi/n}}{n(1 - e^{2\pi i/n})} = - 2\pi i\frac{1}{n(e^{-i\pi/n} - e^{\pi i/n})} \\ = \pi\frac{2i}{n(e^{\pi i/n} - e^{-i\pi/n})} = \frac{\pi}{n\sin(\pi/n)}.$$

The given integral indeed has a closed-form: $$\int_0^\infty\frac{1}{1+x^n}\ dx=\frac{\pi}{n\sin\left(\frac{\pi}{n}\right)}.$$ For the complete proof, you may refer to this OP: Prove $\int_0^{\infty}\! \frac{\mathbb{d}x}{1+x^n}=\frac{\pi}{n \sin\frac{\pi}{n}}$ using real analysis techniques only

Hint. You may recall the celebrated $\Gamma$ function defined by $$\Gamma(\alpha)=\int_0^\infty u^{\alpha-1} e^{-u}\:{\rm{d}}u, \quad \alpha>0$$ and you may write \begin{align} \int_0^\infty \frac{1}{x^n+1} \:{\rm{d}}x&=\int_0^\infty\int_0^\infty e^{-(x^n+1)t} \:{\rm{d}}t\:{\rm{d}}x \\&=\int_0^\infty e^{-t}\int_0^\infty e^{-x^n t} \:{\rm{d}}t\:{\rm{d}}x \\&=\int_0^\infty e^{-t}\left(\int_0^\infty e^{-x^n t}\:{\rm{d}}x\right)\:{\rm{d}}t \\&=\frac1n\int_0^\infty t^{-\frac1n}e^{-t}\left(\int_0^\infty u^{\frac1n-1} e^{-u}{\rm{d}}u\right)\:{\rm{d}}t \\&=\frac1n \Gamma\left(1-\frac1n\right)\Gamma\left(\frac1n\right) \\&=\frac{\pi}{n\sin \frac{\pi}{n}} \end{align}

$\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack} \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,} \newcommand{\dd}{{\rm d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,{\rm e}^{#1}\,} \newcommand{\fermi}{\,{\rm f}} \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{{\rm i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\pars}[1]{\left(\, #1 \,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}} \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,} \newcommand{\sech}{\,{\rm sech}} \newcommand{\sgn}{\,{\rm sgn}} \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$ \begin{align} &\overbrace{\color{#66f}{\large\int_{0}^{\infty}{\dd x \over x^{n} + 1}}} ^{\ds{\color{#c00000}{t \equiv {1 \over x^{n} + 1}\ \imp\ x = \pars{{1 \over t} - 1}^{1/n}}}}\ =\ \int_{1}^{0}t\,{1 \over n}\,\pars{{1 \over t} - 1}^{1/n - 1} \pars{-\,{1 \over t^{2}}}\,\dd t \\[5mm]&={1 \over n}\int_{0}^{1}t^{-1/n}\pars{1 - t}^{1/n - 1}\,\dd t ={1 \over n}\,{\rm B}\pars{1 - {1 \over n},{1 \over n}} ={1 \over n}\,{\Gamma\pars{1 - 1/n}\Gamma\pars{1/n} \over \Gamma\pars{1}} \\[5mm]&=\color{#66f}{\large{1 \over n}\,{\pi \over \sin\pars{\pi/n}}} \end{align}

The result is valid when $\ds{\Re\pars{1 - {1 \over n}} > 0}$ and $\ds{\Re\pars{1 \over n} > 0}$ $\ds{\imp\ \color{#c00000}{0 < \Re\pars{1 \over n} < 1}}$.