Integral $\int \sqrt{\frac{x}{2-x}}dx$ $$\int \sqrt{\frac{x}{2-x}}dx$$
can be written as:
$$\int x^{\frac{1}{2}}(2-x)^{\frac{-1}{2}}dx.$$
there is a formula that says that if we have the integral of the following type:
$$\int x^m(a+bx^n)^p dx,$$ 
then:


*

*If $p \in \mathbb{Z}$ we simply use binomial expansion, otherwise:

*If $\frac{m+1}{n} \in \mathbb{Z}$ we use substitution $(a+bx^n)^p=t^s$
where $s$ is denominator of $p$;

*Finally, if $\frac{m+1}{n}+p \in \mathbb{Z}$ then we use substitution
$(a+bx^{-n})^p=t^s$ where $s$ is denominator of $p$.


If we look at this example:
$$\int x^{\frac{1}{2}}(2-x)^{\frac{-1}{2}}dx,$$
we can see that $m=\frac{1}{2}$, $n=1$, and $p=\frac{-1}{2}$ which means that we have to use third substitution since $\frac{m+1}{n}+p = \frac{3}{2}-\frac{1}{2}=1$ but when I use that substitution I get even more complicated integral with square root. But, when I tried second substitution I have this:
$$2-x=t^2 \Rightarrow 2-t^2=x \Rightarrow dx=-2tdt,$$ 
so when I implement this substitution I have:
$$\int \sqrt{2-t^2}\frac{1}{t}(-2tdt)=-2\int \sqrt{2-t^2}dt.$$
This means that we should do substitution once more, this time:
$$t=\sqrt{2}\sin y \Rightarrow y=\arcsin\frac{t}{\sqrt{2}} \Rightarrow dt=\sqrt{2}\cos ydy.$$
So now we have:
\begin{align*}
-2\int \sqrt{2-2\sin^2y}\sqrt{2}\cos ydy={}&-4\int\cos^2ydy = -4\int \frac{1+\cos2y}{2}dy={} \\
{}={}& -2\int dy -2\int \cos2ydy = -2y -\sin2y.
\end{align*}
Now, we have to return to variable $x$:
\begin{align*}
-2\arcsin\frac{t}{2} -2\sin y\cos y ={}& -2\arcsin\frac{t}{2} -2\frac{t}{\sqrt{2}}\sqrt\frac{2-t^2}{2}={} \\
{}={}&  -2\arcsin\frac{t}{2} -\sqrt{t^2(2-t^2)}.
\end{align*}
Now to $x$:
$$-2\arcsin\sqrt{\frac{2-x}{2}} - \sqrt{2x-x^2},$$
which would be just fine if I haven't checked the solution to this in workbook where the right answer is:
$$2\arcsin\sqrt\frac{x}{2} - \sqrt{2x-x^2},$$ 
and when I found the derivative of this, it turns out that the solution in workbook is correct, so I made a mistake and I don't know where, so I would appreciate some help, and I have a question, why the second substitution works better in this example despite the theorem i mentioned above which says that I should use third substitution for this example?
 A: 
$$\int \sqrt{\frac{x}{2-x}}dx$$

Set $t=\frac {x} {2-x}$ and $dt=\left(\frac{x}{(2-x)^2}+\frac{1}{2-x}\right)dx$
$$=2\int\frac{\sqrt t}{(t+1)^2}dt$$
Set $\nu=\sqrt t$ and $d\nu=\frac{dt}{2\sqrt t}$
$$=4\int\frac{\nu^2}{(\nu^2+1)^2}d\nu\overset{\text{ partial fractions}}{=}4\int\frac{d\nu}{\nu^2+1}-4\int\frac{d\nu}{(\nu^1+1)^2+\mathcal C}$$
$$=4\arctan \nu-4\int\frac{d\nu}{(\nu^2+1)^2}$$
Set $\nu=\tan p$ and $d\nu=\sec^2 p dp.$ Then $(\nu^2+1)^2=(\tan^2 p+1)^2=\sec^4 p$ and $p=\arctan \nu$
$$=4\arctan \nu-4\int \cos^2 p dp$$
$$=4\arctan \nu-2\int \cos(2p)dp-2\int 1dp$$
$$=4\arctan \nu-\sin(2p)-2p+\mathcal C$$
Set back $p$ and $\nu$:
$$=\color{red}{\sqrt{-\frac{x}{x-2}}(x-2)+2\arctan\left(\sqrt{-\frac{x}{x-2}}\right)+\mathcal C}$$
A: Let me try do derive that antiderivative. You computed:
$$f(x)=\underbrace{-2\arcsin\sqrt{\frac{2-x}{2}}}_{f_1(x)}\underbrace{-\sqrt{2x-x^2}}_{f_2(x)}.$$
The easiest term is clearly $f_2$:
$$f_2'(x)=-\frac{1}{2\sqrt{2x-x^2}}\frac{d}{dx}(2x-x^2)=\frac{x-1}{\sqrt{2x-x^2}}.$$
Now the messier term. Recall that $\frac{d}{dx}\arcsin x=\frac{1}{\sqrt{1-x^2}}$. So:
\begin{align*}
f_1'(x)={}&-2\frac{1}{\sqrt{1-\left(\sqrt{\frac{2-x}{2}}\right)^2}}\frac{d}{dx}\sqrt{\frac{2-x}{2}}=-2\frac{1}{\sqrt{1-\frac{2-x}{2}}}\cdot\frac{1}{\sqrt2}\frac{d}{dx}\sqrt{2-x}={} \\
{}={}&-2\sqrt{\frac2x}\cdot\frac{1}{\sqrt2}\cdot\frac{1}{2\sqrt{2-x}}\cdot(-1)=\frac{2}{\sqrt x}\frac{1}{2\sqrt{2-x}}=\frac{1}{\sqrt{2x-x^2}}.
\end{align*}
So:
$$f'(x)=f_1'(x)+f_2'(x)=\frac{x}{\sqrt{2x-x^2}}=\frac{x}{\sqrt x}\frac{1}{\sqrt{2-x}}=\frac{\sqrt x}{\sqrt{2-x}},$$
which is your integrand. So you were correct after all! Or at least got the correct result, but no matter how I try, I cannot find an error in your calculations.
As for the book's solution, take your $f$, and compose it with $g(x)=2-x$. You get the book's solution, right? Except for a sign. But then $g'(x)=-1$, so the book's solution is also correct: just a different change of variables, probably, though I cannot really guess which.
A: Alternative solution - let $x=2t^2$, then
$$I=\int\sqrt{\frac{x}{2-x}}\mathrm{d}x=4\int\frac{t^2}{\sqrt{1-t^2}}\mathrm{d}t=4J$$
By parts we have
$$J=-t\sqrt{1-t^2}+\int\sqrt{1-t^2}\;\mathrm{d}t = -t\sqrt{1-t^2}+\int\frac{1-t^2}{\sqrt{1-t^2}}\;\mathrm{d}t\!=\!-t\sqrt{1-t^2}+\arcsin t-J $$
Hence
$$I=4J=2\cdot 2J =2\arcsin t -2t\sqrt{1-t^2} = 2\arcsin\sqrt{\frac{x}{2}}-\sqrt{2x-x^2} + C$$
The solutions are equivallent because of formula :
$$\arcsin x= \frac{\pi}{2}-\arcsin{\sqrt{1-x^2}} $$
Clearly, take $\sin$ of both sides, with the fact that $\sin (\frac{\pi}{2}-x)=\cos x$ :
$$ x= \cos\arcsin{\sqrt{1-x^2}}=\sqrt{1-\sin^2{\arcsin{\sqrt{1-x^2}}}} =\sqrt{1-(1-x^2)} = x  $$
A: Let $u=\sqrt{2-x}$ then we simply want
$-2\int \sqrt{2-u^2}du$ which is simple after $u=\sqrt{2}\sin{v}$
