<s>[INST] Why is this integration method not valid? Let $$I=\int \frac{\sin x}{\cos x + \sin x}\ dx \tag{1}$$
Now let $$u=\frac{\pi}{2} - x \tag{2}$$ so $$I=\int \frac{\sin (\frac{\pi}{2} - u)}{\cos (\frac{\pi}{2} - u)+\sin (\frac{\pi}{2} - u)}\ du \tag{3}$$
$$=\int\frac{-\cos u}{\sin u + \cos u} \ du \tag{4}$$
$$= \int\frac{-\cos  x}{\sin x + \cos x} \ dx \tag{5}$$
and hence $$2I=\int\frac{\sin x - \cos x}{\sin x + \cos x} \ dx \tag{6}$$
$$=-\ln\ |\sin x + \cos x| + c \tag{7}$$
$\implies I=-\frac{1}{2}\ln|\sin x + \cos x| + c \tag{8}$
But the actual answer is $$I= \frac{1}{2}x -\frac{1}{2}\ln|\sin x + \cos x| + c \tag{9}$$
according to Wolfram Alpha and supported by a different method.
Why does my method not yield the correct result?
 [/INST] An alternative change:
$$I=\int \frac{\sin \ x}{\cos \ x + \sin \ x}\ dx=\frac1{\sqrt{2}}\cdot \int \frac{\sin \ x}{\frac1{\sqrt{2}}\cos \ x + \frac1{\sqrt{2}}\sin \ x}\ dx=\frac1{\sqrt{2}}\cdot \int \frac{\sin \ x}{\sin \left(x+\frac{\pi}{4}\right)}\ dx.$$
Now let $u=x+\frac{\pi}{4}$, then:
$$I=\frac1{\sqrt{2}}\cdot \int \frac{\sin \left(u-\frac{\pi}{4}\right)}{\sin u}\ du=\frac12\int \frac{\sin u-\cos u}{\sin u}\ du=\frac{x}{2}-\frac12\int \frac{d\sin u}{\sin u}=\\
\frac x2-\frac12\ln |\sin u|+C=\frac x2-\frac12\ln |\sin \left(x+\frac{\pi}{4}\right)|+C=\\
\frac x2-\frac12 \ln |\frac1{\sqrt{2}}(\cos x+\sin x)+C=\frac x2-\frac12\ln |\cos x+\sin x|+\underbrace{\frac14\ln 2+C}_{A}.$$
Now, a simpler example:
$$\int \cos x \ dx \stackrel{x=\pi/2-u}=\int \cos \left(\frac{\pi}{2}-u\right)\cdot (-du)=\\
-\int \sin u \ du\stackrel{\ne -\int \sin x \ dx=\cos x+C}=\cos u+C=\\
\cos \left(\frac{\pi}{2}-x\right)+C=\sin x+C.$$
</s>