<s>[INST] Integration of secant $$\begin{align}
\int \sec x \, dx 
&= \int \cos x \left(  \frac{1}{\cos^2x} \right)  \, dx \\
&= \int \cos x \left(  \frac{1}{1-\sin^2x} \right) \, dx \\
& = \int\cos x\cdot\frac{1}{1-\frac{1-\cos2x}{2}} \, dx \\
&= \int \cos x \cdot\frac{2}{1+\cos2x} \, dx 
\end{align}$$
I am stuck in here. Any help to integrate secant?
 [/INST] After $\int \cos x \left(\frac{1}{1-\sin^2x}\right)dx$ use the transformation $z = \sin x$ and $dz  = \cos x \, dx$.
Edit:
$$\int\frac{1}{1-u^2}\,du = \frac{1}{2}\int\frac{(1+u)+(1-u)}{(1+u)(1-u)} = \frac{1}{2} \int \frac{1}{1+u} + \frac{1}{1-u}\,du$$
And use, $\int \frac{1}{u}\,du = \ln|u|$
</s>