Complex integration to solve real integral $\int_{0}^{2}\frac{\sqrt{x\left(2-x\right)}}{\left(x+1\right)^{2}\left(3-x\right)}dx.$ I have to solve this integral
$$\int_{0}^{2}\frac{\sqrt{x\left(2-x\right)}}{\left(x+1\right)^{2}\left(3-x\right)}dx.$$
Thus, I formed the following contour:

By Chauchy theorem I have
$$I=\int_{C_{R}}f\left(z\right)dz+\int_{C_{r1}}f\left(z\right)dz+\int_{k_{\epsilon}}f\left(z\right)dz+\int_{z_{1}}f\left(z\right)dz+\int_{k_{\rho}}f\left(z\right)dz+\int_{C_{r2}}f\left(z\right)dz+\int_{z_{2}}f\left(z\right)dz=0$$
Now I use Jordan's lemma to calculate the values over small circles. I have
$$\lim_{z\rightarrow0}z\cdot\frac{\sqrt{z\left(2-z\right)}}{\left(z+1\right)^{2}\left(3-x\right)}=0\,\,\Rightarrow\,\,\lim_{r\rightarrow0}\int_{k_{\rho}}f\left(z\right)dz=0$$
$$\lim_{z\rightarrow3}\left(z-3\right)\cdot\frac{\sqrt{z\left(2-x\right)}}{\left(z+1\right)^{2}\left(3-z\right)}=0 \Rightarrow\,\,\lim_{r\rightarrow0}\int_{C_{r1}}f\left(z\right)dz=0$$
Now I have the problem with term $(x+1)^2$ because I cannot apply Jordan's lemma because I cannot find the limit.
$$\lim_{z\rightarrow-1}\left(z+1\right)\cdot\frac{\sqrt{z\left(2-z\right)}}{\left(z+1\right)^{2}\left(3-z\right)}=?$$
Does anyone have idea how to solve this? I think lemma cannot be applied here but I don't know the other way.
I also found the function is regular in infinity thus integral over $C_{R}$ is zero.
 A: There are actually several problems with this working.

*

*You need to include the cut circle around $z=2$.  This should give zero.


*The limit you render at $z=3$ is not zero.  The $z-3$ factor is canceled out by the $3-z$ factor in the denominator.  You therefore do not have a zero contribution in that circle.


*Then there is the problem you state at $z=-1$.
Let's look at the problems in that order.

*

*This calculation is essentially the same as that for $z=0$.  You get a zero contribution again.


*The problem here is you don't have a "surviving" factor that tends to zero as $z\to3$.  Instead you have
$(z-3)\dfrac{\sqrt{z(2-z)}}{(z+1)^2(3-z)}=-\dfrac{\sqrt{z(2-z)}}{(z+1)^2}\to-\sqrt{3(2-3)}/(3+1)^2=-\sqrt{-3}/16$
We have to be careful with the sign on the imaginary part of that square root. Rendering the argument of $z(2-z)$ as zero on the upper side of the cut (so you have the nonnegative square root for the forward integration), you go clockwise (not crossing the cut) around $z=2$ to find that the argument of $z(2-z)=-3$ has evolved from zero to $-\pi$, not $+\pi$, and so the proper square root of the negative number is $-\sqrt3i$ rather than $+\sqrt3i$.  Accordingly the limit of your combined function is $+\sqrt3i/16$.
Given this result, you render your function on the small circle around $z=3$ thusly:
$\dfrac{\sqrt{z(2-z)}}{(z+1)^2(3-z)}=[\dfrac{\sqrt{z(2-z)}}{(z+1)^2(3-z)}-\dfrac{\sqrt3i}{16(z-3)}]+[\dfrac{\sqrt3i}{16(z-3)}]$
The first term in brackets will give a zero limit when it's multiplied by your factor $z-3$, so Jordan's Lemma will kill that term. The second, simpler term is something you should get able to integrate directly around the small circle.  Beware that you are going clockwise around that circle and so must adjust the sign of the contribution accordingly.


*Now we get to the really fun part, handling that secobd-order pole at $z=-1$. You can't get your limit at all because of that second-order pole; applying just one factor of $(z+1)$ is not enough to bound such a monster.

Suppose you were just integrating $dz/(z+1)^2$ around any  closed curve that encloses $z=-1$. The antiderivative is $-1/z+C$ which has only an isolated singularity at $z=-1$. So when you go around the contour your antideruvative will return to its original value and the contour integral will go to zero.
This suggests that we may render the integral of your function as
$\oint\dfrac{\sqrt{z(2-z)}}{(z+1)^2(3-z)}-\dfrac{a}{(z+1)^2}dz$
where $a$ is adjusted so that the limit of the integrated multiplied by $z+1$ remains finite.  To this end render
$a=\lim_{z\to-1}(z+1)^2\dfrac{\sqrt{z(2-z)}}{(z+1)^2(3-z)}=\sqrt{-3}/4$
where this time the argument of the negative radicand is $+\pi$ because you go counterclockwise (instead of clockwise) from the upper side of the branch cut to the negative real axis.  Thus $a=+\sqrt3i/4$.
We then seek the limit
$\lim_{z\to-1}(z+1)\dfrac{\sqrt{z(2-z)}-(\sqrt3i/4)(3-z)}{(z+1)^2(3-z)}$
$=\lim_{z\to-1}\dfrac{z(2-z)+(3/16)(3-z)^2}{(z+1)(3-z)[\sqrt{z(2-z)}+(\sqrt3i/4)(3-z)]}$
$=\lim_{z\to-1}\dfrac{-13z^2+14z+27}{16(z+1)(3-z)[\sqrt{z(2-z)}+(\sqrt3i/4)(3-z)]}$
$=\lim_{z\to-1}\dfrac{-13z+27}{16(3-z)[\sqrt{z(2-z)}+(\sqrt3i/4)(3-z)]}=-5\sqrt3i/48$
You then treat this case similarly to (2) above.  Thus you evaluate a "net" integral of $(-5\sqrt3i)dz/[48(z+1)]$ around this circle, again remembering that you are going clockwise.
You now have the integrals over all the circles. All that remains is to combine them apprporiately and solve for the original integral. Remember that your path traverses $(0,2)$ twice, once in the forward direction with positive square root and once in the backward direction with negative square root.  Thus your path contains twice the integral.
A: Probably it would be much easier to consider a "dogbone" contour around the branch cut from 0 to 2 only:

It is trivial to see that the integrals over the circles at the end points vanish when their radius is taken to 0. Let's call the full contour $\gamma$.
When we move from a point on the upper edge (let's call it $x + i0$) to the corresponding point on the other side of the branch cut, $x - i0$, the argument of $f(z)$ increases by $-\pi$, so the function value is multiplied by $e^{-i\pi} = -1$, in other words $f(x + i0) = -f(x - i0)$, and since these edges are integrated in opposite directions, we get
$$\int_{0}^{2}f(x)dx = \frac12\oint_\gamma f(z)dz$$
This curve circles the branch cut in the clockwise direction, so its interior consists of all points outside of it, including $\infty$ where we'll get the contribution of the residue at $\infty$.
The residue theorem now tells us that
$$\oint_\gamma f(z)dz = 2\pi i\left(\operatorname{Res}(f,-1) + \operatorname{Res}(f,3) + \operatorname{Res}(f,\infty)\right)$$
It is not hard to compute these residues to be $-\frac{5\sqrt3 i}{48}$, $\frac{\sqrt3 i}{16}$ and $0$, except possibly for the sign: you can obtain this by noting that when going from $x_0 + i0$ to $x\in\mathbb R$ with $x > 2$, the argument of $x(2 - x)$ increases by $-\pi$, while for $x < 0$ it increases by $\pi$. We obtain a final result of
$$\int_{0}^{2}f(x)dx = \frac12\oint_\gamma f(z)dz = \frac{\sqrt3 \pi}{24}.$$
