<s>[INST] Two methods of finding $\int_{0}^{\frac{\pi}{2}} \frac{dx}{1+\sin x}$ Two methods of finding $$I=\int_{0}^{\pi/2} \frac{dx}{1+\sin x}$$
Method $1.$ I used substitution, $\tan \left(\frac{x}{2}\right)=t$ we get
$$I=2\int_{0}^{1}\frac{dt}{(t+1)^2}=\left. \frac{-2}{t+1}\right|_{0}^{1} =1$$
Method $2.$ we have $$I=\int_0^{\pi/2}\frac{1-\sin x}{\cos ^2 x} \,\mathrm dx = \left. \int_0^{\pi/2}\left(\sec^2 x-\sec x\tan x\right)\,\mathrm dx= \tan x-\sec x\right|_0^{\pi/2}$$
What went wrong in method $2$?
 [/INST] \begin{align}
\tan x - \sec x & = \frac{\sin x -1}{\cos x} = \frac{(\sin x - 1)(-\sin x -1)}{(\cos x)(-\sin x - 1)} = \frac{1-\sin^2 x}{(\cos x)(-\sin x - 1)} \\[10pt]
& = \frac{\cos^2 x}{(\cos x)(-\sin x - 1)} = \frac{-\cos x}{1+\sin x} = \frac 0 2 \text{ if } x = \frac \pi 2.
\end{align}
Or you can use the identity
$$
\tan x \pm \sec x = \tan\left( \frac \pi 4 \pm \frac x 2 \right).
$$
</s>