Where am I going wrong with my proof $\int( \sin x +\cos x) dx=0$ Let's make the substitution $x=\frac{\pi}{2}-u$ to evaluate
$$I=\int (\sin x +\cos x) dx$$
After substituting, the integral becomes
$$
I=-\int (\cos u +\sin u)du=-I \implies I=0$$
What was wrong?
 A: You should keep track of the variable and the constant for these indefinite integrals.
So if the first $I$ is $I(x)$, then $\int(\cos u+\sin u)du=I(u)$. So you have $I(x)=-I(u)+C=-I\left(\frac{\pi}{2}-x\right)+C$. It is true that $I(x)+I\left(\frac{\pi}{2}-x\right)$ is a constant for any particular antiderivative $I(x)$.
A: Though it is not commonly said, when you use $ u$ substitution, you transform both the integral and the set you are integrating over. After the substitution which you have made, the domain you are integrating over has changed even though it is still an indefinite integral. So, it's not really possible to say that the substituted integral is the negative of the original one.
If we were to use this indefinite integral for finding area over some bounds.... sometimes... in 'nice' circumstances, it may actually turn out that what you did is correct. Due to the transformed bounds being equivalent to the original bounds.
Eg:
$$ \int_0^a f(x) dx =  \int_0^a f(a-x) dx$$
Is a property that holds for all integrals.. to prove it simply put $x=a-t$ in the first integral. Indefinite integrals we can interchange variables without losing meaning since once we figure out the bounds, the variable which denotes it with is pointless. For example, I could put keep   in every place of x in the previous statement and it would have the same amount of meaning as before.
Eg:
$ \int_0^a $ f() d   $= \int_0^a$ f(a- ) d 
Has all the same meaning as the previous statement.
A: With an indefinite integral, you cannot simply treat the new variable after substitution as a dummy variable.
Let the primitive you get after integration be $F$.
So what you basically showed is that $F(x) = -F(u)$, which is completely correct once you work out the form of the primitive and put $u =\frac{\pi}{2} -x$.
Actually, there is another aspect to indefinite integration, and that's the constant of integration, which can change after a substitution. So what you really should write is that $F(x) +c_1 = -F(u)+c_2$ but that doesn't matter in this particular case because you'll find that $c_1 = c_2$. But in another case, they may be different.
You might be getting confused with definite integrals, where you have bounds (which also get transformed with the substitution). In that case, you can treat the variable of integration as a dummy variable and doing algebraic manipulations and comparisons as you did would be correct because the form of the primitive would be the same, and what you're asserting is $F(b) - F(a) = - (F(B) - F(A))$, where $a, b$ are the initial bounds and $A, B$ are the respective transformed bounds after the substitution.
A: Imagine you have bounds on the integral:
$$I=\int_{a}^{b}sin(x) + cos(x)dx$$
Doing your substitution $u=\frac{\pi}{2} - x$ you get:
$$I=-\int_{\frac{\pi}{2}-a}^{\frac{\pi}{2}-b}{cos(u)+sin(u)}du$$
Note that the bounds of the integral changed. This is the fundamental problem with what you did. The bounds changing messes with the integral.
The problem with your proof is that you treated $I$ as a function, specifically the antiderivative of $\int{sin(x)+cos(x)}dx$. But that isn’t one specific function, it’s a set of functions, it equals
$$sin(x)-cos(x)+C$$
Where $C$ can be any number. So it’s hard to manipulate the antiderivative of a function because it isn’t necessarily one thing, it’s prone to cause weirdness. That’s why we usually make sure there are bounds on an integral when we set it equal to $I$
A: The problem is $\frac{\pi}{2}-u$ has a negative derivative with respect to $u$. If you consider a definite integral instead of an indefinite one, you will realise that swapping the extrema of integration compensates the minus sign appeared in the substitution.
