Ever since my exposure to [this integral](https://math.stackexchange.com/questions/958624/prove-that-int-01-sin-pi-xxx1-x1-x-dx-frac-pi-e24?lq=1) 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!



$\pi e$ and an unfamiliar polynomial
Ahhh, I see where something went "off":


Consider 


$$f(z) = \exp{\left( i \pi q z+ (m+qz)\log(z) + q(1-z)\log(1-z)\right)} $$


where $m$ is a non-negative integer and $q$ is a integer. Using the exact same branch cuts and contour (just about every single piece of information stays true, with the exception of some algebraic manipulation), we have


$$\int\_{\Gamma\_1} f(z) \ dz = \int\_0^1 x^m e^{-i\pi qx} \left(x^x (1-x)^{1-x}\right)^q \ dx $$


and 
$$\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 $$


This $f$ is bounded, so it remains that the circles around the singularities will vanish. We have then


$$\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}\right) \left(x^x (1-x)^{1-x}\right)^q\ dx $$


$$= 2i\int\_0^1 x^m \sin\left(\pi q x\right) \left(x^x (1-x)^{1-x}\right)^q\ dx $$


We have the following Laurent series for this $f(z)$:


$$f(z) = (-1)^{q+1} e^q \sum\_{n=0}^\infty \frac{b\_n(q)}{z^{n-q-m}}$$


Applying the same residue at infinity calculations, and applying Cauchy's residue theorem, we finally have


$$ \int\_0^1 x^m \sin\left(\pi q x \right) \left(x^x (1-x)^{1-x}\right)^q\ dx = (-1)^{q+1} \pi e^{q} b\_{m+q+1}(q).$$


and we are done.


