I'm going through Stewart's Calculus, and in section 7.3, example 7 asks for $\int \tan^3(x)dx$. In the book, the solution is $\frac{\tan^2(x)}{2} - \ln|\sec x| + C$. This was obtained in the following way:
$\int \tan^3(x) dx = \int (\sec^2(x) - 1)\tan(x)dx = \int \sec^2(x)\tan (x) dx - \int \tan (x) dx = \int \sec^2(x)\tan (x) - \ln|\sec(x)|+C$
Now we let $u = \tan(x)$, so $du = \sec^2(x)dx$ and we have
$\int \tan^3(x) dx = \int \sec^2(x)\tan (x) - \ln|\sec(x)| = \int u du - \ln|\sec(x)| = \frac{u^2}{2} - \ln|\sec(x)| = \frac{\tan^2(x)}{2} - \ln|\sec(x)|$
However, it seems as though there's a second method of integrating it that doesn't produce the same result. If we instead let $u = \sec(x)$ and therefore $du = \sec(x)\tan(x)dx$, we get
$\int \tan^3(x) dx = \int \sec^2(x)\tan (x) - \ln|\sec(x)| = \int \sec(x) (\sec(x)\tan(x)) = \int u du - \ln|\sec(x)| = \frac{u^2}{2} - \ln|\sec(x)| = \frac{\sec^2(x)}{2} - \ln|\sec(x)|$.
This site produces the same result as what I got: https://www.integral-calculator.com/
So is there some kind of trig identity that I'm missing here, or did I integrate incorrectly? Taking the derivative of both solutions produces the same starting point.