<s>[INST] 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 ?
 [/INST] 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}$$
</s>