<s>[INST] How to evaluate this integral $\int_{-\infty}^{+\infty}\frac{x^2e^x}{(1+e^x)^2}dx$? I need to evaluate $$\int_{-\infty}^{+\infty}\frac{x^2e^x}{(1+e^x)^2}dx$$
I think the answer is $\frac{\pi^2}{3}$, but I'm not able to calculate it.
 [/INST] $$f(x) = \dfrac{x^2 \exp(x)}{(1+\exp(x))^2} = \dfrac{x^2 \exp(-x)}{\left(1 + \exp(-x) \right)^2}$$
Recall that
$$\dfrac{a}{(1+a)^2} = a -2a^2 + 3a^3 - 4a^4 + 5a^5 \mp \cdots = \sum_{k=1}^{\infty}(-1)^{k+1}k a^k$$
For $x > 0$, $$f(x) = x^2 \sum_{k=1}^{\infty} (-1)^{k+1} k \exp(-kx)$$
Now for $a > 0$, $$\int_0^{\infty} x^2 \exp(-ax) = \dfrac2{a^3}$$
Hence, $$\int_0^{\infty} f(x) dx = \sum_{k=1}^{\infty} (-1)^{k+1} \dfrac{2k}{k^3} = 2 \sum_{k=1}^{\infty} \dfrac{(-1)^{k+1}}{k^2} = \dfrac{\pi^2}6$$
Hence, $$\int_{-\infty}^{\infty} f(x) dx = 2 \int_0^{\infty} f(x) dx = \dfrac{\pi^2}3$$
</s>