Solve $ \int_\frac{-π}{3}^{\frac{π}{3}}\frac{\cos^2(x)-\sin^2(x)}{\cos^2(x)}dx$ I came across this question in my textbook and have been trying to solve it for a while but I seem to have made a mistake somewhere.
$$ \int_\frac{-π}{3}^{\frac{π}{3}}\frac{\cos^2(x)-\sin^2(x)}{\cos^2(x)}dx$$ and here is what I did. First I simplified the equation as $$ \int_\frac{-π}{3}^{\frac{π}{3}}(1-\tan^2(x))dx=x|_{\frac{-π}{3}}^{\frac{π}{3}}-\int_\frac{-π}{3}^{\frac{π}{3}}(\tan^2(x))dx$$
Then I simplified $\tan^2(x)\equiv\frac{\sin^2(x)}{\cos^2(x)}, \sin^2(x)\equiv1-\cos^2(x)$ so it becomes,  $\tan^2(x)\equiv\frac{1-\cos^2(x)}{\cos^2(x)}=\frac{1}{\cos^2(x)}-1$ making the overall integral 
$$\int_\frac{-π}{3}^{\frac{π}{3}}(1-\tan^2(x))dx=x|_{\frac{-π}{3}}^{\frac{π}{3}}-\int_\frac{-π}{3}^{\frac{π}{3}}(\frac{1}{\cos^2(x)}-1)dx$$
$$=x|_{\frac{-π}{3}}^{\frac{π}{3}}-\int_\frac{-π}{3}^{\frac{π}{3}}\frac{1}{\cos^2(x)}dx-\int_\frac{-π}{3}^{\frac{π}{3}}1dx=x|_{\frac{-π}{3}}^{\frac{π}{3}}-x|_{\frac{-π}{3}}^{\frac{π}{3}}-\int_\frac{-π}{3}^{\frac{π}{3}}\frac{1}{\cos^2(x)}dx$$
I know that $\int\frac{1}{\cos^2(x)}dx=\tan(x)+c$ but that's off by heart and not because I can work it out. Since $x|_{\frac{-π}{3}}^{\frac{π}{3}}-x|_{\frac{-π}{3}}^{\frac{π}{3}}=0$, the final equation becomes 
$$\int_\frac{-π}{3}^{\frac{π}{3}}\frac{\cos^2(x)-\sin^2(x)}{\cos^2(x)}dx=\tan(x)|_{\frac{-π}{3}}^{\frac{π}{3}}=2 \sqrt3$$
Is what I did correct because I feel like I've made a mistake somewhere but can't find it. Also why does $\int\frac{1}{\cos^2(x)}dx=\tan(x)+c$. 
EDIT - Made an error in $\int\frac{1}{\cos^2(x)}dx=\tan^2(x)+c$, it's actually $\int\frac{1}{\cos^2(x)}dx=\tan(x)+c$.
 A: Note that after your words: making the overall integral, because of the minus sign in $$\frac{1}{\cos^2 x} - 1 =\tan^2 x$$ we should have: $$x\bigg \lvert_{-\pi/3}^{\pi/3} - \int_{-\pi/3}^{\pi/3} \frac1{\cos^2 x} \, dx \color{red}{+} \int_{-\pi/3}^{\pi/3} 1\, dx$$

By the way, if you want to solve your integral quickly, note that we have: $$\int_{-\pi/3}^{\pi/3} \frac{\cos^2 x - \sin^2 x} {\cos^2 x} \, dx$$ $$=\int_{-\pi/3}^{\pi/3} 1-\tan^2 x \, dx$$ $$=\int_{-\pi/3}^{\pi/3} 1-(\sec^2 x - 1)\, dx$$ $$ =\int_{-\pi/3}^{\pi/3} 2-\sec^2 x\, dx$$ $$= 2\left[\frac{2\pi}3\right] - \tan x \bigg \lvert_{-\pi/3}^{\pi/3}$$ $$=2\left[\frac{2\pi}3-\sqrt 3\right]$$
A: $\begin{align} J=\int_\frac{-π}{3}^{\frac{π}{3}}\frac{\cos^2(x)-\sin^2(x)}{\cos^2(x)}dx=2\int_0^{\frac{π}{3}}\frac{\cos^2(x)-\sin^2(x)}{\cos^2(x)}dx\end{align}$
Observe that for $x\in [0;\frac{\pi}{3}]$,
$\begin{align} \frac{\cos^2(x)-\sin^2(x)}{\cos^2 x}&=\frac{\cos^2 x(1-\tan^2 x)}{\cos^2 x}\\
&=\frac{1-\tan^2 x}{1+\tan^2 x}\times \frac{1}{\cos^2x}
\end{align}$
Perform the change of variable $y=\tan x$,
$\begin{align}J&=2\int_{0}^{\sqrt{3}}\frac{1-y^2}{1+y^2}\,dy\\
&=2\int_{0}^{\sqrt{3}} \left(\frac{2}{1+y^2}-1\right)\,dy\\
&=2\Big[2\arctan y-y\Big]_{0}^{\sqrt{3}}\\
&=2\Big[2\times \frac{\pi}{3}-\sqrt{3}\Big]\\
&=\boxed{\frac{4\pi}{3}-2\sqrt{3}}
\end{align}$
A: To simplify, try this approach of $\tan^2 x = \sec^2 x - 1$ to get
$$\int_{-\pi/3}^{\pi/3}(2-\sec^2 x)dx = 2 \cdot \int^{\pi/3}_{0}(2-\sec^2 x)dx$$
To get $2 \cdot[2x-\tan x]_{0}^{\pi/3}$ = $\frac{4\pi}{3} - 2\sqrt{3}$
A: Well you know that $(\tan(x))'= \frac 1 {\cos^2(x)}$
$$(\tan(x))'= \frac {\sin^2(x)+\cos^2(x)} {\cos^2(x)}$$
$$(\tan(x))'= {1+\tan^2(x)}$$
Integrate
$$\tan(x)= \int {1+\tan^2(x)}dx$$
$$\tan(x)-x=\int {\tan^2(x)}dx$$
$$\tan(x)-2x= \int -1+ {\tan^2(x)}dx$$
$$2x-\tan(x)= \int 1- {\tan^2(x)}dx=\int 1- {\frac {\sin^2(x)}{\cos^2(x)}}dx=\int {\frac {\cos^2(x)-\sin^2(x)}{\cos^2(x)}}dx$$
