Indefinite integral with substitution For my engineering math course I got a couple of exercises about indefinite integrals. I ran trought all of them but stumbled upon the following problem. 
$$\int \frac{1-x}{\sqrt{1+x-2x^2}}\,dx $$
We can write $1+x-2x^2$ as $(1-x)(2x+1)$ 
So I got:
$$
\int \frac{1-x}{\sqrt{1+x-2x^2}}\,dx = \int \frac{1-x}{\sqrt{(1-x)(2x+1)}}\,dx 
$$
We can also replace $1-x$ in the denominator with $\sqrt{(1-x)^2}$ 
$$
\int \frac{1-x}{\sqrt{(1-x)(2x+1)}}\,dx = \int \frac{\sqrt{(1-x)^2}}{\sqrt{(1-x)(2x+1)}}\,dx
$$
If we simplify this fraction we get:
$$
\int \frac{\sqrt{1-x}}{\sqrt{2x+1}}\,dx
$$
Next we apply the following substitutions
$$
u = -x
$$
so : $-du = dx$
We can rewrite the integral as following:
$$-\int \frac{\sqrt{1+u}}{\sqrt{1-2u}}\,du$$
Then we apply another substitution: 
$\sqrt{1+u} = t $ so $ \frac{1}{2\sqrt{1+u}} = dt $ 
We rewrite: $ \sqrt{1+u} $ to $\frac{1}{2}t^2 \,dt $ 
We can also replace $\sqrt{1-2u} $ as following: 
$$\sqrt{-2t^2+3}=\sqrt{-2(1+u)+3}=\sqrt{1-2u}$$ 
With al these substitutions the integral has now the following form: 
$$-\frac{1}{2}\int \frac{t^2}{\sqrt{-2t^2+3}}\,dt$$ 
Next we try to ''clean'' up the numerator: 
$$-\frac{1}{2} \int \frac{t^2}{\sqrt{\frac{1}{2}(6-t^2)}} \, dt$$
$$-\frac{\sqrt{2}}{2} \int \frac{t^2}{\sqrt{6-t^2}} \, dt$$
And that's where I got stuck. I can clearly see that an arcsin is showing up in the integral but don't know how to get rid of the $t^2$.

Let $u^2=\frac{1-x}{1+2x}$. Then $x=\frac{1-u^2}{1+2u^2}$ and $\mathrm{d}x=-\frac{6u}{(1+2u^2)^2}\,\mathrm{d}u$.
Let $\sqrt2u=\tan(\theta)$, then $\sqrt2\,\mathrm{d}u=\sec^2(\theta)\,\mathrm{d}\theta$.
$$
\begin{align}
\int\frac{1-x}{\sqrt{1+x-2x^2}}\,\mathrm{d}x
&=\int\frac{1-x}{\sqrt{(1-x)(1+2x)}}\,\mathrm{d}x\\
&=\int\sqrt{\frac{1-x}{1+2x}}\,\mathrm{d}x\\
&=-\int\frac{6u^2}{(1+2u^2)^2}\,\mathrm{d}u\\
&=-\frac3{\sqrt2}\int\frac{\tan^2(\theta)}{\sec^4(\theta)}\sec^2(\theta)\,\mathrm{d}\theta\\
&=-\frac3{\sqrt2}\int\sin^2(\theta)\,\mathrm{d}\theta\\
&=-\frac3{2\sqrt2}\int(1-\cos(2\theta))\,\mathrm{d}\theta\\
&=-\frac3{4\sqrt2}(2\theta-\sin(2\theta))+C\\
&=-\frac3{2\sqrt2}\left(\theta-\frac{\tan(\theta)}{1+\tan^2(\theta)}\right)+C\\
&=-\frac3{2\sqrt2}\left(\arctan\left(\sqrt2u\right)-\frac{\sqrt2u}{1+2u^2}\right)+C\\
&=\frac12\sqrt{1+x-2x^2}-\frac3{2\sqrt2}\arctan\left(\sqrt{\frac{2-2x}{1+2x}}\right)+C\\
\end{align}
$$
