Verify $\int\sec x\ dx=\frac12 \ln \left\lvert\frac{1+\sin x}{1-\sin x}\right\rvert + C$

Question says it all, how can I verify the following?
$$\int\sec x\ dx=\frac12 \ln \left|\frac{1+\sin x}{1-\sin x}\right| + C$$

Solutions Collecting From Web of "Verify $\int\sec x\ dx=\frac12 \ln \left\lvert\frac{1+\sin x}{1-\sin x}\right\rvert + C$"

+1) For verification, follows Dr MV’s suggestion, for actually finding the antiderivative, multiply top and bottom with $\cos x$, apply the Pythagorean Identity in the denominator and then do a $u$-sub $\cos x=u$. With partial fraction decomposition you can work towards your antiderivative. This is one of the many, many, MANY ways to do your integral. Just for fun, here is a different approach:
A non-traditional method to do the integral, here are the steps:
\frac{1}{\cos x}&=\frac{1}{\cos x}+\frac{\sin x}{\cos x}-\frac{\sin x}{\cos x}\\
&=\frac{1+\sin x}{\cos x}-\frac{\sin x}{\cos x}\\
&=\frac{(1+\sin x)\cos x}{\cos^2x}-\frac{\sin x}{\cos x}\\
&=\frac{(1+\sin x)\cos x}{1-\sin^2x}-\frac{\sin x}{\cos x}\\
&=\frac{(1+\sin x)\cos x}{(1-\sin x)(1+\sin x)}-\frac{\sin x}{\cos x}\\
&=\frac{\cos x}{1-\sin x}-\frac{\sin x}{\cos x}
Integrating gives $-\ln|1-\sin x|+\ln|\cos x|$ and combining gives $\ln|\frac{\cos x}{1-\sin x}|$. Now inside the $\ln$ multiply top and bottom by $\cos x$ and perform Pythagorean Identity in the numerator to ultimately arrive at the known result.

Here’s one way to verify the result
$$\frac12 \frac{d}{dx}\ln \left|\frac{1+\sin x}{1-\sin x}\right| + 0$$
$$=\frac12 \left(\frac{d}{dx}\ln \left|1+\sin x\right|-\frac{d}{dx}\ln\left|1-\sin x\right|\right)$$
$$=\frac12\left(\frac{0+\cos x}{1+\sin x}-\frac{0-\cos x}{1-\sin x}\right)$$
$$=\frac{\cos x}{2}\left(\frac{1}{1+\sin x}+\frac{1}{1-\sin x}\right)$$
$$=\frac{\cos x}{(1+\sin x)(1-\sin x)}$$
$$=\frac{\cos x}{1-\sin^2 x}=\frac{1}{\cos x}=\sec x$$

You can verify this by integrating $\sec (x)$ and applying some trig identities:

LHS &=
\int \sec(x) \; \mathrm{d}x \\
&= \int \sec(x) \left ( \frac{\sec (x) + \tan (x)}{\sec (x) + \tan (x)} \right ) \; \mathrm{d}x \\
&= \int \frac{\sec^2 (x) + \sec (x) \tan (x)}{\sec (x) + \tan (x)} \; \mathrm{d}x \\
&= \int \frac{1}{u} \; \mathrm{d}u \tag{using $u=\sec (x) + \tan (x)$ as substitution} \\
&= \ln \left \lvert u \right \rvert + C \\
&= \ln \left \lvert \sec (x) + \tan (x) \right \rvert + C \\
&= \ln \left \lvert \frac{1+\sin (x)}{\cos (x)} \right \rvert + C \\
&= \ln \left \lvert \left ( \frac{\left (1+\sin (x) \right )^2}{\cos^2 (x)} \right )^{\frac{1}{2}}\right \rvert + C \\
&= \frac{1}{2} \ln \left \lvert \frac{\left (1+\sin (x) \right )^2}{\cos^2 (x)} \right \rvert + C \\
&= \frac{1}{2} \ln \left \lvert \frac{\left (1+\sin (x) \right )^2}{ 1- \sin^2 (x)} \right \rvert + C \\
&= \frac{1}{2} \ln \left \lvert \frac{\left (1+\sin (x) \right )^2}{\left ( 1- \sin (x) \right ) \left ( 1 + \sin (x) \right )} \right \rvert + C \\
&= \frac{1}{2} \ln \left \lvert \frac{1+\sin (x)}{ 1- \sin (x) } \right \rvert + C = RHS \tag*{Q.E.D.}

We have
\sec^2 x&=& \tan^2 x + 1\\
\sec^2 – \tan^2x&=& 1\\
(\sec x + \tan x)(\sec x – \tan x)&=&1\\
(\sec x + \tan x)^2(\sec x – \tan x)&=&\sec x + \tan x\\
(\sec x + \tan x)^2&=&\frac{\sec x + \tan x}{\sec x – \tan x}\\
\mid\sec x + \tan x\mid&=&\bigg(\frac{\sec x + \tan x}{\sec x – \tan x}\bigg)^\frac{1}{2}\\
\ln\mid\sec x + \tan x\mid&=&\ln\bigg(\frac{\sec x + \tan x}{\sec x – \tan x}\bigg)^\frac{1}{2}\\
\ln\mid\sec x + \tan x\mid&=&\frac{1}{2}\ln\bigg(\frac{\sec x + \tan x}{\sec x – \tan x}\bigg)\\

Now all that needs to be done is to show that
$$\int\sec x dx = \ln\mid\sec x + \tan x\mid+C$$
$$\frac{\sec x + \tan x}{\sec x + \tan x}=1\implies \sec x = \frac{\sec^2 x+\sec x\tan x}{\sec x+\tan x}$$

If you are familiar with the inverse hyperbolic functions and their properties I will provide a solution in blink of an eye, with the substitution $u=\sin x$ :

$$\int\sec x \;\mathrm{d}x\!=\!\int\frac{\mathrm{d}x}{\sqrt{1-\sin^2 x}}\!=\!\begin{vmatrix}u=\sin x \\ \mathrm{d}x\!=\!\frac{\mathrm{d}u}{\sqrt{1-u^2}}\end{vmatrix}\!=\!\int\frac{\mathrm{d}u}{1-u^2}\!=\operatorname{arctanh}u = \frac{1}{2}\ln\left|\frac{1+\sin x}{1-\sin x}\right|+C $$