<s>[INST] Problem with $\int \frac{\sin^{3}x+\cos^{3}x}{\sin{x}\cos{x}} \text{dx}$ I wrote 
\begin{eqnarray}
I 
&=& \int \frac{\sin^{3}x+\cos^{3}x}{\sin{x}\cos{x}} \text{dx}\\
&=& 
\int \frac{\sin^{3}x}{\sin{x}\cos{x}}\text{dx}+\int \frac{\cos^{3}x}{\sin{x}\cos{x}}\text{dx}\\
 &=& 
 \int \frac{\sin^{2}x}{\cos^2{x}}\cos{x}\text{dx}+\int \frac{\cos^{2}x}{\sin^2{x}}\sin{x}\text{dx}\\
 &=& 
 \int \frac{\sin^{2}x}{1-\sin^2{x}}\cos{x}\text{dx}+\int \frac{\cos^{2}x}{1-\cos^2{x}}\sin{x}\text{dx}\\
&=&
\int\frac{u^2}{1-u^2}du-\int\frac{m^2}{1-m^2}dm\\
&=&
\color{blue}{\int\frac{u^2}{1-u^2}du-\int\frac{u^2}{1-u^2}du}\\
&=&
0
\end{eqnarray}
and Other
Let $x=\dfrac{\pi}{2}-t$ so
$$I=\int \frac{\sin^{3}x+\cos^{3}x}{\sin{x}\cos{x}} \text{dx}=-\int \frac{\sin^{3}t+\cos^{3}t}{\sin{t}\cos{t}} \text{dt}=-I$$
but correct answer is 
$$
I=\ln\left|\dfrac{1+\tan\dfrac{x}{2}}{1-\tan\dfrac{x}{2}}\right|+\ln\left|\tan\dfrac{x}{2}\right|-\sin x+\cos x+C
$$

Question.1 Where is wrong.?
Question.2 what conditions guarantee that our changing variable in indefinite integrals doesn't change our final solutions!.

 [/INST] Note that 
$$\begin{align}
\int \frac{u^2}{1-u^2}\,du&=-u+\frac12\log\left|\frac{1-u}{1+u}\right|+C\\\\
&=-\sin(x)+\frac12\log\left|\frac{1-\sin(x)}{1+\sin(x)}\right|+C
\end{align}$$
and similarly for $\int \frac{m^2}{1-m^2}\,dm$ with $m=\cos(x)$, and not $\sin(x)$.

NOTE $1$:

We need to be preserve the separate identities of the transformations $u \to \sin(x)$ and $m\to \cos(x)$ throughout the analysis.  That is to say, that $u$ is not simply a "dummy" integration variable inasmuch as it represents $\sin(x)$, and not $\cos(x)$. 

Naturally, both are $u$ and $m$ are "dummy" variables in the sense that we could use other symbols to represent the transformation.  But, it is of critical importance to distinguish the two different transformations by the corresponding pair of symbols used as new variables. 

NOTE $2$:

One way to clarify things is to turn the indefinite integral into a definite one.  The separate substitutions lead to distinct integration limits.

So, let's look at the integrals $\int_a^b \frac{\sin^2(x)}{1-\sin^2(x)}\cos(x)\,dx$ and $\int_a^b \frac{\cos^2(x)}{1-\cos^2(x)}\sin(x)\,dx$.  Upon enforcing the proposed substitutions we arrive at  
$$\begin{align}
\int_a^b \frac{\sin^2(x)}{1-\sin^2(x)}\cos(x)\,dx=\int_{\sin(a)}^{\sin(b)} \frac{u^2}{1-u^2}\,du\tag 1
\end{align}$$
and
$$\begin{align}
\int_a^b \frac{\cos^2(x)}{1-\cos^2(x)}\sin(x)\,dx=-\int_{\cos(a)}^{\cos(b)} \frac{u^2}{1-u^2}\,du \tag 2
\end{align}$$
Clearly, $(1)$ and $(2)$ do not add to zero.

NOTE $3$:  
The indefinite integral (antiderivative), $F(x)$, of a function $f$, can be more clearly written $F(x)=\int_a^x f(t)\,dt+C$ (for a suitable number $a$).  This can help to avoid the potential pitfall that comes from the notation $F(x)=\int f(x)\,dx$.
</s>