# integral of $\sec x \tan x$

method 1:Substitution

$$\int \sec x\tan x dx=\int \frac{\sin x}{\cos ^2x}dx$$

Let $$u=\cos x \implies -du=\sin x dx$$

$$-\int \frac{1}{u^2}du=\frac{1}{u}+c$$

So $$\int \sec x\tan x dx=\frac{1}{\cos x}=\sec x+c$$

Method 2:integration by parts

$$\int \sec x\tan x dx=\int \sec ^2x\sin xdx$$

Let $$u=\sin x$$ and $$dv=\sec^2x dx \implies du=\cos x dx$$ and $$v=\tan x$$

$$\int \sec ^2x\sin xdx=\tan x \sin x-\int \tan x\cos x dx$$

$$=\tan x \sin x-\int \sin x dx$$

$$=\tan x \sin x+\cos x +c$$

I cannot tell where I went wrong especially with the second method.

• Always be aware that different methods can give different-looking expressions for the same result (or - for indefinite integration - the same result up to an additive constant, which is irrelevant because of the $+c$), especially if trigonometry gets involved because there are lots of trigonometric identities. – J.G. Apr 3 at 12:04

Nothing went wrong. Just note that\begin{align}\tan(x)\sin(x)+\cos(x)&=\frac{\sin^2(x)}{\cos(x)}+\frac{\cos^2(x)}{\cos(x)}\\&=\frac1{\cos(x)}\\&=\sec(x).\end{align}