<s>[INST] Evaluate $\int_{2}^{7} \frac{x}{1-\sqrt{2+x}} d x$ We have the following integral:
$$
\int_{2}^{7} \frac{x}{1-\sqrt{2+x}}\, dx
$$
And this is my solution, which seems to be wrong, and I am failing to see where exactly I failed at:
We have $u=1-\sqrt{2+x}, x=u^2-2u-1, dx=-2\sqrt{2+x}\, du$, and we know that $x\geq -2$ and thus $u\leq 1$:
\begin{align}
\int_{2}^{7} \frac{x}{1-\sqrt{2+x}}\, dx
&=-2\int_{-1}^{-2} \frac{(u^2+2u-1)(u-1)}{u}\, du\\
&= -2 \left( \int_{-1}^{-2} u^2 d u + \int_{-1}^{-2} u\, du +\int_{-1}^{-2} -3\, du + \int_{-1}^{-2} \frac{1}{u}\, du \right) \\
&= -2\left[\frac{u^3}{3}+\frac{u^2}{2}-3u+\ln{|u|}\right]_{-1}^{-2}\approx -18
\end{align}
Can someone please help me pinpoint the issue?
 [/INST] The first thing I would like to point out is that since you want to do a substitution, it is really extra (unnecessary) work writing $dx$ in terms of $x$ (where the aim of substitution is to "get rid" of the initial variable and simplify the integral in the process).
With that out of the way, let $u = 1 - \sqrt {2 + x}$, then $x = u^2 - 2u - 1$ and $\mathrm{d}x = 2u - 2$.
Now, observe that, $\forall\ n \in \mathbb {R}$, $\sqrt n \geq 0$, so we note that $u \leq 1$.
\begin{align}
\int_{2}^{7} \frac x {1 - \sqrt {2 + x}}\ \mathrm {d}x & =
2\int_{-1}^{-2} \frac {(u^2 - 2u - 1)(u - 1)} u\ \mathrm {d}u
\\[5 mm] & =
2\int_{-1}^{-2} \frac {u^3 - 3u^2 + u + 1} u\ \mathrm {d}u
\\[5 mm] & =
2\left[\frac {u^3} 3 - \frac {3u^2} 2 + u + \ln|u|\right]^{-2}_{-1}
\\[5 mm] & =
2\ln 2 -\frac {47} 3
\end{align}
</s>