# Integrating $\int \frac{dx}{x^2+x+1}$

I am trying to evaluate the following integral: $$I=\int \frac{dx}{x^2+x+1}$$

I am not supposed to do it with complex numbers so it's kind of hard. I checked the answer on WolframAlpha.

It gives $$I=\frac{\sqrt{3}}{2}\arctan{\left(\frac{\sqrt{3}}{2}x+\frac{1}{2}\right)}+C$$

Having this information I found that I need to set

$$t=\frac{\sqrt{3}}{2}x+\frac{1}{2}$$

consequently: $x^2+x+1=\frac{3}{4}(t^2+1)$ and $dx=\frac{\sqrt{3}}{2}dt$

therefore: $$I=\frac{2}{\sqrt{3}} \int \frac{dt}{t^2+1}$$ which can be found easily by setting $t=\tan{\theta}$ giving the same answer stated above.

Practically, I cheated: if I had not known the final answer I would have not guessed what I needed to set as $t$.

My question is: how should I think in order to find this integral?

Is there a method to find integrals of the form $$\int \frac{dx}{ax^2+bx+c}$$

Without knowing the answer, how can I solve such integral?

Thanks

• Complete the square. Dec 22, 2014 at 21:58
• Thank you! This is helpful.
– rand
Dec 22, 2014 at 22:04
• IMO the main lesson to be drawn from this is: The purpose of COMPLETING THE SQUARE is always to reduce a problem involving a quadratic polynomial with a linear term to a problem involving a quadratic polynomial with no linear term. (See my answer below.) ${}\qquad{}$ Dec 22, 2014 at 22:10

Hint: $x^2+x + 1 = \left(x+\frac{1}{2}\right)^2 + \left(\dfrac{\sqrt{3}}{2}\right)^2$

• This is called completing the square. Dec 22, 2014 at 22:11

It's not that hard: \begin{align*}\int\frac1{x^2+x+1}dx&=\int\frac1{(x+1/2)^2+3/4}dx=\frac43\int\frac1{(ax+b)^2+1}dx\\&=\frac43\int\frac1{y^2+1}\cdot\frac1ady=\frac4{3a}\arctan y,\end{align*} where $y= ax+b$. Now compute $a,b$ and substitute back to get the result.

The general method is $\int\frac1{(ax+b)^2}=-\frac1a\frac1{ax+b}$ if it the denominator is a square, partial fractions if it has two real roots and completing the square and using $\arctan$ otherwise.

• I edited this because it goes off the page. Just saying :) Dec 22, 2014 at 22:21
• @Alizter It doesn't for me :S That explains it. I don't like too many rows, but I'll edit it a little without increasing the number of rows. Dec 22, 2014 at 22:22

The purpose of completing the square is always to reduce a problem involving a quadratic polynomial with a linear term to a problem involving a quadratic polynomial with no linear term.

$$\overbrace{\int \frac{dx}{x^2+x+1} = \int\frac{dx}{(x^2+x+\frac 1 4) + \frac 3 4}}^{\text{completing the square}} = \int \frac{dx}{(x+\frac 1 2)^2 + \frac 3 4} = \int\frac{du}{u^2 + \frac 3 4}$$ etc.

Since $ax^2 + bx+c = a\Bigg[x^2 + \frac{b}{a}x + \frac{c}{a}\Bigg] = a\Bigg[(x+\frac{b}{2a})^2 - \frac{b^2 - 4ac}{4a^2} \Bigg]$ then
$$\int \frac{1}{ax^2+bx+c}dx = \frac{1}{a}\int \frac{1}{(x+\frac{b}{2a})^2 - \frac{b^2 - 4ac}{4a^2}}dx$$
And the next step will depend on the sign of $b^2-4ac$.