How to integrate $\int \frac{1}{\cos(x)}\,\mathrm dx$

Alternatively, observe that: $$ \int \dfrac{1}{\cos x} dx = \int \sec x~dx = \int \sec x \left(\dfrac{\sec x + \tan x}{\sec x + \tan x}\right) dx = \int\dfrac{\sec^2 x + \sec x \tan x}{\sec x + \tan x} dx $$ Now let $u=\sec x + \tan x$ so that $du = (\sec x \tan x + \sec^2x)~dx$. Then we obtain: $$ \int\dfrac{(\sec x \tan x + \sec^2 x)~dx}{\sec x + \tan x} = \int \dfrac{du}{u}=\ln|u|+C= \boxed{\ln|\sec x + \tan x|+C} $$


\begin{align} & \int\frac{1}{1-u^2}\,du=\frac12\int\left(\frac{1}{1+u}+\frac{1}{1-u}\right) \,du \\[8pt] = {} & \frac12(\ln(1+u)-\ln(1-u))+\color{red }{\ln c} = \ln\left(\color{red }{c}\sqrt{\frac{1+u}{1-u}} \, \right) \end{align}