How to integrate $\int\sqrt{\frac{4-x}{4+x}}$? Let 
$$g(x)=\sqrt{\dfrac{4-x}{4+x}}.$$
I would like to find the primitive of $g(x)$, say $G(x)$.
I did the following: first the domain of $g(x)$ is $D_g=(-4, 4]$. Second, we have
\begin{align}
G(x)=\int g(x)dx &=\int\sqrt{\dfrac{4-x}{4+x}}dx\\
                 &=\int\sqrt{\dfrac{(4-x)(4-x)}{(4+x)(4-x)}}dx\\
                 &=\int\sqrt{\dfrac{(4-x)^2}{16-x^2}}dx\\
                 &=\int\dfrac{4-x}{\sqrt{16-x^2}}dx\\
                 &=\int\dfrac{4}{\sqrt{16-x^2}}dx-\int\dfrac{x}{\sqrt{16-x^2}}dx\\
                 &=\int\dfrac{4}{\sqrt{16(1-x^2/16)}}dx+\int\dfrac{-2x}{2\sqrt{16-x^2}}dx\\
                 &=\underbrace{\int\dfrac{1}{\sqrt{1-(x/4)^2}}dx}_{\text{set $t=x/4$}}+\sqrt{16-x^2}+C\\
                 &=\underbrace{\int\dfrac{4}{\sqrt{1-t^2}}dt}_{\text{set $t=\sin \theta$}}+\sqrt{16-x^2}+C\\
                 &=\int\dfrac{4\cos\theta}{\sqrt{\cos^2\theta}}d\theta+\sqrt{16-x^2}+C\\
\end{align}
So finally, I get 
$$G(x)=\pm\theta+\sqrt{16-x^2}+C'.$$
With wolframalpha I found some different answer. Could you provide any suggestions?
Also, multiplying by $4-x$ is it correct at the beginning? because I should say then that $x\neq 4$.
 A: First of all, you are right that there is trouble in multiplying by $\frac{4-x}{4-x}$ when $x=4$. But why bother with the domain $\langle-4,4]$ in the first place? You can change the integrand at one point without changing integral, so that one point is irrelevant. Thus, choose $D_g = \langle-4,4\rangle$. 
The only other issue is the one that I already mentioned in the comments. If you substitute $t = \sin\theta \in\langle -1,1\rangle$, just choose $\theta$ to be in $\langle-\frac\pi 2,\frac\pi 2\rangle$ (substitution is natural bijection that way). Then you have that $\cos\theta>0$, and thus $\sqrt{\cos^2\theta}=\cos\theta$.
So, your final result should be $$4\theta + \sqrt{16-x^2} + C = 4\arcsin\frac x4 + \sqrt{16-x^2} + C$$ and if you differentiate it, you can see that the result is just fine.
Although your procedure is fine, in this case you might want to make trigonometric substitution much sooner:
$$\int\sqrt{\frac{4-x}{4+x}}\,dx = \int\frac{4-x}{\sqrt{16-x^2}}\, dx = [x = 4\sin t] =\int \frac{4-4\sin t}{4\cos t}\cdot 4\cos t\, dt=\\ = 4(t+\cos t)+C = 4\arcsin\frac x4 +4\cos(\arcsin\frac x4) + C = 4\arcsin\frac x4 +4\sqrt{1-\frac{x^2}4} + C$$
A: Solving a more general problem, using integration by parts:
$$\mathcal{I}_\text{n}\left(x\right)=\int\sqrt{\frac{\text{n}-x}{\text{n}+x}}\space\text{d}x=x\sqrt{\frac{\text{n}-x}{\text{n}+x}}+\text{n}\int\frac{x}{\left(\text{n}+x\right)^2\sqrt{\frac{2\text{n}}{\text{n}+x}-1}}\space\text{d}x$$
Now, substitute $\text{u}=\text{n}+x$ and $\text{d}\text{u}=\text{d}x$:
$$\int\frac{x}{\left(\text{n}+x\right)^2\sqrt{\frac{2\text{n}}{\text{n}+x}-1}}\space\text{d}x=\int\frac{\text{u}-\text{n}}{\text{u}^2\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}$$
Seperate the integral:
$$\int\frac{\text{u}-\text{n}}{\text{u}^2\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}=\int\frac{\text{u}}{\text{u}^2\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}-\int\frac{\text{n}}{\text{u}^2\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}=$$
$$\int\frac{1}{\text{u}\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}-\text{n}\int\frac{1}{\text{u}^2\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}$$
So:


*

*$$\int\frac{1}{\text{u}\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}=\int\frac{1}{\sqrt{\text{u}}\sqrt{2\text{n}-\text{u}}}\space\text{d}\text{u}=2\arcsin\left\{\frac{\sqrt{\text{u}}}{\sqrt{2}\sqrt{\text{n}}}\right\}+\text{C}_1$$

*Substitute $\text{s}=\frac{2\text{n}}{\text{u}}-1$ and $\text{d}\text{s}=-\frac{2\text{n}}{\text{u}^2}\space\text{d}\text{u}$:
$$\int\frac{1}{\text{u}^2\sqrt{\frac{2\text{n}}{\text{u}}-1}}\space\text{d}\text{u}=-\frac{1}{2\text{n}}\int\frac{1}{\sqrt{\text{s}}}\space\text{d}\text{s}=\text{C}_2-\frac{\sqrt{\frac{2\text{n}}{\text{u}}-1}}{\text{n}}$$

A: Substitute $x=4\frac{1-y^2}{1+y^2}$ so that $y=\sqrt{\frac{4-x}{4+x}}$:
$$
\begin{align}
\int\sqrt{\frac{4-x}{4+x}}\,\mathrm{d}x
&=4\int y\,\mathrm{d}\frac{1-y^2}{1+y^2}\\
&=-16\int\frac{y^2}{\left(1+y^2\right)^2}\,\mathrm{d}y\\
&=-16\int\frac{\tan^2(\theta)}{\sec^2(\theta)}\,\mathrm{d}\theta\\
&=-16\int\sin^2(\theta)\,\mathrm{d}\theta\\
&=-16\int\frac{1-\cos(2\theta)}2\,\mathrm{d}\theta\\
&=-8\theta+4\sin(2\theta)+C\\
&=-8\theta+8\frac{\tan(\theta)}{\sec^2(\theta)}+C\\
&=-8\tan^{-1}\left(\sqrt{\frac{4-x}{4+x}}\right)+\sqrt{16-x^2}+C
\end{align}
$$
