Problem : Evaluate $\displaystyle\int \frac{\sin x+\cos x}{\cos^2 x+\sin^4 x} \, dx $
I evaluated in the following way, and somehow got zero :
$$I=\int \frac{\sin x+\cos x}{\cos^2 x+\sin^2 x(1-\cos^2 x)} \, dx$$
$$I=\int \frac{\sin x}{\cos^2 x+\sin^2 x(1-\cos^2 x)}dx +\int \frac{\cos x}{\cos^2 x+\sin^2 x(1-\cos^2 x)} \,dx $$
$$I=\int \frac{\sin x}{1-\sin^2 x\cos^2 x} \, dx +\int \frac{\cos x}{1-\sin^2 x\cos^2 x} \, dx$$
$$I=I_1+I_2$$
Substituting $\cos x=t$ in $I_1$ and $\sin x=u$ in $I_2$
This gives : $$I_1=-\int \frac{1}{1-(1-t^2)t^2} \, dt $$ and $$I_2=\int \frac{1}{1-u^2(1-u^2)} \, du $$
Since $I_1=-I_2$, $I=0$
My textbook gives me the answer : $$I=\frac{1}{2\sqrt{3}}\log\left(\frac{\sqrt{3}+\sin x-\cos x}{\sqrt{3}-\sin x+\cos x}\right) + \tan^{-1}(\sin x-\cos x) + C$$ which seems to have involved the substitution $\sin x-\cos x=t$. I tried to simplify the denominator to make it a function of $(\sin x-\cos x)$ but I couldn't.
Could you please explain why my method did not work and how do I proceed to obtain the answer given ?
If you had, for example, $\displaystyle\int_0^{\pi/2}\!,$ then your $I_1$ would become $\displaystyle\int_0^1$ whereas $I_2$ would become $\displaystyle\int_1^0 = -\int_0^1$ and then $I_1-I_2$ would be $\displaystyle\int_0^1 - \left(-\int_0^1\right) = 2\int_0^1.$
But these are not definite integrals. One of them becomes $F(t) + C = F(\cos x)$ and the other $-F(u) = -F(\sin x) + C$, where $F$ is the same function in both cases. (And $C$ would in general not be the same in both cases.) So they don't cancel each other out even though $F$ is the same in both cases.