<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] Let's ignore the missing minus sign in line (3) (since $\mathrm{d}u = - \mathrm{d}x$).  Instead let's inspect the method.  
The short version: Once you establish a relation between $x$ and $u$, you have established it.  You do not get to change that relation without implicitly reducing the domain of validity to the simultaneous solution set of the multiple relations.
Let's start with something we all know.
$$  \int x \,\mathrm{d}x = \frac{1}{2}x^2 + C \text{.}  $$
And let's perform your change of variable (and because I noted it above, I'll include the minus sign), $x = \frac{\pi}{2} - u$, so $\mathrm{d}x = - \mathrm{d}u$:
\begin{align*}
-\int \left(\frac{\pi}{2} - u \right) \,\mathrm{d}u = \frac{-\pi u + u^2}{2} + C  \text{.}
\end{align*}
This is very different from the previous answer (even accounting for the "elastic" nature of "${}+C$" to produce and absorb specific constant expressions).  Why?  Because you have already established that $x = \frac{\pi}{2} - u$.  We are not free to switch to $u = x$ (unless we really only want an expression that works at only one point, where $u = x = \frac{\pi}{2} - u$, that is, at $u = \pi/4$).
So a customer walks into our math shop asking for the antiderivative of something in terms of $x$.  We give them an answer involving $u$s.  They presume we have had a stroke since we are speaking gibberish.  To respond to the customer, we must switch back to the variables they asked about and we have already established the relation between $x$ and $u$.  Therefore, we have \begin{align*}
\int x \,\mathrm{d}x
    &= -\int \left(\frac{\pi}{2} - u \right) \,\mathrm{d}u  \\
    &= \frac{-\pi u + u^2}{2} + C  \\
    &= \frac{-\pi \left( \frac{\pi}{2} - x \right)  + \left( \frac{\pi}{2} - x \right)^2}{2} + C  \\
    &= \frac{-\pi^2 + 4x^2}{8} + C  \\
    &= \frac{x^2}{2} + C  \text{,}
\end{align*}
where here we have let $C$ absorb the constant $-\pi^2/8$.
</s>