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/u - 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!

Break it into two integrals, integral (sec^2(x)tan(x))dx and integral(-tan(x))dx. Both can be solved using u substitution.

It seems like you made a mistake when substituting back in the value of u. Let's go through the integration process step by step to identify where the error occurred.

You correctly started by breaking up the integrand as follows:

∫ tan^2(x) * tan(x) dx = ∫ (sec^2(x) - 1) * tan(x) dx

Next, you made a u-substitution, setting u = sec(x), and found du = sec(x) * tan(x) dx. Rearranging, dx = du / (sec(x) * tan(x)).

So, substituting these values, the integral becomes:

∫ (u^2 - 1) * (tan(x) * du) / (sec(x) * tan(x))

The tan(x)'s cancel out, and we have:

∫ (u^2 - 1) * du / sec(x)

Now, we need to substitute back the value of u. Note that u = sec(x), so sec(x) = u. Therefore, the integral becomes:

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

Splitting this into two separate integrals, we have:

∫ u^2 / u du - ∫ 1 / u du

Simplifying further, we get:

∫ u du - ∫ 1 du

The integrals become:

(u^2 / 2) - ln |u| + C

Substituting back u = sec(x), we obtain:

(sec^2(x) / 2) - ln |sec(x)| + C

Now, considering that tan^2(x) = sec^2(x) - 1, we can rewrite the expression in terms of tan^2(x):

(sec^2(x) / 2) - ln |sec(x)| + C
= tan^2(x) / 2 - ln |sec(x)| + C

So, the solution should be tan^2(x) / 2 - ln |sec(x)| + C, which matches the expected answer.

It seems your error occurred when substituting back u as sec(x). Make sure to substitute correctly, and double-check the algebraic steps to ensure accuracy.