To calculate integral of xtan^2x.

We now that tan^2x = sec^2x-1.

Therefore Int xtan^2x dx = Int x*(sec^2x - 1)dx

Int xtan^2x dx= Int xsec2xdx - Int xdx

Int xtan^2x dx = Intx*sec^2xdx - x^2/2....(1)

Int xsec^2x dx = xtanx - Int{x'tanx}dx.

Int xtanx dx = xtanx - Int tanx dx

Int xtanx = xtanx+log(cosx) + C. Substituting this in (1) we get:

Int x tan^2x dx = xtanx + log(cosx) - x^2/2+C.

Since we know that (tan x)^2+1 = (tan x)', we'll add and subtract 1 inside the expression of the given function;

Int f(x)dx = Int x[(tan x)^2+1-1]dx

We'll remove the brackets:

Int x[(tan x)^2+1] - Int xdx

We'll note Int x[(tan x)^2+1] = I1 and Int xdx = I2.

Since I2 is an elementary formula, we'll solve it first:

I2 = x^2/2 + C

For solving I1 we'll apply integration by parts:

Int udv = uv - Int vdu

u = x => du = dx

dv = [(tan x)^2+1] = (tan x)'dx

v = tan x

I1 = x*tanx - Int tan xdx

I1 = x*tanx + ln (cos x)

Int f(x)dx = I1 - I2

**Int f(x)dx = x*tanx + ln (cos x) - x^2/2 + C**