# Integrate $\int\tan^2x\,dx$

$$\int \tan^2xdx$$

Here is what I tried...

$$\int \tan^2xdx = \int (\sec^2x-1)dx = \int(\frac{1}{\cos^2x} -1)dx = \int \frac{1}{ \frac{1}{2} (1+\cos2x)} = \frac{2}{1} \int \frac{1}{1+\cos2x}$$

$$u = \cos2x, du = 2\sin2xdx$$

$$= 2 \bigg( \frac{1}{x + \frac{1}{2}\sin2x} \bigg) + C$$

But the answer is $$\tan x - x + C$$.

I think the way that I set up the problem (using half angle identity of $$\cos^2x$$ in the denominator started making the calculations a lot harder to follow in my opinion) was an issue and that I could have set it up better?

• I think the main point is that you should know that the integral of the $\sec^2$ is equal to $\tan$. You can derive it probably by setting $u=\cos(x)$ and you get something that simplifies. (You should do the substitution directly without simplifying the $\cos^2$) – Stan Tendijck Mar 6 at 14:06
• There are correct answers below, but you should know that there are things wrong with your answer, that you really should understand. Minor issue (I assume): you lost the $-1$ in the integrand. Major issue (if I understand what you did): $$\int {1\over \text {something} }\,dx \not= {1 \over \int \text{something}\, dx}.$$ – peter a g Mar 6 at 14:09
• @peterag yeaaa that's what I did...damn. I can't believe I overlooked derivative of $/tan$ is $\sec^2$ – Evan Kim Mar 6 at 14:20

$$\int(\sec^2x-1)dx=\int\sec^2x\ dx-\int dx=?$$
The derivative of $$\tan x$$ is $$1+\tan^2x$$. Then $$\int\tan^2x\,dx = \int\frac{\mathrm{d}}{\mathrm{d}x}\tan x\,\mathrm{d}x-x+c = \tan x -x+c.$$
$$\frac{d}{dx}\left(\tan{x}\right)=\sec^2{x}\implies \int\sec^2{x}\,dx=\tan{x}+C$$
$$\int \tan^2x\,dx = \int(\sec^2x-1)\,dx= \int\sec^2x\,dx-\int\,dx=\tan{x}-x+C.$$
$$I=\int\tan^2(x)dx=\int\sec^2(x)-1dx$$ as:$$\cos^2(x)+\sin^2(x)=1\to1+\tan^2(x)=\frac{1}{\cos^2(x)}$$ also we know that: $$\frac{d}{dx}\left[\tan(x)\right]=\sec^2(x)$$ so: $$I=\tan(x)-\int dx=\tan(x)-x+C$$