<s>[INST] $\int \frac{\tan x}{\cos^2x}dx$ $\int \frac{\tan x}{\cos^2x}dx=\int\frac{\frac{\sin x}{\cos x}}{\cos^2 x}dx=\int \frac{\sin x}{\cos^3x}dx$
$\cos x=t, -\sin xdx=dt \Rightarrow \sin xdx=-dt$
$\int \frac{-dt}{t^3}=-\int t^{-3}dt=\frac{1}{2}t^{-2}dt=\frac{1}{2\cos^2x}+C $
$\int \frac{\tan x}{\cos^2x}dx\\\tan x=t,\frac{dx}{\cos^2 x}=dt\\\int t dt=\frac{1}{2}t^2+C=\frac{1}{2}\tan^2x+C$
which solution is correct?
 [/INST] Both are correct, recall $\tan^{2}(x)+1=\sec^{2}(x)$, so that your two answers differ by a constant.
</s>