Answer
$ x tan (x) + ln|cos (x)| - x^2/2 + C $
Work Step by Step
Using integration by parts:
u = x so u' = 1
v' = $tan^2 (x) = sec^2 (x) -1 $ (Trigonometry identity)
v = $ \int sec^2 (x) -1 $ dx = $ tan(x) - x $
Now let's plug those parts into the equation:
$\int x tan^2 (x) dx = uv - \int (u'v)$
=$ x(tan(x) - x) - \int (tan(x) - x)dx $
= $ x tan (x) - x^2 + ln|cos (x)| + (x^2)/2 + C $
= $ x tan (x) + ln|cos (x)| - x^2/2 + C $