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$.
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]$$