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.
 A: Another approach
$$
\begin{align}
\int\limits_{-\infty}^{+\infty}\frac{x^2 e^x}{(1+e^x)^2}dx
&=\lim\limits_{a\to 0}\int\limits_{-\infty}^{+\infty}\frac{x^2 e^{(a+1)x}}{(1+e^x)^2}dx\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}\int\limits_{-\infty}^{+\infty}\frac{e^{(a+1)x}}{(1+e^x)^2}dx\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}\int\limits_{0}^{+\infty}\frac{t^a}{(1+t)^2}dt\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}B(1+a,1-a)\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}\frac{\Gamma(1+a)\Gamma(1-a)}{\Gamma(2)}\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}a\Gamma(a)\Gamma(1-a)\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}\pi a\csc(\pi a)\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}\pi a\left(\frac{1}{\pi a}+\frac{\pi a}{6}+o(a)\right)\\
&=\lim\limits_{a\to 0}\frac{d^2}{da^2}\left(1+\frac{\pi^2 a^2}{6}+o(a^2)\right)\\
&=\frac{\pi^2}{3}
\end{align}
$$
A: Slightly more generally, consider 
$$J(P,R) = \oint_\Gamma \frac{P(z)\; e^z\; dz}{(1+e^z)^2}$$
where $P$ is a polynomial and $\Gamma$ is the positively oriented rectangular contour from $-R$ to $R$ to $R+2\pi i$ to $-R+2\pi i$.  Then $J(P,R) = 2 \pi i \text{Res}(P(z)\; e^z/(1+e^z)^2,z=\pi i) = - 2 \pi i P'(\pi i)$. 
On the other hand, it is easy to see that the contributions to the integral from the vertical sections go to $0$ as $R \to \infty$, and
$$ \lim_{R \to \infty} J(P,R) = \int_{-\infty}^\infty \frac{(P(x) - P(x+2\pi i)) e^x}{(1+e^x)^2}\ dx$$
Now $P(x) - P(x + 2 \pi i) = x^2$ for $P(z) = -\dfrac{\pi i}{3} x + \dfrac{1}{2} x^2 + \dfrac{i}{6 \pi} x^3$,  which makes $- 2 \pi i P'(\pi i) = \dfrac{\pi^2}{3}$.
A: $$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$$
A: In a more general setting, let $$F\left( s \right) = \int\limits_0^\infty  {\frac{{{x^{s - 1}}}}{{{{\left( {{e^x} + 1} \right)}^2}}}{e^x}dx} $$
We have, whenever $|e^{-x}|<1$, that is, for $x>0$, that
$$\frac{1}{{1 + {e^{ - x}}}} = \sum\limits_{k = 0}^\infty  {{{\left( { - 1} \right)}^k}{e^{ - kx}}} $$
and convergence is uniform. Thus
$$\frac{{{e^{ - x}}}}{{{{\left( {1 + {e^{ - x}}} \right)}^2}}} = \frac{d}{{dx}}\frac{1}{{1 + {e^{ - x}}}} = \sum\limits_{k = 0}^\infty  {{{\left( { - 1} \right)}^k}\frac{d}{{dx}}{e^{ - kx}}}  = \sum\limits_{k = 1}^\infty  {{{\left( { - 1} \right)}^{k + 1}}k{e^{ - kx}}} $$
Note that after multipication and division by $e^{2x}$ one gets $$\frac{{{e^x}}}{{{{\left( {1 + {e^x}} \right)}^2}}} = \sum\limits_{k = 1}^\infty  {{{\left( { - 1} \right)}^{k + 1}}k{e^{ - kx}}} $$ 
Thus $$\frac{{{e^x}{x^{s - 1}}}}{{{{\left( {1 + {e^x}} \right)}^2}}} = \sum\limits_{k = 1}^\infty  {{{\left( { - 1} \right)}^{k + 1}}k{e^{ - kx}}{x^{s - 1}}} $$
Now, we look at individual terms
$$\int\limits_0^\infty  {{e^{ - kx}}{x^{s - 1}}dx}  = \frac{1}{{{k^s}}}\int\limits_0^\infty  {{e^{ - kx}}{{\left( {kx} \right)}^{s - 1}}d\left( {kx} \right)}  = \frac{1}{{{k^s}}}\int\limits_0^\infty  {{e^{ - u}}{u^{s - 1}}du}  = \frac{1}{{{k^s}}}\Gamma \left( s \right)$$
Thus$$\tag 1 \int\limits_0^\infty  {\frac{{{e^x}{x^{s - 1}}}}{{{{\left( {1 + {e^x}} \right)}^2}}}}  = \Gamma \left( s \right)\sum\limits_{k = 1}^\infty  {{{\left( { - 1} \right)}^{k - 1}}\frac{1}{{{k^{s-1}}}}}  = \Gamma \left( s \right)\eta \left( s-1 \right)$$
Specializing for $s=3$, we get:
$$\int\limits_0^\infty  {\frac{{{e^x}{x^2}}}{{{{\left( {1 + {e^x}} \right)}^2}}}}  = \Gamma \left( 3 \right)\eta \left( 2 \right) = 2!\frac{{{\pi ^2}}}{{12}} = \frac{{{\pi ^2}}}{6}$$
so that$$\int\limits_{ - \infty }^\infty  {\frac{{{e^x}{x^2}}}{{{{\left( {1 + {e^x}} \right)}^2}}}}  = 2\frac{{{\pi ^2}}}{6} = \frac{{{\pi ^2}}}{3}$$
You might be interested in this question of mine where I wonder about integrals of the form $$\int\limits_0^\infty  {F\left( {\frac{1}{{{e^x} - 1}},{e^x},{x^s}} \right)dx} $$
and provide some similar expressions to $(1)$.
