<s>[INST] Calculating the integral $\int \sqrt{1+\sin x}\, dx$. I want to calculate the integral $\int \sqrt{1+\sin x}\, dx$. 
I have done the following:
\begin{equation*}\int \sqrt{1+\sin x}\, dx=\int \sqrt{\frac{(1+\sin x)(1-\sin x)}{1-\sin x}}\, dx=\int \sqrt{\frac{1-\sin^2 x}{1-\sin x}}\, dx=\int \sqrt{\frac{\cos^2x}{1-\sin x}}\, dx=\int \frac{\cos x}{\sqrt{1-\sin x}}\, dx\end{equation*} 
We substitute $$u=\sqrt{1-\sin x} \Rightarrow du=\frac{1}{2\sqrt{1-\sin x}}\cdot (1-\sin x)'\, dx \Rightarrow du=-\frac{\cos x}{2\sqrt{1-\sin x}}\, dx \\ \Rightarrow  -2\, du=\frac{\cos x}{\sqrt{1-\sin x}}\, dx $$ 
We get the following: 
\begin{equation*}\int \frac{\cos x}{\sqrt{1-\sin x}}\, dx=\int(-2)\, du=-2\cdot \int 1\, du=-2u+c\end{equation*} 
Therefore \begin{equation*}\int \frac{\cos x}{\sqrt{1-\sin x}}\, dx=-2\sqrt{1-\sin x}+c\end{equation*} 
In Wolfram the answer is a different one. What have I done wrong? 
 [/INST] You have $$\begin{equation*}\int \sqrt{1+\sin x}\, dx=\int \sqrt{\frac{(1+\sin x)(1-\sin x)}{1-\sin x}}\, dx=\int \sqrt{\frac{1-\sin^2 x}{1-\sin x}}\, dx=\int \sqrt{\frac{\cos^2x}{1-\sin x}}\, dx=\int \frac{\cos x}{\sqrt{1-\sin x}}\, dx\end{equation*}$$ which is true up to your last equality where you forgot your $\sqrt {cos^2x}=|cos(x)|$ and replaced it with  $\sqrt {cos^2x}=cos(x)$
</s>