
Integral problem
I am trying to solve the integral:
$\displaystyle \int\frac{tan{^2}(x)}{1 + 2tan{^2}x} dx$
This is what I did:
$\displaystyle u = tan(x)$
$\displaystyle x = arctan(u)$
$\displaystyle dx = (1+u^2) du$
So that the integral is:
$\displaystyle \int\frac{u{^2}(1+u^2)}{1 + 2u{^2}} du$
Then I did polynomial division, and got that:
$\displaystyle \int\frac{u{^2}(1+u^2)}{1 + 2u{^2}} du$ =
$\displaystyle \int\frac{1}{2}u^2 + \frac{1}{4} \frac{1}{4}\frac{1}{2u^2+1} du$
But the according to Wolfram, the answer that I should have got from the integral I started solving, is not the same as the answer to this new integral.
What mistake did I do?

you are doing it right..after integrating, you have to substitute back the value of u, which is tanx.
Edit: A correction is needed in the step where you found dx. Look at the post below.

Is...
$\displaystyle \displaystyle u= \tan x \implies x = \tan^{1} u \implies \frac{dx}{du}= \frac{1}{1+u^{2}}$
Kind regards
$\displaystyle \chi$ $\displaystyle \sigma$

You might go an other way, or whatever we like to cal it. If we massage the trigonometric functions out of $\displaystyle tan²x$ instead.
$\displaystyle \displaystyle tan²x = \frac{sin²x}{cos²x} = \frac{\frac{1cos 2x}{2}}{\frac{1+cos2x}{2}} = \frac{1cos 2x}{1+cos2x}$
In your integral
$\displaystyle \displaystyle \frac{tan²x}{1+2tan²x} = \frac{\frac{1cos 2x}{1+cos2x}}{1+2 \left( \frac{1cos 2x}{1+cos2x} \right)} = \frac{\frac{1cos 2x}{1+cos2x}}{\frac{1+cos2x + 22cos 2x}{1+cos2x} } = \frac{1cos 2x}{3cos2x} } = \frac{22 + 1cos 2x}{3cos2x} = 1  \frac{2}{3cos2x}$
Try solving $\displaystyle \int 1  \frac{2}{3cos2x} dx $ and see if it computes. (Wondering)

To make things easier:
$\displaystyle \displaystyle \int\frac{\tan^2{x}}{1+2\tan^2{x}}\;{dx} = \frac{1}{2}\int\frac{2\tan^2{x}1+1}{1+2\tan^2{x}}\;{dx} = \frac{1}{2}\;{x}\frac{1}{2}\int\frac{1}{1+2\tan^2{x}}\;{dx}.$
Still go on with $\displaystyle u = \tan{x}$.