Integrate $\int_{-\infty}^{\infty} \frac{\cosh(\beta x)}{1+\cosh( \beta x )} e^{-x^2} x^2 \rm{d}x$

I have some idea, if you are willing to take into account something different by residues, and if you are willing to proceed by your own adopting some tricks in the same way I will do (this message refers to the part $2$ of what I will do in a while. I'll show you my ideas for part $1$ only).

Starting with writing $\cosh$ in exponential form, and arranging:

$$\int_{-\infty}^{+\infty} \frac{e^{\beta x} + e^{-\beta x}}{2 + e^{\beta x} + e^{-\beta x}}e^{-x^2} x^2\ \text{d}x$$

Now we split the integral into the one from $[0, +\infty)$ and $(-\infty, 0]$. I'll do the first one, then for the second one there will be surely similar methods. Use your fantasy.

I collect a tern $e^{\beta x}$ for the integrand, above and below:

$$\int_0^{+\infty} \frac{1 + e^{-2\beta x}}{1 + 2e^{-\beta x} + e^{-2\beta x}}e^{-x^2} x^2\ \text{d}x$$

Now I use the Geometric Series

$$\frac{1}{1 + 2e^{-\beta x} + e^{-2\beta x}} = \sum_{k = 0}^{+\infty}\left(-2e^{-\beta x} - e^{-2\beta x}\right)^k$$

Inserting and arranging a bit:

$$\sum_{k = 0}^{+\infty}(-1)^k \int_0^{+\infty}(1 + e^{-2\beta x})e^{-x^2} x^2 e^{-\beta k x}(2 + e^{-\beta x})^k\ \text{d}x$$

Binomial theorem will help now:

$$(2 + e^{-\beta x})^k = \sum_{j = 0}^{k} \binom{k}{j}2^k\ \left(e^{-\beta x}\right)^{k-j}$$

namely

$$\sum_{k = 0}^{+\infty}\sum_{j = 0}^{k}(-1)^k\binom{k}{j}2^k\int_0^{+\infty}(1 + e^{-2\beta x})e^{-x^2} x^2e^{-\beta k x}\ \text{d}x$$

Arranging a little bit

$$\sum_{k = 0}^{+\infty}\sum_{j = 0}^{k}(-1)^k 2^k \binom{k}{j}\int_0^{+\infty}x^2(1 + e^{-2\beta x})e^{-\beta x(k-j)}e^{-x^2}e^{-\beta k x}\ \text{d}x$$

From this point we can split the integral in the two terms: $A_1$ and $A_2$, and compute their values:

$$A_1 = \int_0^{+\infty}x^2 e^{-\beta x (k-j)}e^{-x^2 - \beta k x}\ \text{d}x$$

$$A_2 = \int_0^{+\infty}x^2 e^{-\beta x (k - j + 2\beta)}e^{-x^2 - \beta k x}\ \text{d}x$$

Now, proceeding with $A_1$, we can arrange better the exponentials collecting $x$ terms:

$$A_1 = \int_0^{+\infty}x^2 e^{-x^2 - x[2\beta k - \beta j]}\ \text{d}x$$

$$A_1 = \int_0^{+\infty}x^2 e^{-x^2 - Bx}\ \text{d}x$$

This is a well known integral, whose result is

$$ \int_0^{+\infty}x^2 e^{-x^2 - Bx}\ \text{d}x = \frac{1}{8}\left(-2B + (2 + B^2)e^{B^2/4}\sqrt{\pi}\text{Erfc}\left(\frac{B}{2}\right)\right)$$

Where of course $B = 2\beta k - \beta j$.

In the same way we have for $A_2$:

$$A_2 = \int_0^{+\infty}x^2 e^{-\beta x (k - j + 2\beta)}e^{-x^2 - \beta k x}\ \text{d}x$$

$$A_2 = \int_0^{+\infty}x^2 e^{-x^2 - x[2\beta k - \beta j + 2\beta^2]}\ \text{d}x$$

$$A_2 = \int_0^{+\infty}x^2 e^{-x^2 - Cx}\ \text{d}x$$

Which again is like before:

$$\int_0^{+\infty}x^2 e^{-x^2 - Cx}\ \text{d}x = \frac{1}{8}\left(-2C + (2 + C^2)e^{C^2/4}\sqrt{\pi}\text{Erfc}\left(\frac{C}{2}\right)\right)$$

Where of course $C = 2\beta k - \beta j + 2\beta^2$.

The end of (this part of) the story is:

$$\sum_k \sum_j A_1(k, j) + A_2(k, j)$$

$$\sum_{k = 0}^{+\infty}\sum_{j = 0}^{k}(-1)^k 2^k \binom{k}{j} \frac{1}{8}\left[-2B + (2 + B^2)e^{B^2/4}\sqrt{\pi}\text{Erfc}\left(\frac{B}{2}\right) -2C + (2 + C^2)e^{C^2/4}\sqrt{\pi}\text{Erfc}\left(\frac{C}{2}\right)\right]$$

You can eventually try to calculate it with some software. I tried with Mathematica but I believe my computer is not that powerful to perform such a calculation..

Then the other part of the integral can be manipulated similarly I guess. Give it a try.

In the meanwhile I'll watch a Supernatural new episode. I leave my computer trying to calculate, maybe we get some spider out of the hole.