Wolframalpha step-by-step of $\int\frac{\cos(x)}{\sqrt{2+\cos(2x)}}dx$ I wonder, where the minus sign goes after the first $u$-substitution of integral  $\displaystyle\int\frac{\cos(x)}{\sqrt{2+\cos(2x)}}dx$?

Integrate
$$\int \frac{\cos x}{\sqrt{2+\cos(2x)}}dx$$
Known Identity
$$\cos(2x)=1-2\sin^2(x)$$
Replacing
$$\int \frac{\cos x}{\sqrt{3-2\sin^2(x)}}dx$$
Let $u = \sin(x)$, $du = \cos(x)dx$
Substituting
$$\int \frac{u}{\sqrt{3-2u^2}}du$$
Let $z = \sqrt{3-2u^2}$
$$dz = \frac{1}{2}\frac{-4u}{\sqrt{3-2u^2}}du$$
$$dz = -\frac{2u}{\sqrt{3-2u^2}}du$$
Substituting
$$-\int \frac{1}{2}dz$$
$$=-\frac{z}{2} + C$$
Substituting back
$$=- \frac{1}{2} \sqrt{- 2 u^{2} + 3}+ C$$
Substituting back $u = \sin(x)$
$$=-\frac{1}{2}\sqrt{-2\sin^2(x)+3}+ C$$
Simplifying 
$$=-\frac{1}{2}\sqrt{2(1-\sin^2(x))+1}+ C$$
$$=-\frac{1}{2}\sqrt{2\cos^2(x)+1}+ C$$
$$=-\frac{1}{2}\sqrt{1+2\cos^2(x)}+ C$$
