# Integral of $\frac1{\cos x}$ using t substitution

Okay, so I'm trying to find $\int \frac1{\cos x}\mathrm{d}x$ using the substitution $t = \tan\left(\frac{x}{2}\right)$.

I sub in the trig identity for $\sec$ as $\frac{1+t^2}{1-t^2}$ and then rearrange and substitute $\frac{\mathrm{d}t}{\mathrm{d}x} = \frac12 \left(1+ \tan^2\left(\frac{x}{2}\right)\right)$ so I am left with

$\frac2{1-t^2}$

I then used partial fractions to find

$\frac2{1-t^2} = \frac1{1+t} + \frac1{1-t}$

and therefore integrating I get

$\int \frac1{\cos x}dx = \ln(t+1) - \ln(t-1)$

But subbing in $t = \tan\left(\frac{x}{2}\right)$ doesn't seem to get me anywhere close to the solution that I want to find, which is:

$\int \frac1{\cos x}\mathrm{d}x = \ln(\sec x + \tan x) + C$

Any help on this would be greatly appreciated.

Thanks!

• You might find this question relevant: math.stackexchange.com/questions/6695 Nov 1, 2010 at 21:56
• This is a duplicate of math.stackexchange.com/questions/6695/… Nov 1, 2010 at 21:58
• It's not quite a copy, I'm asking a different question which although is similar, doesn't get answered in that thread. I didn't think it would be appropriate to ask a question in someone else's post. Nov 1, 2010 at 22:06

The problem equivocates to proving that $\left|\frac{t+1}{t-1}\right| = |\sec x + \tan x|$, where $t=\tan\frac x2$.

Using the fact that $\tan\frac x2 = \frac{1-\cos x}{\sin x}$, we get

$$\frac{t+1}{t-1} = \frac{1+\sin x-\cos x}{1-\sin x-\cos x} = \frac{\sec x+\tan x-1}{\sec x-\tan x-1}.$$

In addition, \begin{align}(\sec x+\tan x)(-1+\sec x-\tan x) &= -\sec x - \tan x +(\sec^2x-\tan^2x)\\ &= -(\sec x+\tan x-1),\end{align} which is what we wanted.

• Ahh Brilliant! Thank you! I strangely tried submitting back t and then applying the log rules but that just confused me a little. This makes so much sense! Thank you! Nov 1, 2010 at 22:34

Try writing $\sec x + \tan x$ in terms of $t$ and see if you can reorganize the two answers to agree. You may need to tweak the value of $C$ to do this.

• Thank you! A bit of guidance without the full answer is also nice! Learning how to solve it not just the solution really useful. Thanks! Nov 1, 2010 at 22:36

We know that $$\cos x=\frac{1-\tan^{2}\frac{x}{2}}{1+\tan^{2}\frac{x}{2} }=\frac{1-\tan^{2}\frac{x}{2}}{\sec^2 \frac{x}{2} }$$ Given that $$\int \frac{1}{\cos x}dx$$$$=\int \frac{1}{\frac{1-\tan^{2}\frac{x}{2}}{\sec^2 \frac{x}{2} }}dx$$ $$=\int \frac{\sec^2 \frac{x}{2}}{1- \tan^{2}\frac{x}{2}}dx$$ Let $$\tan \frac{x}{2}=t \implies \frac{1}{2}\sec^2\frac{x}{2}dx=dt \implies \sec^2\frac{x}{2}dx=2dt$$ Now , we have $$\int \frac{\sec^2 \frac{x}{2}}{1- \tan^{2}\frac{x}{2}}dx=\int \frac{2dt}{1- t^2}$$$$=\frac{2}{2}\ln\left|\frac{1+t}{1-t}\right|$$ $$=\ln\left|\frac{1+\tan \frac{x}{2}}{1-\tan \frac{x}{2}}\right|$$ $$=\ln\left|\frac{\cos \frac{x}{2}+\sin \frac{x}{2}}{\cos \frac{x}{2}-\sin \frac{x}{2}}\right|$$ $$=\ln\left|\frac{\left(\cos \frac{x}{2}+\sin \frac{x}{2}\right)\left(\cos \frac{x}{2}+\sin \frac{x}{2}\right)}{\left(\cos \frac{x}{2}-\sin \frac{x}{2}\right)\left(\cos \frac{x}{2}+\sin \frac{x}{2}\right)}\right|$$ $$=\ln\left|\frac{\cos^2\frac{x}{2}+\sin^2\frac{x}{2}+2\sin\frac{x}{2}\cos\frac{x}{2}}{\cos^2 \frac{x}{2}-\sin^2 \frac{x}{2}}\right|$$ $$=\ln\left|\frac{1+\sin x}{\cos x}\right|$$ $$\color{blue}{=\ln\left|\sec x+\tan x\right|+C}$$