Help, Where is wrong when I do same complex integration using two different contours everyone! please give few hit. I want take the integral $$I=\int_{0}^{\infty}{\frac {dx}{ \sqrt{x}(1+{x}^{2})}} $$ by using the Residue Theorem. I choice two contours in complex plane with $z=r e^{i\theta}$ to calculate, But I get different results which one of them is same as the textbook and WolframAlpha, i.e. $I=\frac {\sqrt{2}}{2} \pi$.
The 1st contour is given as A big semicircle $C_{4}$ with radius R and a small semicircle $C_{2}$ with radius $\delta$ centering at origin and $C_{1}$ and $C_{3}$ parallel to real axis, Click to Check. 
In this situation, the Residue Theorem is $\oint_{\Gamma_{1}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}} =-\pi i^{\frac{3}{2}}$ for combined contour $\Gamma_{1}$ of four parts of contours $C_{1}$,$C_{2}$,$C_{3}$ and $C_{4}$ and I also have the following results for these four contours with the radius of $C_{4}$ and $C_{2}$ turn to be $\infty$ and $0$, respectively $$\int_{C_{1}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}} =-i I$$ $$\int_{C_{3}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}} =I$$ $$\left|\int_{C_{2}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}}\right| \le \lim_{\delta\rightarrow 0}{\frac {\pi \delta}{\left| \sqrt {\delta}-{\delta}^{\frac{5}{2}}\right|}}=0$$ $$\left|\int_{C_{4}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}}\right| \le \lim_{R\rightarrow \infty}{\frac {\pi R}{\left| \sqrt {R}-{R}^{\frac{5}{2}}\right|}}=0$$. So, I have $I(1-i)=-\pi i^{\frac{3}{2}}$ and $I=\frac {\sqrt{2}}{2} \pi$. 
But, In 2nd contour, I can not get the result, Please help find where did I mistake. The 2nd contour is given as 
In this situation, the Residue Theorem is $\oint_{\Gamma_{2}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}} =\int_{C_{1}}+\int_{C_{2}}+\int_{C_{3}}+\int_{C_{4}}=2 \pi i （Resf(z)_{z=i}+Resf(z)_{z=-i}）=-i \pi \sqrt{2}$ for combined contour $\Gamma_{2}$ of four parts of contours $C_{1}$,$C_{2}$,$C_{3}$ and $C_{4}$ and I also have the following results for these four contours with the radius of $C_{2}$ and $C_{4}$ turn to be $\infty$ and $0$, respectively $$\int_{C_{1}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}} =\int_{C_{1}}{\frac{d(r e^{i 0})}{\sqrt{r} e^{i \frac{0}{2}} (1+{r}^{2} e^{i 2* 0})}}=\int_{C_{1}}{\frac{d(r)}{\sqrt{r} (1+{r}^{2})}}=\int_{0}^{\infty}{\frac{dr}{\sqrt{r} (1+{r}^{2})}}=I$$
$$\int_{C_{3}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}} =\int_{C_{3}}{\frac{d(r e^{i 2 \pi})}{\sqrt{r} e^{i \pi} (1+{r}^{2} e^{i 4*\pi})}}=\int_{C_{3}}{\frac{dr}{-\sqrt{r}  (1+{r}^{2})}}=-\int_{+\infty}^{0}{\frac{dr}{\sqrt{r} (1+{r}^{2})}}=\int_{0}^{\infty}{\frac{dr}{\sqrt{r} (1+{r}^{2})}}=I$$
To evaluate the up level of the integral of $C_{4}$ and $C_{2}$, I first calculate the up level of absolute value of $f(z)$. Because $$\left|f(z) \right|=\frac {1}{\left| \sqrt{r}{e}^{i\frac {\theta}{2}}(1+{r}^{2}{e}^{ i2\theta}) \right|} \le \frac { 1 }{ \left| \sqrt { r } -{ r }^{ \frac { 5 }{ 2 }  } \right|  } $$
$$\left|\int_{C_{4}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}}\right| \le \lim_{\delta\rightarrow 0}{\frac {2\pi \delta}{\left| \sqrt {\delta}-{\delta}^{\frac{5}{2}}\right|}}=0$$ 
$$\left|\int_{C_{2}}{\frac{dz}{\sqrt{z} (1+{z}^{2})}}\right| \le \lim_{R\rightarrow \infty}{\frac {2\pi R}{\left| \sqrt {R}-{R}^{\frac{5}{2}}\right|}}=0$$. So, I have $2I=-i \sqrt{2}\pi$ and $I=-i \frac {\sqrt{2}}{2} \pi$. 
I think I should be make some mistake in the 2nd contour calculation. Is anyone can help me to fix it, thanks and please!! And what should be attended when I take a contour integral for a multivalued function except branch and branch cut?
 A: Take the branch cut of $\sqrt{x}$ to be the negative real axis.  We can deform the contour from $(0,\infty)$ to $(-\infty,0)$ on either side of the branch cut, at the cost of adding in a residue.  Notice that the integrand has opposite values on either side of the branch cut.  If we deform $(0,\infty)$ to $(-\infty,0)$ requiring that $arg(z)=\pi$, we have
$$\int_0^\infty\frac{dx}{\sqrt{x}(1+x^2)}=2\pi i\cdot \text{Res}\left(\frac{1}{\sqrt{z}(1+z^2)},z=i\right)-\int_{-\infty}^0\frac{dx}{\sqrt{x}_+(1+x^2)}.$$
($x_+$ means $arg(x)=\pi$ and $x_-$ means $arg(x)=-\pi$)
Repeating the same process but deforming to the other side of the branch cut, we have 
$$\int_0^\infty\frac{dx}{\sqrt{x}(1+x^2)}=-2\pi i\cdot \text{Res}\left(\frac{1}{\sqrt{z}(1+z^2)},z=-i\right)-\int_{-\infty}^0\frac{dx}{\sqrt{x}_-(1+x^2)}.$$
Therefore we have 
$$2\int_0^\infty\frac{dx}{\sqrt{x}(1+x^2)}=2\pi i\cdot\text{Res}\left(\frac{1}{\sqrt{z}(1+z^2)},z=i\right)-2\pi i\cdot \text{Res}\left(\frac{1}{\sqrt{z}(1+z^2)},z=-i\right).$$
$2\pi i\cdot\text{Res}\left(\frac{1}{\sqrt{z}(1+z^2)},z=i\right)=\pi\cdot e^{-i\pi/4}$ and $-2\pi i\cdot\text{Res}\left(\frac{1}{\sqrt{z}(1+z^2)},z=-i\right)=\pi\cdot e^{i\pi/4}$ so 
$$\int_0^\infty\frac{dx}{\sqrt{x}(1+x^2)}=\frac{\pi}{2}(e^{i\pi/4}+e^{-i\pi/4})=\frac{\pi}{\sqrt{2}}.$$
A: I would propose the following to avoid the multiple valued problem in this case: substitute
$$x=u^2\implies dx=2u\,du\implies\;\text{we get the integral}\;\;$$
$$ \int_0^\infty\frac{2u\;du}{u(1+u^4)}=2\int_0^\infty\frac{du}{1+u^4}=\frac\pi{\sqrt2}$$
which is your first result (This is more or less well known result, which can also be obtained by "usual", real methods, or by complex analysis).
A: The first integral is equal to, in the limit as $R \to \infty$,
$$ e^{i \pi} \int_{\infty}^0 \frac{dx}{e^{i \pi/2} \sqrt{x} (1+x^2)} + \int_0^{\infty} \frac{dx}{\sqrt{x} (1+x^2)} = (1-i) \int_0^{\infty} \frac{dx}{\sqrt{x} (1+x^2)}$$
which is equal to $i 2 \pi$ times the residue at the pole $z=e^{i \pi/2}$, so that
$$\sqrt{2} e^{-i \pi/4} \int_0^{\infty} \frac{dx}{\sqrt{x} (1+x^2)} = i 2 \pi \frac1{e^{i \pi/4} 2 e^{i \pi/2}}  \implies \int_0^{\infty} \frac{dx}{\sqrt{x} (1+x^2)} = \frac{\pi}{\sqrt{2}}$$
The second integral is equal to, in the limit as $R \to \infty$,
$$\int_0^{\infty} \frac{dx}{\sqrt{x} (1+x^2)} + e^{i 2 \pi}\int_{\infty}^0 \frac{dx}{e^{i \pi}\sqrt{x} (1+x^2)} $$
which is equal to $i 2 \pi$ times the sum of the residues at the poles $z=e^{i \pi/2}$ and $z=e^{i 3 \pi/2}$. (NB This is the key to recovering the correct answer - we have defined the branch cut so that the argument of $-i$ must be $3 \pi/2$.)  Thus,
$$2 \int_0^{\infty} \frac{dx}{\sqrt{x} (1+x^2)} = i 2 \pi \left [\frac1{e^{i \pi/4} 2 e^{i \pi/2}} + \frac1{e^{i 3 \pi/4} 2 e^{i 3 \pi/2}} \right ] = \pi \sqrt{2}$$
So both contours provide the same result, so long as the argument of the complex variable $z$ is treated consistently with respect to the branch cut.
