How can I solve $\int \frac{3x+2}{x^2+x+1}dx$

I want to compute this primitive $$I=\int \frac{3x+2}{x^2+x+1}dx.$$

I split this integral into two part: $$\int \frac{3x+2}{x^2+x+1}dx=\int \frac{2x+1}{x^2+x+1}dx+\int \frac{x+1}{x^2+x+1}dx,$$ For the first part: $$\int \frac{2x+1}{x^2+x+1}dx= \ln(|x^2+x+1|)+c_1$$ For the second part: due a change of variable $u=x+1$, I find $$\int \frac{x+1}{x^2+x+1}dx= \int \frac{x+1}{x(x+1)+1}dx=\int \frac{u}{u(u-1)+1}dx=\dots$$

• $u=x+1\implies x=u-1$, hence $\frac{x+1}{x(x+1)+1}=\frac{u}{(u-1)u+1}\neq\frac{u}{u^2}$. – Workaholic Feb 3 '16 at 15:59
• @Workaholic, I don't have any idea to compute the second integral, can you help me – Achaire Feb 3 '16 at 16:02
• the varible change is no good here $\frac{x+1}{x(x+1)+1}=\frac{x}{x(x+1)+1}+\frac{1}{x(x+1)+1}$ – Achaire Feb 3 '16 at 16:05
• Do you know how to deal with integrals of the form $\displaystyle\int\frac{1}{ax^2+bx+c}\,\mathrm dx$? – Workaholic Feb 3 '16 at 16:07
• It seems that most agree that rewriting $x^2+x+1$ as $x^2+x+\frac{1}{4}+\frac{3}{4}=(x+\frac{1}{2})^2+\frac{3}{4}$ would be helpful. – John Joy Feb 3 '16 at 16:41

Hint For the second:

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

Rewrite as $$\int\bigg( \frac{2x+1}{2(x^2+x+1)}+\frac{1}{2(x^2+x+1)} \bigg)dx$$

$$=\underbrace{\frac 1 2 \int\frac{2x+1}{x^2+x+1}dx}_{:=I}+\underbrace{\frac 1 2 \int \frac{1}{x^2+x+1}dx}_{:=J}$$

For $I$ substitute $t=x^2+x+1$ and $dt=(2x+1)dx$

For $J$ complete the square : $\frac 1 2\displaystyle\int \frac{1}{(x+1/2)^2+3/4}$ and now substitute $\varphi=x+1/2$ and $d\varphi=dx\Longrightarrow \frac 1 2\displaystyle\int \frac{1}{\varphi ^2 +3/4}d \varphi$

factor out $3/4$ from the denominator $\frac 2 3\displaystyle\int \frac{1}{(4\varphi ^2)/(3)+1}d \varphi$ and then substitute $z=\frac{2 \varphi}{\sqrt 3}$ and $dz=\frac{2}{\sqrt 3}d \varphi$ so you will get $\frac {1}{\sqrt 3}\displaystyle\int \frac{1}{z^2+1}dz$ and from here it is easy

HINT: the second integral is given by $$\int\frac{x+1}{x^2+x+1}dx$$ you must write the denominator as $$(x+1/2)^2+3/4)$$

Here is one approach to the second integral:

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

The first integral is identical to the one you integrated. The second is $\arctan$, which can be seen after you complete the square.

$$\int \frac{1}{x^2 + x + 1} dx = \int \frac{1}{x^2 + x + (1/2)^2 - (1/2)^2 + 1} dx$$ $$\int \frac{1}{(x+1/2)^2 + 3/4} dx = \frac{4}{3} \int \frac{1}{\left( \frac{2x+1}{\sqrt 3}\right) + 1} dx = \frac{2}{\sqrt{3}} \int \frac{1}{u^2 + 1} du = \frac{2}{\sqrt{3}} \arctan \left( \frac{2x+1}{\sqrt{3}}\right) + C$$

Where we used the substitution $u = \frac{2x+1}{\sqrt{3}}$.

Hint:
There's no need to split the integral that way (IMO), we can instead write, \begin{align} \int \frac{3x+2}{x^2+x+1}\,\mathrm dx&=\frac{3}{2}\int\frac{2x+\tfrac{4}{3}}{x^2+x+1}\,\mathrm dx\\ &=\frac32\int\dfrac{2x+1+\tfrac13}{x^2+x+1}\,\mathrm dx\\ &=\dfrac32\left(\int\dfrac{2x+1}{x^2+x+1}\,\mathrm dx+\int\dfrac{{\small 1/3}}{x^2+x+1}\,\mathrm dx\right). \end{align} The first one is obvious. For the second one we should complete the square in the denominator, like this, $$\int\dfrac{1}{x^2+x+1}\,\mathrm dx=\int\dfrac{1}{\color{royalblue}{x^2+x+\tfrac14}+1-\tfrac14}\,\mathrm dx=\int\dfrac1{\color{royalblue}{\left(x+\tfrac1{2}\right)^2}+\tfrac34}\,\mathrm dx.$$ Now try to proceed further by rewriting that last expression so as to exploit the fact that the integral of $\frac{u'(x)}{u(x)^2+1}$ is $\arctan u(x)+\rm C$, you may have to factor something, and do one or more substitutions.

Let $3x+2=A\dfrac{d(x^2+x+1)}{dx}+B$

$\iff3x+2=A(2x+1)+B=2Ax+A+B$

$\implies2A=3,A+B=2$

$$\implies\int\dfrac{3x+2}{x^2+x+1}dx=A\cdot\dfrac{d(x^2+x+1)}{x^2+x+1}+B\dfrac{dx}{x^2+x+1}$$

$$\int\dfrac{dx}{x^2+x+1}=\int\dfrac4{(2x+1)^2+(\sqrt3)^2}dx$$

Set $2x+1=\sqrt3\tan y$