<s>[INST] Compute definite integral Question: Compute 
$$\int_0^1 \frac{\sqrt{x-x^2}}{x+2}dx.$$
Attempt: I've tried various substitutions with no success. Looked for a possible contour integration by converting this into a rational function of $\sin\theta$ and $\cos \theta$.
 [/INST] We certainly can use contour integration here.  First, through a sub of $x \mapsto x^2$ and a little algebra, we can express the integral as
$$2 \int_0^1 dx \, \sqrt{1-x^2} - 4 \int_0^1 dx \frac{\sqrt{1-x^2}}{2+x^2} = \frac{\pi}{2} - 2 \int_{-1}^1 dx \frac{\sqrt{1-x^2}}{2+x^2}$$
Now consider  
$$\oint_C dz \frac{\sqrt{z^2-1}}{z^2+2} $$
where $C$ is (1) the circle $z=R e^{i \theta}$, $\theta \in [-\pi,\pi)$, (2) a line extending from the circle at $\theta=\pi$ to the dogbone contour, (3) the dogbone, and (4) a line back to the circle at $\theta=-\pi$.  Note that the integral vanishes along the lines to the dogbone and along the small circles of the dogbone.  
Thus, the contour integral is equal to
$$i R \int_{-\pi}^{\pi} d\theta \, e^{i \theta} \frac{\sqrt{R^2 e^{i 2 \theta}-1}}{R^2 e^{i 2 \theta}+2} + i 2 \int_{-1}^1 dx \frac{\sqrt{1-x^2}}{2+x^2}$$
Note that I have ignored the small semicircular and circular contours, as the integrals around those vanish as their radii vanish.  Also, I have skipped over the step of assigning a phase to each branch of the square root along $[-1,1]$.  
The contour integral is also equal to $i 2 \pi$ times the residue of the poles inside $C$, which are at $z=\sqrt{2} e^{\pm i \pi/2}$.  Thus, taking the limit as $R \to \infty$, we get
$$i 2 \pi + i 2 \int_{-1}^1 dx \frac{\sqrt{1-x^2}}{2+x^2} = i 2 \pi \left (\frac{i \sqrt{3}}{i \sqrt{2}} +  \frac{-i \sqrt{3}}{-i \sqrt{2}} \right ) = i \sqrt{6} \pi $$
Putting this altogether, we get
$$\int_{-1}^1 dx \frac{\sqrt{1-x^2}}{2+x^2} = \left (\sqrt{6}-2 \right ) \frac{\pi}{2} $$
and therefore, the original integral is equal to

$$\int_0^1 dx \frac{\sqrt{x-x^2}}{x+2} = \left (\frac{5}{2}-\sqrt{6} \right ) \pi $$

</s>