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

could you help me on this integral ?

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

Here's what I've started :

$$\int \frac{1}{\cos(x)}\,\mathrm dx = \int \frac{\cos(x)}{\cos(x)^2}\,\mathrm dx = \int \frac{\cos(x)}{1-\sin(x)^2}\,\mathrm dx$$

Now, I did : $$u = \sin(x)$$, so $$\mathrm du = 1$$.

Now I have :

$$\int \frac{\text{???}}{1-u^2}\,\mathrm du$$

But at this point, I think I did the most of the job but I'm stuck. Could you help me to solve this integral please (to the integration by substitution at the end) ?

Thanks

EDIT :

Now I follow the steps and I got :

$$\int \frac{1}{1-u^2}\,\mathrm du$$ Doing the partial fraction I got $$A = 1/2$$ and $$B = 1/2$$.

So basically I have :

\begin{align} & \int \frac{1}{1-u^2}\,\mathrm du = \int \frac{1/2}{1+u}\,\mathrm du + \int \frac{1/2}{1-u}\,\mathrm du \\[8pt] = {} & \frac 1 2 \left(\int \frac{1}{1+u} \, du - \int \frac{1}{1-u} \, du\right) \\[8pt] = {} & \frac 1 2 \ln\left(\frac{1+u}{1-u}\right) = \ln\left(\left(\frac{1+\sin(x)}{1-\sin(x)}\right)^{1/2}\right) \\[8pt] = {} & \ln \left(\frac{\sqrt{1+\sin(x)}}{\sqrt{1-\sin(x)}}\right) = \ln\left(\frac{\sqrt{1+\sin(x)}}{\sqrt{\cos(x)^2}}\right) \\[8pt] = {} & \ln\left(\frac{\sqrt{1+\sin(x)}}{\cos(x)}\right) \end{align}

Here's what my teacher got :

What's wrong with what I did ? Did I miss something ?

• $du=\cos x\,dx$, which brings you to $\int\frac{du}{1-u^2}$. Now use partial fractions. Commented Jun 13, 2013 at 7:43
• @AndréNicolas Thanks for the hint. Could you see my edit please ? Commented Jun 13, 2013 at 8:31
• @user2336315 Note that since: $$\sec x + \tan x = \dfrac{1}{\cos x} + \dfrac{\sin x}{\cos x} = \dfrac{1+\sin x}{\cos x}$$ this is equivalent to my answer. Looking at your work, you should have done: $$\sqrt{\dfrac{1+\sin x}{1 - \sin x}} = \sqrt{\dfrac{1+\sin x}{1 - \sin x} \cdot \dfrac{1+\sin x}{1 + \sin x}} = \sqrt{\dfrac{(1+\sin x)^2}{1 - \sin^2 x}} = \sqrt{\dfrac{(1+\sin x)^2}{\cos^2 x}} = \dfrac{1+\sin x}{\cos x}$$ Commented Jun 13, 2013 at 9:18
• @Adriano Nice ! Commented Jun 13, 2013 at 9:38
• Towards the end, when you "multiplied top and bottom by $1+\sin x$" you forgot to multiply the top. By the way, the conventional way of putting it is $\ln(|\sec x+\tan x|)$ and there is a quick excessively magic way to do it all in one line. Commented Jun 13, 2013 at 14:18

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}$$

• whilst this is a well-known method, it is difficult to do if you do not know it Commented Oct 4, 2018 at 12:45

\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}

• Thanks ! Upvoted ! Could you see my edit please ? Commented Jun 13, 2013 at 8:31
• I don't get you. What do you mean by add its constant ? Commented Jun 13, 2013 at 8:40

I know this is an old post but I spotted the mistake in your solution after the edit.

You wrote 1-sin(x) = cos(x)^2 (which is wrong for obvious reasons)

• This would probably be better as a comment (I think). Commented Dec 13, 2015 at 21:37
• I didn't downvote by the way. Commented Dec 13, 2015 at 21:38

You can also remember that :$1/\cos(x)=\sec(x)$

• What good will that do? ${}\qquad{}$ Commented Dec 13, 2015 at 20:20

$$\frac{\sqrt{1+\sin(x)}}{\sqrt{1-\sin(x)}} = \frac{\sqrt{1+\sin(x)}\sqrt{1+\sin(x)}}{\sqrt{1-\sin(x)}\sqrt{1+\sin(x)}} = \frac{1+\sin(x)}{\sqrt{\cos(x)^2}} =\text{etc.}$$

Here is another try: $$I=\int\sec(x)dx=\int\frac{1}{\cos(x)}dx$$ now $$u=\cos(x)$$ so $$dx=\frac{du}{-\sin(x)}$$ then: $$I=-\int\frac{1}{\sqrt{1-u^2}u}du$$ then we can use $$v=1-u^2$$ so $$du=\frac{dv}{-2u}$$ and the integral becomes: $$I=\frac{1}{2}\int\frac{1}{v(1-v)}dv$$ and by using partial fraction decomposition we can obtain: $$\frac{1}{v(1-v)}=\frac{1}{v}+\frac{1}{1-v}$$ and so our integral becomes: $$I=\frac{1}{2}\int\frac{1}{v}+\frac{1}{1-v}dv=\frac{1}{2}\ln|\frac{v}{1-v}|+C=\frac{1}{2}\ln|\frac{1-u^2}{u^2}|+C=\frac{1}{2}\ln|\frac{1-\cos^2(x)}{\cos^2(x)}|+C$$ although this looks wrong to me

Notice how$$\left[\sec x\right]’_x=\sec x\tan x$$$$\left[\tan x\right]’_x=\sec^2 x$$A factor of $$\sec x$$ shows up in both results of the derivative! Adding the two equations together gives$$\left[\sec x\right]’_x+\left[\tan x\right]’_x=\sec x(\tan x+\sec x)$$Divide both sides by $$\sec x+\tan x$$ and integrate with respect to $$x$$. The right-hand side becomes the integral you’re looking\begin{align*}\int\mathrm dx\,\sec x & =\int\mathrm dx\,\frac {\left[\sec x\right]’_x+\left[\tan x\right]’_x}{\tan x+\sec x}\\ & =\int\frac {\mathrm du}u\\ & =\log(\sec x+\tan x)+C\end{align*}

\begin{aligned} \int \sec d x &=\int \frac{\cos x}{\cos ^{2} x} d x \\ &=\int \frac{1}{(1+\sin x)(1-\sin x)} d(\sin x) \\ &=\frac{1}{2} \int \left(\frac{1}{1-\sin x}+\frac{1}{1+\sin x}\right) d (\sin x) \\ &=\frac{1}{2} \ln \left|\frac{1+\sin x}{1-\sin x} \right| +C \\ &=\frac{1}{2} \ln \left|\frac{(1+\sin x)^{2}}{\cos ^{2} x}\right| +C\\ &=\ln \left|\frac{1+\sin x}{\cos x}\right| +C\\&=\ln |\sec x+\tan x|+C \end{aligned}

$$\displaystyle \frac{1}{\cos{x}}=\frac{\cos{x}}{\cos^{2}{x}}=\frac{\cos{x}}{1-\sin^{2}{x}}$$

$$\displaystyle \sin{x}=u\Rightarrow du=\cos{x} dx$$

$$\displaystyle \frac{dx}{\cos{x}}=\frac{\ du}{1-\ u^{2}}=\frac{1}{2}(\frac{1}{u-1}-\frac{1}{u+1})$$

$$\displaystyle \int\frac{dx}{\cos{x}}=\ln\sqrt{ \frac{{\sin{x}-1}}{{\sin{x}+1}}}+c$$

Actually, the standard approach (Euler formula) when integrating trigonometric functions can be used, but it will take a different form, i.e., \begin{align} \int{\frac{1}{\cos x}dx}&=\int\frac{2e^{ix}}{e^{2ix}+1}dx\\ &=-2i\tan^{-1}(e^{ix})+C\\ &=\ln\left|\frac{1-ie^{ix}}{1+ie^{ix}}\right|+C \end{align}

which is equivalent to $$\ln\sqrt{\left|\frac{\sin x+1}{\sin x-1}\right|}+C$$ since \begin{align} \sqrt{\left|\frac{\sin x+1}{\sin x-1}\right|}= \sqrt{\left|\frac{e^{ix}-e^{-ix}+2i}{e^{ix}-e^{-ix}-2i}\right|}= \sqrt{\left|\frac{e^{2ix}-1+2ie^{ix}}{e^{2ix}-1-2ie^{ix}}\right|}= \sqrt{\left(\frac{e^{ix}+i}{e^{ix}-i}\right)^2}=\left|\frac{1-ie^{ix}}{1+ie^{ix}}\right| \end{align}