Evaluate the following integrals:
$\int \frac{x^{2}+x+1}{x^{2}-x+1} d x$
Given $I=\int \frac{x^{2}+x+1}{x^{2}-x+1} d x$
Expressing the integral $\int \frac{\mathrm{P}(\mathrm{x})}{\mathrm{ax}^{2}+\mathrm{bx}+\mathrm{c}} \mathrm{dx}=\int \mathrm{Q}(\mathrm{x}) \mathrm{dx}+\int \frac{\mathrm{R}(\mathrm{x})}{\mathrm{ax}^{2}+\mathrm{bx}+\mathrm{c}} \mathrm{dx}$
$\Rightarrow \int \frac{x^{2}+x+1}{x^{2}-x+1} d x=\int\left(\frac{2 x}{x^{2}-x+1}+1\right) d x$
$=2 \int\left(\frac{x}{x^{2}-x+1}\right) d x+\int 1 d x$
Consider $\int \frac{x}{x^{2}-x+1} d x$
Let $x=1 / 2(2 x-1)+1 / 2$ and split,
$\Rightarrow \int\left(\frac{2 x-1}{2\left(x^{2}-x+1\right)}+\frac{1}{2\left(x^{2}-x+1\right)}\right) d x$
$\Rightarrow \frac{1}{2} \int \frac{2 x-1}{\left(x^{2}-x+1\right)} d x+\frac{1}{2} \int \frac{1}{\left(x^{2}-x+1\right)} d x$
Consider $\int \frac{2 x-1}{\left(x^{2}-x+1\right)} d x$
Let $u=x^{2}-x+1 \rightarrow d x=d u / 2 x-1$
$\Rightarrow \int \frac{2 \mathrm{x}-1}{\left(\mathrm{x}^{2}-\mathrm{x}+1\right)} \mathrm{dx}=\int \frac{2 \mathrm{x}-1}{\mathrm{u}} \frac{\mathrm{du}}{2 \mathrm{x}-1}$
$=\int \frac{1}{\mathrm{u}} \mathrm{du}$
We know that $\int \frac{1}{x} d x=\log |x|+c$
$\Rightarrow \int \frac{1}{u} d u=\log |u|=\log \left|x^{2}-x+1\right|$
Now consider $\int \frac{1}{\left(x^{2}-x+1\right)} d x$
$\Rightarrow \int \frac{1}{\left(x^{2}-x+1\right)} d x=\int \frac{1}{\left(x-\frac{1}{2}\right)^{2}+\frac{3}{4}} d x$
Let $\mathrm{u}=\frac{2 \mathrm{x}-1}{\sqrt{3}} \rightarrow \mathrm{dx}=\frac{\sqrt{3}}{2} \mathrm{du}$
$\Rightarrow \int \frac{1}{\left(x-\frac{1}{2}\right)^{2}+\frac{3}{4}} d x=\int \frac{2 \sqrt{3}}{3 u^{2}+3} d u$
$=\frac{2}{\sqrt{3}} \int \frac{1}{u^{2}+1} d u$
We know that $\int \frac{1}{x^{2}+1} d x=\tan ^{-1} x+c$
$\Rightarrow \frac{2}{\sqrt{3}} \int \frac{1}{\mathrm{u}^{2}+1} \mathrm{du}=\frac{2 \tan ^{-1} \mathrm{u}}{\sqrt{3}}=\frac{2 \tan ^{-1}\left(\frac{2 \mathrm{x}-1}{\sqrt{3}}\right)}{\sqrt{3}}$
Then,
$\Rightarrow \int \frac{x}{x^{2}-x+1} d x=\frac{1}{2} \int \frac{2 x-1}{\left(x^{2}-x+1\right)} d x+\frac{1}{2} \int \frac{1}{\left(x^{2}-x+1\right)} d x$
$=\frac{1}{2}\left(\log \left|x^{2}-x+1\right|\right)+\frac{1}{2}\left(\frac{2 \tan ^{-1}\left(\frac{2 x-1}{\sqrt{3}}\right)}{\sqrt{3}}\right)$
$=\frac{\log \left|x^{2}-x+1\right|}{2}+\frac{\tan ^{-1}\left(\frac{2 x-1}{\sqrt{3}}\right)}{\sqrt{3}}$
Now $2 \int\left(\frac{\mathrm{x}}{\mathrm{x}^{2}-\mathrm{x}+1}\right) \mathrm{dx}+\int 1 \mathrm{dx}$
We know that $\int 1 \mathrm{dx}=\mathrm{x}+\mathrm{c}$
$\Rightarrow 2 \int\left(\frac{\mathrm{x}}{\mathrm{x}^{2}-\mathrm{x}+1}\right) \mathrm{dx}+\int 1 \mathrm{dx}=2\left(\frac{\log \left|\mathrm{x}^{2}-\mathrm{x}+1\right|}{2}+\frac{\tan ^{-1}\left(\frac{2 \mathrm{x}-1}{\sqrt{3}}\right)}{\sqrt{3}}\right)+\mathrm{x}+\mathrm{c}$
$=\left(\log \left|\mathrm{x}^{2}-\mathrm{x}+1\right|\right)+\left(\frac{2 \tan ^{-1}\left(\frac{2 \mathrm{x}-1}{\sqrt{3}}\right)}{\sqrt{3}}\right)+\mathrm{x}+\mathrm{c}$
$\therefore \mathrm{I}=\int \frac{\mathrm{x}^{2}+\mathrm{x}+1}{\mathrm{x}^{2}-\mathrm{x}+1} \mathrm{dx}=\left(\log \left|\mathrm{x}^{2}-\mathrm{x}+1\right|\right)+\left(\frac{2 \tan ^{-1}\left(\frac{2 \mathrm{x}-1}{\sqrt{3}}\right)}{\sqrt{3}}\right)+\mathrm{x}+\mathrm{c}$