Integral $\int\limits_0^1 {{{\left( {\frac{x}{{1 - x}}} \right)}^x}} \sin \left( {\pi x} \right)dx$ I am trying to calculate this integral:
$$I=\int\limits_0^1 {{{\left( {\frac{x}{{1 - x}}} \right)}^x}} \sin \left( {\pi x} \right)dx$$
And here is my try so far:
$$\begin{array}{l}
I = \int\limits_0^1 {{{\left( {\frac{x}{{1 - x}}} \right)}^x}} \sin \left( {\pi x} \right)dx = \Im \left[ {\int\limits_0^1 {{x^x}} {{\left( {1 - x} \right)}^{ - x}}{e^{i\pi x}}dx} \right] = \Im \left[ {\int\limits_0^1 {{e^{x\ln \left( x \right)}}} {e^{ - x\ln \left( {1 - x} \right)}}{e^{i\pi x}}dx} \right] = \Im \left[ {\int\limits_0^1 {{e^{x\left( {i\pi  + \ln \left( x \right) - \ln \left( {1 - x} \right)} \right)}}} dx} \right]\\
 = \Im \left[ {\int\limits_0^1 {{e^{x\left( {i\pi  + \ln \left( {\frac{x}{{1 - x}}} \right)} \right)}}} dx} \right],t = \ln \left( {\frac{x}{{1 - x}}} \right) \Rightarrow x = \frac{{{e^t}}}{{{e^t} + 1}} \Rightarrow dx = \frac{{{e^t}}}{{{{\left( {{e^t} + 1} \right)}^2}}}dt\\
 \Rightarrow I = \Im \left[ {\int\limits_{ - \infty }^{ + \infty } {{e^{\frac{{{e^t}}}{{{e^t} + 1}}\left( {i\pi  + t} \right)}}} \frac{{{e^t}}}{{{{\left( {{e^t} + 1} \right)}^2}}}dt} \right],z = i\pi  + t \Rightarrow dz = dt \Rightarrow I = \Im \left[ {\int\limits_{ - \infty  + i\pi }^{ + \infty  + i\pi } {{e^{\frac{{{e^{\left( {z - i\pi } \right)}}}}{{{e^{\left( {z - i\pi } \right)}} + 1}}z}}} \frac{{{e^{\left( {z - i\pi } \right)}}}}{{{{\left( {{e^{\left( {z - i\pi } \right)}} + 1} \right)}^2}}}dz} \right] = \Im \left[ {\int\limits_{ - \infty  + i\pi }^{ + \infty  + i\pi } {{e^{\frac{{ - {e^z}}}{{ - {e^z} + 1}}z}}} \frac{{ - {e^z}}}{{{{\left( { - {e^z} + 1} \right)}^2}}}dz} \right]\\
 = \Im \left[ { - \int\limits_{ - \infty  + i\pi }^{ + \infty  + i\pi } {\frac{{{e^{z\left( {\frac{{ - {e^z}}}{{ - {e^z} + 1}} + 1} \right)}}}}{{{{\left( { - {e^z} + 1} \right)}^2}}}} dz} \right] = \Im \left[ { - \int\limits_{ - \infty  + i\pi }^{ + \infty  + i\pi } {\frac{{{e^{z\left( {\frac{{ - 2{e^z} + 1}}{{ - {e^z} + 1}}} \right)}}}}{{{{\left( { - {e^z} + 1} \right)}^2}}}} dz} \right]\\
 Now: \int\limits_{ - \infty  + i\pi }^{ + \infty  + i\pi } { - \frac{{{e^{z\left( {\frac{{ - 2{e^z} + 1}}{{ - {e^z} + 1}}} \right)}}}}{{{{\left( { - {e^z} + 1} \right)}^2}}}} dz = 2\pi i.{\rm{Res}}\left( { - \frac{{{e^{z\left( {\frac{{ - 2{e^z} + 1}}{{ - {e^z} + 1}}} \right)}}}}{{{{\left( { - {e^z} + 1} \right)}^2}}},z = 0} \right) =  - 2\pi i.\frac{e}{2} =  - i\pi e
\end{array}$$
But at this step, and numerical check, this answer is wrong, even Mathematica only gives the approximation result $1.128274458083298$.
I don't know where I am wrong, may be when I transferred this integral to contour integral with rectangular contour($[-R-i\pi]\cup\ [R-i\pi]\cup\ [R+i\pi]\cup\ [-R+i\pi]$, the contribution on two vertices $[R+i\pi]\to[R-i\pi]$ and $[-R-i\pi]\to[-R+i\pi]$ don't vanish as $R\to \infty$. May I ask for some advices? Thank you very much
 A: Here is a rough proof of
$$\int_{0}^{1}\left(\frac{x}{1-x}\right)^{x}\sin\left(\pi x\right)dx = \frac{\pi e}{2}-\pi.$$
Proof. Let the integral in question equal $I$. Using your calculations above, which are correct, let's suppose
$$\int_{0}^{1}\left(\frac{x}{1-x}\right)^{x}\sin\left(\pi x\right)dx = -\Im\int_{-\infty+i\pi}^{\infty+i\pi}\exp\left(\frac{z-2ze^{z}}{1-e^{z}}\right)\frac{dz}{\left(1-e^{z}\right)^{2}}.$$
Let $f(z) = \exp\left(\dfrac{z-2ze^{z}}{1-e^{z}}\right)\dfrac{1}{\left(1-e^{z}\right)^{2}}$ and consider traversing clockwise on the same rectangular contour you constructed in your attempt. I made a graphic below.

Since the only pole of concern is at the origin (the red x in the picture), the residue is calculated by
$$-2\pi i\cdot{\rm{Res}}\left(\exp\left(\dfrac{z-2ze^{z}}{1-e^{z}}\right)\dfrac{1}{\left(1-e^{z}\right)^{2}},z = 0 \right) = -i\pi e.$$
By Cauchy's Residue Theorem, we have
$$-i\pi e = \left(\int_{-R+i\pi}^{R+i\pi}+\int_{R+i\pi}^{R-i\pi}+\int_{R-i\pi}^{-R-i\pi}+\int_{-R-i\pi}^{-R+i\pi}\right)f\left(z\right)dz.$$
From left to right, define each integral as $I_1, I_2, I_3,$ and $I_4$ respectively.
For the first integral, let $z=x+i\pi$. For the third integral, let $z=x-i\pi$. After some algebra, we would get $-\Im I_1 = \Im I_3 = I.$

the contribution on two vertices $[R+i\pi]\to[R-i\pi]$ and $[-R-i\pi]\to[-R+i\pi]$ don't vanish as $R\to \infty$.

Only $I_4$ vanishes as $R \to \infty$. To show this, let $z=iy-R$ so that
$$I_4 = \int_{-R-i\pi}^{-R+i\pi}f\left(z\right)dz=i\int_{-\pi}^{\pi}\exp\left(\frac{iy-R-z\left(iy-R\right)e^{iy}e^{-R}}{1-e^{iy}e^{-R}}\right)\cdot\frac{dy}{\left(1-e^{iy}e^{-R}\right)^{2}}.$$
Taking the limit of that integrand as $R\to\infty$, we get that it vanishes.
Similarly for $I_2$, we have
$$\int_{R+i\pi}^{R-i\pi}f\left(z\right)dz=i\int_{\pi}^{-\pi}\exp\left(\frac{iy+R-z\left(iy+R\right)e^{iy}e^{R}}{1-e^{iy}e^{R}}\right)\cdot\frac{dy}{\left(1-e^{iy}e^{R}\right)^{2}}.$$
As $R \to \infty$, we see the integrand approaches 1, making $I_2 = -2\pi i$.
Putting everything together while applying $R \to \infty$ and equating $-\Im$ on both sides, we get
$$
\begin{align}
-i\pi e &= I_1 - 2\pi i + I_3 + I_4 \\
\implies -\Im(-i\pi e) &= -\Im I_1 +\Im 2\pi i - \Im I_3 + 0 \\
\pi e &= I + 2\pi -(-I) + 0 \\
\therefore I &= \frac{\pi e}{2}-\pi. \\
\end{align}
$$
Q.E.D.
