# What is the trick needed to compute the integral $\int \frac{1}{x^{2}+x+1} dx$?

Working through Spivak's Calculus and using old assignments from the course offered at my school I'm working on the following problem, asking me to find the integral $$\int \frac{1}{x^{2}+x+1} dx$$

Looking through Spivak and previous exercises I worked on, I thought using a partial fraction decomposition would be the technique, but even in Spivak the only exercises I've seen which are similar involve:

$$\int \frac{1}{(x^{2}+x+1)^{n}} dx\ ,\text{where}\ n> 1$$

In which case it is pretty straightforward to solve. So there must be a reason why the exercise isn't presented unless it is so straightforward.

Integration by parts and substitution (at least for now) have proven fruitless as well. So I come here to ask if I'm missing any special trick to compute this integral ?

• Using $x^2+x+1 = (x+\frac12)^2+\frac34$ and use trigonometric substitution. Sep 17, 2020 at 18:43
• Yoo could split the fraction into partial fractions, although I agree that the constants involved will be very messy. Sep 17, 2020 at 19:11

It's actually very simple to identify this integral as this:

$$\int \frac{1}{x^2+x+1} dx = \int \frac{1}{\left(x+\frac{1}{2} \right)^2+ \frac{3}{4}} dx.$$

Now you can see that you can use the following rule for integration: $$\int \frac{1}{x^2+a^2}dx=\frac{1}{a} \arctan \left(\frac{x}{a} \right)+ C.$$

And now you get $$\int \frac{1}{\left(x+\frac{1}{2} \right)^2+ \frac{3}{4}} dx = \frac{2}{\sqrt{3}} \arctan \left(\frac{2x+1}{\sqrt{3}} \right) + C.$$

• Post in same timing Sep 17, 2020 at 18:53

I'll take a different approach from the answers so far. For this approach, you'll have to be at least a bit comfortable working with complex numbers.

We can factor $$x^2 + x + 1$$ as $$\left(x - \frac{1 + \sqrt{3}i}{2}\right)\left(x - \frac{1 - \sqrt{3}i}{2}\right)$$.

That means we can rewrite the integral using partial fractions: $$\int \frac{dx}{x^2+x+1} = \int \frac{A dx}{x - \frac{1 +\sqrt{3}i}{2}} + \int \frac{B dx}{x - \frac{1 -\sqrt{3}i}{2}}$$ for some $$A, B \in \mathbb{C}$$. We can find $$A$$ and $$B$$ easily: $$Ax - A \frac{1 +\sqrt{3}i}{2} + Bx - B \frac{1 -\sqrt{3}i}{2} = 1$$. This gives us that $$A = -B$$, and $$A = -\frac{\sqrt{3}i}{3}$$.

These integrals are of the form $$\int \frac{Kdx}{x-L}$$, and are easy enough to solve: just use the substitution $$u = x - \frac{1 +\sqrt{3}i}{2}$$ for the first one, and $$u =x - \frac{1 -\sqrt{3}i}{2}$$ for the second one.

Though the efficient way has been given several times, decomposition in simple fractions remains your good friend.

The polynomial $$x^2+x+1$$ has complex roots, let $$\omega$$ and $$\omega^*$$, which, incidentally, are cube roots of unity. Now,

$$\frac1{x^2+x+1}=\frac1{(x-\omega)(x-\omega^*)}=\frac1{2i\Im(\omega)}\left(\frac1{x-\omega}-\frac1{x-\omega^*}\right)$$ and after integration,

$$\frac1{2i\Im(\omega)}\log\frac{x-\omega}{x-\omega^*}.$$

As $$|x-\omega|=|x-\omega^*|$$, the logarithm reduces to the difference of the arguments,

$$-\frac1{\Im(\omega)}\arctan\frac{\Im(\omega)}{x-\Re(\omega)}=-\frac2{\sqrt3}\arctan\frac{\sqrt3}{2x+1}.$$

There is even a faster way, noticing that

$$\frac1{x-\omega}=\frac{x-\omega^*}{(x-\omega)(x-\omega^*)}=\frac{x-\Re(\omega)}{x^2+x+1}+i\frac{\Im(\omega)}{x^2+x+1}.$$

Hence, taking the imaginary part,

$$\int\frac{dx}{x^2+x+1}=\frac{\Im(\log(x-\omega))}{\Im(\omega)}=-\frac1{\Im(\omega)}\arctan\frac{\Im(\omega)}{x-\Re(\omega)}.$$

As a byproduct,

$$\int\frac{{x-\Re(\omega)}}{x^2+x+1}dx=\frac{\Re(\log(x-\omega))}{\Im(\omega)}=\frac1{\Im(\omega)}\log\sqrt{(x-\Re(\omega))^2+\Im^2(\omega)}.$$

Hint : $$x^2+x+1 = (x+\frac{1}{2})^{2}+\frac{3}{4}$$

• going to give this a try. Will report back with progress....Thanks. Sep 17, 2020 at 18:44

$$\int \frac{1}{(x+1/2)^2 + 3/4} dx= \frac{2}{\sqrt3}\tan^{-1}\frac{2x+1}{\sqrt3} +c$$