TITLE: Question regarding $\int \tan(x) \sec^2(x) \,dx$
QUESTION [5 upvotes]: I am asked to find the following but unsure whether or not my solution is valid:
$$\int \tan(x) \sec^2(x) \,dx$$
Setting $u=\tan(x)$ and $du=\sec^2(x)\,dx$:
$$= \int u\,du$$
$$= \dfrac{u^2}{2}+C$$
$$= \dfrac{\tan^2(x)}{2}+C$$
The part that confuses me is that it appears the correct solution should be the follwing but I don't believe I did anything wrong. Why is this the correct solution and mine is not?
$$= \dfrac{\sec^2(x)}{2}+C$$

REPLY [5 votes]: As Dan Z points out in his comment above, both solutions are correct. $$\frac {\tan^2 x}2 + C = \dfrac{\sec^2(x) -1} 2 + C = \dfrac{\sec^2(x)}2 - \frac 12 + C= \dfrac{\sec^2(x)}2 +C_2$$ so the solutions differ only by a constant.

Remark: If you're curious as to how the second alternative is derived...
Note that $$\int \tan x \sec^2 x \,dx = \int \sec x (\sec x \tan x \,dx)$$ Letting $u = \sec x$ gives us $du = \sec x \tan x \,dx$.  This leads to the integral $$\int \sec u \,du$$hence the alternative solution.
So it just comes down to what one chooses as $u$.