Integral of $\frac{1}{x^2+x+1}$ and$\frac{1}{x^2-x+1}$ How to integrate two very similar integrals. I am looking for the simplest approach to that, it cannot be sophisticated too much as level of the textbook this was taken from is not very high. $$\int \frac{1}{x^2+x+1} dx$$ and$$\int \frac{1}{x^2-x+1} dx$$

For the first one:
$$
\int { \frac { 1 }{ 1+{ x }^{ 2 }+x }  } dx\quad =\quad \quad \int { \frac { 1 }{ { x }^{ 2 }+x+\frac { 1 }{ 4 } +\frac { 3 }{ 4 }  } dx } \\ \qquad \qquad \qquad \qquad =\quad \int { \frac { 1 }{ { \left( x+\frac { 1 }{ 2 }  \right)  }^{ 2 }+\frac { 3 }{ 4 }  } dx } \\ \qquad \qquad \qquad \qquad \quad =\quad \frac { 4 }{ 3 } \int { \frac { 1 }{ 1+{ \left( \sqrt { \frac { 4 }{ 3 }  } \left( x+\frac { 1 }{ 2 }  \right)  \right)  }^{ 2 } }  } dx\\ \qquad \qquad \qquad \qquad \quad =\quad  \frac { 2 }{ \sqrt{3} }   \arctan { \left( \frac { 2 }{ \sqrt{3} }   \left( x+\frac { 1 }{ 2 }  \right)  \right)  }  +C
$$
The second one will be the same just a minus instead of a plus:
$$
 \frac { 2 }{ \sqrt{3} }   \arctan { \left( \frac { 2 }{ \sqrt{3} }   \left( x-\frac { 1 }{ 2 }  \right)  \right)  }  +C
$$
Here's a general formula for $\int \frac{1}{ax^2+bx+c}dx$, when $b^2-4ac<0$:
$$
\int { \frac { 1 }{ a{ x }^{ 2 }+bx+c }  } dx\quad =\frac { 1 }{ a } \quad \int { \frac { 1 }{ { x }^{ 2 }+\frac { b }{ a } x+\frac { c }{ a }  }  } dx\\ \qquad \qquad \qquad \qquad \quad =\quad \frac { 1 }{ a } \int { \frac { 1 }{ { x }^{ 2 }+\frac { b }{ a } x+\frac { { b }^{ 2 } }{ 4{ a }^{ 2 } } +\frac { c }{ a } -\frac { { b }^{ 2 } }{ 4{ a }^{ 2 } }  } dx } \\ \qquad \qquad \qquad \qquad \quad =\quad \frac { 1 }{ a } \int { \frac { 1 }{ { \left( x+\frac { b }{ 2a }  \right)  }^{ 2 }+\frac { c }{ a } -\frac { { b }^{ 2 } }{ 4{ a }^{ 2 } }  }  } dx\\ \qquad \qquad \qquad \qquad \quad =\quad \frac { 1 }{ a\left( \frac { c }{ a } -\frac { { b }^{ 2 } }{ 4{ a }^{ 2 } }  \right)  } \int { \frac { 1 }{ 1+{ \left( \frac { x+\frac { b }{ 2a }  }{ \sqrt { \frac { c }{ a } -\frac { { b }^{ 2 } }{ 4{ a }^{ 2 } }  }  }  \right)  }^{ 2 } } dx } \\ \qquad \qquad \qquad \quad =\quad \frac { \sqrt { \frac { c }{ a } -\frac { { b }^{ 2 } }{ 4{ a }^{ 2 } }  }  }{ c-\frac { { b }^{ 2 } }{ 4a }  } \arctan { \left( \frac { x+\frac { b }{ 2a }  }{ \sqrt { \frac { c }{ a } -\frac { { b }^{ 2 } }{ 4{ a }^{ 2 } }  }  }  \right)  } +C
$$
