Ever since my exposure to this integral involving $\pi e$, I've conjectured and set about evaluating the possible nature of the following integral

$$\int_0^1 x^m \sin(\pi x) x^x (1-x)^{1-x} \ dx, \quad m = 0, \, 1, \, 2, \, 3, \dots$$

**Observations**

I've inputted a few values in WolframAlpha and NumberEmpire engine, and I discovered this interesting beauty:

\begin{align} f_q{(x)} = \begin{cases} -\left(\frac{1}{e}(1-x)^{1-\frac{1}{x}} \right)^q, & x\neq 0 \\ -1, & x = 0 \end{cases} = \sum_{n = 0}^{\infty} b_n{(q)} x^n \end{align}

By using clever manipulation (Putnam style), a recurrence relation was derived for the coefficients of $f_q(x)$, namely

\begin{align} b_n{(q)} = -\frac{q}{n} \sum_{k=1}^{n} \frac{b_{n-k}{(q)}}{k+1}, \; \; b_0{(q)} = -1. \end{align} $b_n{(q)}$ generates the following polynomials

\begin{align*} b_0{(q)} &= -1 \\ b_1{(q)} &= \frac{q}{2} \\ b_2{(q)} &= \frac{-3q^2+4q}{24} \\ b_3{(q)} &= \frac{q^3-4q^2+4q}{48} \\ b_4{(q)} &= \frac{-15q^4+120q^3-320q^2+288q}{5760} \\ b_5{(q)} &= \frac{3q^5-40q^4+200q^3-448q^2+384q}{11520} \\ b_6{(q)} &= \frac{-63q^6+1260q^5-10080q^4+40544q^3-82656q^2+69120q}{2903040} \\ b_7{(q)} &= \frac{9q^7-252q^6+2940q^5-18368q^4+65184q^3-125568q^2+103680q}{5806080} \\ \vdots \end{align*}

Interestingly, the denominators seem to obey a more-or-less known sequence, brought about by Manjul Bhargava's work "The Factorial Function and Generalizations", although proving the connection between the two isn't easy, or at least isn't obvious.

Thus, based on the nature of the $b_n(q)$, I was then prompted to consider this generalization:

$$I_m(q) = \int_0^1 x^m \sin(\pi x) (x^x (1-x)^{1-x})^q \ dx$$ for non-negative integer $m$ and real $q$.

**Evaluating the Integral**

Looking back in the forum where I found the integral, I set about to apply the same "dumbbell" contour used for a simple case, first considering the following function

$$f(z) = \exp{(-i\pi q z+(m+qz)\log(z) + q(1-z)\log(1-z))} $$ and defining branch cuts for the logarithms, specifically

$$z^{m+qz} = \exp{((m+qz)\log(z))}, \quad -\pi \leq \arg(z) < \pi $$ $$(1-z)^{q(1-z)} = \exp{(q(1-z)\log(1-z))}, \quad 0 \leq \arg(1-z) < 2\pi $$

Now, since $f(z)$ is continuous on $(-\infty, 0)$ and $(1, \infty)$, our given cut is $[0,1]$, with singularities at $z = 0, \, 1$; thus, the "dumbbell" contour, which we define as $\Gamma$, would consist of

- $\Gamma_1$: Line segment slightly above $[0,1]$
- $\Gamma_2$: Line segment slightly below $[0,1]$
- $\Gamma_3$: Circle of small radius enclosing $z = 0$
- $\Gamma_4$: Circle of small radius enclosing $ z= 1$

If done properly, for $\Gamma_1$, with $0 \leq x \leq 1$, we have

$$\int_{\Gamma_1} f(z) \ dz = \int_0^1 x^m e^{i\pi(-qx+2q(1-x))} \left(x^x (1-x)^{1-x}\right)^q \ dx $$

For $\Gamma_2$, with $0 \leq x \leq 1$, we have $$\int_{\Gamma_2} f(z) \ dz = \int_0^1 x^m e^{-i\pi qx} \left(x^x (1-x)^{1-x}\right)^q \ dx $$

Since $f$ is bounded, the radius will tend to zero, so thus $$\int_{\Gamma_3} f(z) \ dz = \int_{\Gamma_4} f(z) \ dz = 0$$

Thus, we have

$$\int_{\Gamma} f(z) \ dz = \int_{\Gamma_2} f(z) \ dz - \int_{\Gamma_1} f(z) \ dz $$

$$\int_0^1 x^m \left(e^{-i\pi qx} - e^{i\pi(-qx+2q(1-x))}\right) \left(x^x (1-x)^{1-x}\right)^q\ dx $$

$$= -2ie^{i\pi q}\int_0^1 x^m e^{-2\pi i qx} \sin\left(\pi q (1-x) \right) \left(x^x (1-x)^{1-x}\right)^q\ dx $$

On the other hand, with residue at infinity calculations, we have

$$\int_{\Gamma} f(z) \ dz = 2 \pi i \mathrm{Res}_{z = 0} \frac{1}{z^2} f\left( \frac{1}{z} \right)$$

Now $f(z)$ has the following Laurent series expansion

$$\frac{1}{z^2} f\left( \frac{1}{z} \right) = -e^{q(1-\pi i)} \sum_{n=0}^{\infty} b_n(q) z^{n-(q+m+2)}$$

Thus, by the Cauchy residue theorem,

$$\int_{\Gamma} f(z) \ dz = 2 \pi i \mathrm{Res}_{z = 0} \frac{1}{z^2} f\left( \frac{1}{z} \right) = -2 \pi i e^{q(1-\pi i)} b_{m+q+1}(q)$$ where we are restricting $q$ to be an integer (unfortunately).

Thus, with some manipulations, our final result is

$$ \int_0^1 x^m e^{2\pi i q(1-x)} \sin\left(\pi q (1-x) \right) \left(x^x (1-x)^{1-x}\right)^q\ dx = \pi e^{q} b_{m+q+1}(q).$$

I can't help but look at this and think I've done goofed somewhere---something isn't right. The $e^{2\pi i q(1-x)} $ term especially bugs me; I've attempted comparing real and imaginary components, to no avail. Maybe I didn't pick the best contour? $f(z)$?

Your input is much appreciated!