Calculate $I = \int_0^1 \frac{\ln(\frac{1 - x} {x})} {x^2 + 1} dx$ This is my very first post. Therefore, sorry for any confusion...
Could someone help me to solve this integral. I believe I am messing up with the fact $\ln(z)$ is multivalued when I extended this integral to the complex plane. Roughly, I did the following:

*

*I am assuming the logarithm $\ln(x)$ is real if $x > 0$.

*The singularity points are $\{0, 1, i, -i\}$.

*I positioned the branch cut over the segment $[0, 1]$.

*Set up a closed line integral composed of the following paths: $[-1, 0]\cup \{z = x + i0, x \in [0, 1]\}\cup C_1$. Where $C_1$ is the semicircunference of radius one with center at $(0, 0)$, above the real axis, in a counterclockwise direction.

*The value of line integral over the path $\{z = x + i0, x \in [0, 1]\}$ is the answer ($=I$).

*I related the integral over the path $[-1, 0]$ ($=J$) with the integral over $\{z = x + i0, x \in [0, 1]\}$ ($= I$) . I found the following relation $J = I + i\pi\int_0^1 \frac{1} {x^2+1} dx$

*Calculated the integral over $C_1$. I found a messy real number involving $\pi^2$.

*The sum of each of above integrals is equal to a closed integral (in a counterclockwise direction). This closed integral is equal to the sum of the residues inside the path. In this path there is only one residue $z =i$, whose value is $-i/2\ln(-1-i)$.

*Equated the closed integral to the sum of integrals. Equating real parts I would get the answer.

BTW, the correct answer is $I = \frac {\pi} {8} \ln(2)$
Thanks
 A: Note
\begin{align}
I =& \int_0^1 \frac{\ln(\frac{1 - x} {x})} {x^2 + 1} dx 
=\int_0^1 \frac{\ln({1 - x})} {x^2 + 1} dx- \int_0^1 \overset{x\to\frac{1-x}{1+x}}{\frac{\ln x} {x^2 + 1} }dx\\
 =& \int_0^1 \frac{\ln({1 + x})} {x^2 + 1} dx
\overset{x\to\frac{1-x}{1+x}}=\int_0^1 \frac{\ln 2} {x^2 + 1} dx
 - \int_0^1 \frac{\ln (1+x)} {x^2 + 1} dx\\
=& \frac\pi4 \ln2- I=\frac\pi8\ln2
\end{align}
A: A variant from the Quanto's answer:
\begin{align}I&=\int_0^1 \frac{\ln\left(\frac{1-x}{x}\right)}{1+x^2}dx\\
&\overset{y=\frac{1-x}{1+x}}=\int_0^1 \frac{\ln\left(\frac{2y}{1-y}\right)}{1+y^2}dy\\
2J&=\int_0^1 \frac{\ln 2}{1+y^2}dy\\
&=\frac{\pi\ln 2}{4}\\
J&=\boxed{\frac{\pi\ln 2}{8}}\\
\end{align}
A: If you want to evaluate the integral using complex integration, you are moving in the right direction. But you have to use the symmetries that complex integration provides. For example, the contour of radius $R$ is usually chosen to move it to infinity, where the integral wanish.
I'm afraid that in the case of your integral a bit more complicated algorithm should be used. Let's consider, for example, the following contour

and the integrand $\frac{\ln^2(\frac{1 - x} {x})} {x^2 + 1}$.
You correctly have chosen the cut connecting the branch points of logarithm. Let's choose the branch of logarithm with positive real value on its upper bank; in this case on the lower bank $\frac{1 - x} {x}$ will get the multiplier $e^{2\pi i}$. I also draw the contour around the cut, a big circle (of radius $R\to\infty$) and linked them with the line on the real axis (from $1$ to $R$).
Now we have a closed contour in the complex plane:
a) from $0$ to $1$ on the upper bank of the cut
b) from $1$ to $R$ along axix $X$ (path $1$)
c) full circle of radius $R$ counter clockwise
d) along the path $1$ in the opposite direction (from $R$ to $1$)
e) along the lower bank of the cut (from $1$ to $0$) to the starting point
We have the closed contour, and integrand is single-valued inside it. We have a couple of simple poles inside the contour (at $x=$ $e^{\frac{\pi i}{2}}$ and $e^{\frac{3\pi i}{2}}$).
$$\oint_C =2\pi i Res \frac{\ln^2(\frac{1 - x} {x})} {x^2 + 1}$$
Let's note that integral along big circle $\to0$ when $R\to \infty$, and integrals along path $1$ cancels each other (we go in the opposite directions).
So, we are left with
$$\oint_C=\int_0^1 \frac{\ln^2(\frac{1 - x} {x})} {x^2 + 1} dx+\int_1^0 \frac{\ln^2(\frac{1 - x} {x}e^{2\pi i})} {x^2 + 1} dx$$
$$=\int_0^1 \frac{\ln^2(\frac{1 - x} {x})} {x^2 + 1} dx+\int_1^0 \frac{\ln^2(\frac{1 - x} {x})} {x^2 + 1} dx+4\pi i\int_1^0 \frac{\ln(\frac{1 - x} {x})} {x^2 + 1}+(2\pi i)^2\int_1^0 \frac{1} {x^2 + 1}dx$$
Two first terms cancel each other, so
$$\oint_C=4\pi i\int_1^0 \frac{\ln(\frac{1 - x} {x})} {x^2 + 1}dx+(2\pi i)^2\int_1^0 \frac{1} {x^2 + 1}dx=2\pi i Res \frac{\ln^2(\frac{1 - x} {x})} {x^2 + 1}$$
$$=2\pi i\frac{\ln^2\Bigl(\frac{1 -e^{\frac{\pi i}{2}} } {e^{\frac{\pi i}{2}}}\Bigr)} {2i}+2\pi i\frac{\ln^2\Bigl(\frac{1 -e^{\frac{3\pi i}{2}} } {e^{\frac{3\pi i}{2}}}\Bigr)} {-2i}=\pi\Bigl(\ln^2(e^{\frac{-\pi i}{2}} -1)-\ln^2(e^{\frac{-3\pi i}{2}} -1)\Bigr)$$
$$=\pi\Bigl(\ln^2(\sqrt2e^{\frac{3\pi i}{4}})-\ln^2(\sqrt2e^{\frac{5\pi i}{4}})\Bigr)$$
$$I=\int_0^1 \frac{\ln(\frac{1 - x} {x})} {x^2 + 1} dx=-\pi i\int_0^1 \frac{1} {x^2 + 1}dx+\frac{1}{4i}\Bigl(\ln^2(\sqrt2e^{\frac{5\pi i}{4}})-\ln^2(\sqrt2e^{\frac{3\pi i}{4}})\Bigr)$$
$$I=\frac{\pi \ln2}{8}$$
Rather long evaluation, but the beauty of the complex integration is the shortcut to the general formula, if there is a symmetry. In our case these are the limits of integration - branch points.
Let's consider, for example, $$I(k)=\int_0^1 \frac{\ln^k(\frac{1 - x} {x})} {x^2 + 1} dx$$
If we choose the integrand $$\frac{(\frac{1 - x} {x})^s} {x^2 + 1} dx$$ and integrate along the same path, we easily get
$$J(s)(1-e^{2\pi is})=2\pi i Res\frac{(\frac{1 - x} {x})^s} {x^2 + 1}$$
$$J(s)=\int_0^1\frac{(\frac{1 - x} {x})^s} {x^2 + 1}dx=\pi \,2^{\frac{s}{2}}\,\frac{\sin(\frac{\pi s}{4})}{\sin(\pi s)}=\frac{\pi}{4}  \frac{2^{\frac{s}{2}}}{\cos(\frac{\pi s}{4})\cos(\frac{\pi s}{2})}$$
$$I(k)=\frac{d^k}{ds^k}J(s)|_{s=0}$$
Taking the limit at $s\to0$
$$I(0)=\int_0^1 \frac{1} {x^2 + 1} dx= \frac{\pi}{4}$$
$$I(1)=\int_0^1 \frac{\ln(\frac{1 - x} {x})} {x^2 + 1} dx=\frac{\pi \ln2}{8}$$
$$I(2)=\int_0^1 \frac{\ln^2(\frac{1 - x} {x})} {x^2 + 1} dx=\frac{\pi \ln^22}{16}+\frac{21\pi^3}{64}$$
etc.
