Trignometric integral : $\int \frac{dx}{\sin x + \sec x}$

Another way:

$$\dfrac{2\cos x}{2+2\cos x\sin x}=\dfrac{\cos x-\sin x}{2+2\cos x\sin x}+\dfrac{\cos x+\sin x}{2+2\cos x\sin x}$$

As $\displaystyle\int(\cos x-\sin x)dx=\cos x+\sin x,$ write $2\cos x\sin x=(\cos x+\sin x)^2-1$ and set $\cos x+\sin x=u$

and as $\displaystyle\int(\cos x+\sin x)dx=\sin x-\cos x,$ write $2\cos x\sin x=1-(\sin x-\cos x)^2$ and set $\sin x-\cos x=v$


As Michael Wang commented $$A=(1+t^2)^2-2t(t^2-1)=t^4-2 t^3+2 t^2+2 t+1$$ Computing the roots of the quartic equation (all are complex), you end with $$A=\left(t^2+(\sqrt{3}-1)t-\sqrt{3}+2\right)\left(t^2-(\sqrt{3}+1) t+\sqrt{3}+2\right)$$ Partial fraction decomposition then leads to $$\dfrac{1-t^2}{(1+t^2)^2-2t(t^2-1)}=\frac{1+t}{t^2+(\sqrt{3}-1)t-\sqrt{3}+2}+\frac{1+t}{t^2-(\sqrt{3}+1) t+\sqrt{3}+2}$$ which makes the problem workable.

Edit

Being less lazy, write $$(t^2+at+b)(t^2+ct+d)-(t^4-2 t^3+2 t^2+2 t+1)=0$$ Expand and group terms to get $$(a+c+2)t^3+ (a c+b+d-2)t^2+ (a d+b c-2)t+(b d-1)=0$$ So the equations to be solved are $$a+c+2=0\tag 1$$ $$a c+b+d-2=0\tag 2$$ $$a d+b c-2=0\tag 3$$ $$bd-1=0\tag 4$$ Using $(4)$, then $d=\frac 1b$. Using $(1)$, then $c=-2-a$. Replace in $(2)$ to get $$\frac{a}{b}-(a+2) b-2=0\implies a=\frac{2 b}{1-b}$$ Now, plug everything in $(3)$ to get $$\frac{(b^2-4b+1) \left(b^2+1\right)}{(b-1)^2 b}=0\implies b^2-4b+1=0$$