<s>[INST] Evaluate $\int\frac{x^2}{\sqrt{1+x+x^2}}\,dx$ The task is to evaluate $$\int\frac{x^2}{\sqrt{1+x+x^2}}\,dx$$
My best approach has been substitution of $u=x+\frac{1}{2}$, and from there onto (some terrible) trig sub - finally arriving at a messy answer. 
Is there a slicker way of doing this?
 [/INST] As you suggest, complete the square,
$$ 1+x+x^2 = (x+1/2)^2 + 3/4 $$
Now, the key is to substitute to make the square root something nice. I'll do a couple of substitutions to make it clearer. Set $y=x+1/2$, so we have
$$ \int \frac{(y-1/2)^2}{\sqrt{y^2+3/4}} \, dy $$
Now the denominator looks in the form appropriate for a hyperbolic substitution. In particular,
$$ \frac{d}{dx} \arg \sinh{x} = \frac{1}{\sqrt{1+x^2}}, $$
so setting $y=\frac{1}{2}\sqrt{3}\sinh{u}$, you find, ($dy=\frac{1}{2}\sqrt{3}\cosh{u} \, du$)
$$ \int \frac{(\frac{1}{2}\sqrt{3}\sinh{u}-\frac{1}{2})^2}{\sqrt{\frac{3}{4} (1+\sinh^2{u})}} \frac{1}{2}\sqrt{3}\cosh{u} \, du = \frac{1}{4}\int (\sqrt{3} \sinh{u}-1)^2 \, du  $$
This integral is fairly elementary after using the identity
$$ \cosh{2u}=\cosh^2{u}+\sinh^2{u} = 1+2\sinh^2{u} $$
After that, you just have to invert the substitutions, for which you will also need
$$ \cosh{u} = \sqrt{1+\sinh^2{u}} $$
and
$$ \sinh{2u}=2\sinh{u}\cosh{u}. $$
</s>