Hello im trying to integrate tan^3 dx

i have solved out the whole thing but it doesnt match up with the solution..
this is what i did:

first i broke it up into:
integral tan^2x (tanx) dx
integral (sec^2x-1)(tanx) dx

then i did a u substitution
u = secx
du = secxtanx dx (dx = du/secxtanx)

so now i have..
integral (u^2 - 1)*tanx* du/secxtanx
(then the tanx's cancel and then i have a secx with which i re-subsitute u for)

so now i have:
integral (u^2-1)/u
and break it up...
integral u^2/2 - integral 1/u
= integral u - integral 1/u

=u^2/2 - lnabs(u) + c
(and then plug u back in)

(sec^2x)/2 - lnabs(sec^2x) + c
...but it says this is wrong because the anser is actually tan^2x/2 - lnabs(sec^2x) + c

ive done this problem numerous times and i just cant figure out what im doing wrong, any help would be amazing thank you so much!

(on the 17th line it shud be u^2/u)

It seems that you have made a small mistake in your integration. Let's go through it step by step to identify the error:

You correctly started by breaking up the integral as:
∫ tan^2x * tanx dx = ∫ (sec^2x - 1) * tanx dx

Then you made the substitution u = secx, which gives: du = secxtanx dx.

Now, you wrote dx = du/secxtanx, which is almost correct, but you missed a factor of secx. It should be:
dx = du/(u * secx)

Let's substitute this back into the integral:
∫ (u^2 - 1) * tanx * dx/secxtanx = ∫ (u^2 - 1) du/u

Here comes the mistake: instead of breaking it up as u^2/2 - 1/u, you broke it up as u - 1/u. The correct simplification is:

∫ (u^2 - 1) du/u = ∫ (u^2/u - 1/u) du = ∫ (u - 1/u) du = ∫ (u^2/2 - 1/u) du

Now, integrating the expression correctly, we get:
(u^2/2 - ln|u|) + C

Finally, substituting u back as secx, we have:
(sec^2x/2 - ln|secx|) + C

Hence, the correct answer is tan^2x/2 - ln|secx| + C.