Can an indefinite integral evaluate to zero? 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 ?
 A: Let $$I =\int\frac{\sin x+\cos x}{\cos^2 x+\sin^4 x}dx$$
Now we can write $\cos^2 x+\sin^4 x = \sin^4 x-\sin^2 x+1 = \cos^4 x-\cos^2 x+1$
So $$I = \int\frac{\sin x}{\cos^4 x-\cos^2 x+1}dx+\int\frac{\cos x}{\sin^4 x-\sin^2 x+1}dx$$
Now put $\cos x=t\;,$ Then $\sin xdx = -dt$ and put $\sin x=u\;,$ Then $\cos dx = du$
So $$I = -\underbrace{\int\frac{1}{t^4-t^2+1}dt}_{J}+\underbrace{\int\frac{1}{u^4-u^2+1}du}_{K}$$
Now Let $$J = \int\frac{1}{t^4-t^2+1}dt = \frac{1}{2}\int\frac{(t^2+1)-(t^2-1)}{t^4-t^2+1}dt$$
So $$J =\frac{1}{2}\int\frac{t^2+1}{t^4-t^2+1}dt+\frac{1}{2}\int\frac{t^2-1}{t^4-t^2+1}dt$$
So $$J = \frac{1}{2}\int\frac{1+\frac{1}{t^2}}{\left(t-\frac{1}{t}\right)^2+1}+\frac{1}{2}\int\frac{1-\frac{1}{t^2}}{\left(t+\frac{1}{t}\right)^2+3}dt$$
So we get $$J = \tan^{-1}\left(\frac{t^2-1}{t}\right)+\frac{1}{2\sqrt{3}}\ln \left|\frac{t^2-\sqrt{3}t+1}{t^2+\sqrt{3}t+1}\right|$$
Same calculation for $J$
So we get $$I = -\tan^{-1}\left(\frac{\cos^2 x-1}{\cos x}\right)-\frac{1}{2\sqrt{3}}\ln \left|\frac{\cos^2 x-\sqrt{3}\cos x+1}{\cos^2 x+\sqrt{3}\cos x+1}\right|+\tan^{-1}\left(\frac{\sin^2 x-1}{\sin  x}\right)+\frac{1}{2\sqrt{3}}\ln \left|\frac{\sin^2 x-\sqrt{3}\sin x+1}{\sin^2 x+\sqrt{3}\sin  x+1}\right|+\mathcal{C}$$
A: 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.
