<s>[INST] How to evaluate $\int\frac{x}{\sqrt{x^2+x+1}} \, dx$ using trigonometric substitution? I am pretty sure that my answer is correct but given answer for the exercise from textbook Calculus James Steward was slightly different. Any idea to solve this:
$$\int\frac{x}{\sqrt{x^2+x+1}} \, dx$$
The given answers: $\sqrt{x^2+x+1}-\frac{1}{2}\ln(\sqrt{x^2+x+1}+x+\frac{1}{2})+c$
Thanks in advance.
 [/INST] First split off the bit that does not need a trigonometric substitution:
$$\int\frac{x\,dx}{\sqrt{x^2+x+1}}=\int\frac{x+\frac{1}{2}}{\sqrt{x^2+x+1}}dx
  -\frac{1}{2}\int\frac{dx}{\sqrt{x^2+x+1}}\ .$$
You should see that the first integral is now easy.  For the second, complete the square:
$$\int\frac{dx}{\sqrt{x^2+x+1}}=\int\frac{dx}{\sqrt{(x+\frac{1}{2})^2+\frac{3}{4}}}\ .$$
If you really want to use a trig substitution, try
$$x+\frac{1}{2}=\frac{\sqrt3}{2}\tan\theta\ ,$$
which still leaves you with a slightly tricky integral.  Better, use the hyperbolic substitution
$$x+\frac{1}{2}=\frac{\sqrt3}{2}\sinh\theta\ .$$
If you want to directly get the answer from the book, do some algebra:
$$\frac{1}{\sqrt{x^2+x+1}}
  =\frac{\displaystyle\frac{x+\frac{1}{2}}{\sqrt{x^2+x+1}}+1}{\sqrt{x^2+x+1}+x+\frac{1}{2}}\ .$$
With a bit of thought you will see why this is easy to integrate.
</s>