Find the integral of $\frac{x^n}{(\exp(x)+1)(\exp(-x)+1)}$

complex-analysiscontour-integrationintegrationresidue-calculus

I need to find the integral $$I = \int_{-\infty}^\infty \frac{x^n}{(\exp(x)+1)(\exp(-x)+1)}dx.$$

I think this should be possible with the residue theorem, but I got stuck.
So first of all the integral is zero if n is odd, since then it is an odd integrand integrated over a symmetric interval.

My choice for the complex contour is a rectangle with sidelength $2R$ (on the real axis) and the other $2\pi i$, because the denominator is the same for $x \rightarrow x+2\pi i$ and $I = \lim_{R\rightarrow \infty} \int_{\gamma_1}f(z)dz$.

  1. I define the contour $\gamma = \gamma_1 + \gamma_2 + \gamma_3 + \gamma_4$, where $\gamma_1$ and $\gamma_3$ are the two long, horizontal sides (with length $2R$) and $\gamma_2$ and $\gamma_4$ the two vertical ones. Then there is one pole of order 2 inside the region of integration at $z_0 = i\pi$.

  2. $\int_{\gamma_2} f(z)dz + \int_{\gamma_4}f(z)dz = \int_0^{2\pi i} \frac{(t+R)^n}{(\exp(t+R)+1)(\exp(-t-R)+1)}dt – \int_0^{2\pi i} \frac{(-t+2\pi i-R)^n}{(\exp(-t-R)+1)(\exp(+t+R)+1)}dt = 0 + 0$ individually when $R\rightarrow \infty$.

  3. Now this is where I got stuck. I want to relate the integral over $\gamma_3$ to the integral over $\gamma_1$. For this I tried to rearange
    $$\begin{align}
    \int_{\gamma_3}f(z)dz &= -\int_{-R}^{R}\frac{(-t+2\pi i)^n}{(\exp(t) + 1)(\exp(-t)+1)}dt \\
    \\
    &= -\sum_{k=0}^n \binom{n}{k}\cdot\int_{-R}^R\frac{(-t)^k(2\pi i)^{n-k}}{(\exp(t)+1)(\exp(-t)+1)}dt \\
    \\
    &=
    -\sum_{k=0}^n \binom{n}{k}\cdot(2\pi i)^{n-k}\cdot I_k
    \end{align}$$

    where I defined $I_k = \int_{\gamma_1}f(z)dz$.

Now I don't know how to proceed from here. Is there a way I can solve this recursive formula or do I is there maybe a completely different way of solving this?

Best Answer

$$J(n)=\int_{-\infty}^\infty \frac{x^n}{(e^x+1)(e^{-x}+1)}dx=\frac{(2\pi)^n\pi}{2}\int_{-\infty}^\infty\frac{x^n}{\cosh^2\pi x}dx$$ $$=\frac{(2\pi)^n\pi}{2}\frac{\partial^n}{\partial \alpha^n}\Big|_{\alpha=0}\int_{-\infty}^\infty\frac{e^{\alpha x}}{\cosh^2\pi x}dx=\frac{(2\pi)^n\pi}{2}\frac{\partial^n}{\partial \alpha^n}I(\alpha)\Big|_{\alpha=0}$$ The integral $\displaystyle I(\alpha)=\int_{-\infty}^\infty\frac{e^{\alpha x}}{\cosh^2\pi x}dx$ is well-known and can be evaluated, for example, via complex integration.

Consider the following rectangular contour enter image description here

and the integral along it gives $$\oint\frac{e^{\alpha z}}{\cosh^2\pi z}dz=I(\alpha)+[1]-I(\alpha)e^{i\alpha}+[2]=2\pi i\underset{z=\frac{i}{2}}{\operatorname{Res}}\frac{e^{\alpha z}}{\cosh^2\pi z}$$ because we have a single second order pole inside the contour. Integrals $[1]$ and $[2]$ tend to zero, as $R\to\infty$. Near $z=\frac{i}{2}$ we have $$\frac{e^{\alpha \frac{i}{2}+\epsilon}}{\cosh^2\pi(\frac{i}{2}+\epsilon)}=\frac{e^{i\frac{\alpha}{2}}}{-\pi^2\epsilon^2}\big(1+\alpha\epsilon+O(\epsilon^2)\big)$$ so, the residue is $\displaystyle -\,\frac{\alpha e^{i\frac{\alpha}{2}}}{\pi^2}$ $$I(\alpha)\big(1-e^{i\alpha}\big)=-\frac{2i\alpha}{\pi}e^{i\frac{\alpha}{2}}\,\,\Rightarrow\,\,\boxed{\,I(\alpha)=\frac{\alpha}{\pi\sin\frac{\alpha}{2}}\,}$$ $$J(n)=\frac{(2\pi)^n\pi}{2}\frac{\partial^n}{\partial \alpha^n}I(\alpha)\Big|_{\alpha=0}=\boxed{\,\pi^n\frac{d^n}{dx^n}\bigg(\frac{x}{\sin x}\bigg)\Big|_{x=0}\,}$$ Following the suggestion by @Gary (https://dlmf.nist.gov/4.19#E4), the answer can be expressed via Bernoulli numbers (probably, this is the most compact form): $$\boxed{\,\,I(2k)= (-1)^{k-1}2\pi^{2k}(2^{2k-1}-1)B_{2k},\,\,\text{and}\,\,I(2k+1)=0;\,\, k=0, 1, 2, ...\,\,}$$


Quick check: at $n=0\,\, J(0)=\pi^0=1$

On the other hand, $\displaystyle J(n=0)=\int_0^\infty\frac{dt}{\cosh^2t}=\tanh t\Big|_0^\infty=1$

Related Question