power series for $\frac1{x^2+x+1}$ So I am trying to find the sequence $(a_n)_{n\geq0}$ such that 
$$\frac1{x^2+x+1}=\sum_{n\geq0}a_nx^n$$
My attempts:
I defined $$A(x)=\frac1{x^2+x+1}$$
Hence $$A(x)=\sum_{n\geq0}a_nx^n$$
And so $$(x^2+x+1)\sum_{n\geq0}a_nx^n=1$$
$$\sum_{n\geq0}a_nx^{n+2}+\sum_{n\geq0}a_nx^{n+1}+\sum_{n\geq0}a_nx^n=1$$
$$\sum_{n\geq0}a_n(x^{n+2}+x^{n+1}+x^n)=1$$
$$a_0(x^2+x+1)+\sum_{n\geq1}a_n(x^{n+2}+x^{n+1}+x^n)=1$$
$x=0$:
$$a_0=1$$
So
$$x^2+x+1+a_1(x^3+x^2+x)+\sum_{n\geq2}a_n(x^{n+2}+x^{n+1}+x^n)=1$$
$$\frac{x^2+x+1+a_1(x^3+x^2+x)+\sum_{n\geq2}a_n(x^{n+2}+x^{n+1}+x^n)}x=\frac1x$$
$$x+1+a_1(x^2+x+1)+\sum_{n\geq2}a_n(x^{n+1}+x^{n}+x^{n-1})=0$$
$x=0$:
$$a_1=-1$$
One more time:
$$x^2+x+1-x^3-x^2-x+a_2(x^4+x^3+x^2)+\sum_{n\geq3}a_n(x^{n+2}+x^{n+1}+x^n)=1$$
$$-x^3+a_2(x^4+x^3+x^2)+\sum_{n\geq3}a_n(x^{n+2}+x^{n+1}+x^n)=0$$
Divide both sides by $x^2$:
$$-x+a_2(x^2+x+1)+\sum_{n\geq3}a_n(x^{n}+x^{n-1}+x^{n-2})=0$$
$x=0$:
$$a_2=0$$
How do I find $a_n$? Am I doing things right so far? Thanks.
 A: \begin{align}
\frac1{1+x+x^2} &= \frac{1-x}{1-x^3} \\
&= \frac1{1-x^3}-x\left(\frac1{1-x^3} \right)\\
&= \sum_{i=0}^\infty x^{3i}-x\sum_{i=0}^\infty x^{3i}\\
&=\sum_{i=0}^\infty x^{3i}-\sum_{i=0}^\infty x^{3i+1}\\
\end{align}
A: Another way of doing this is to let the roots of $1+x+x^2=0$ be $a$ and $b$ so that $1+x+x^2=(1-ax)(1-bx)$ with $ab=1$ and $a+b=-1$. Then use partial fractions $$\frac 1{1+x+x^2}=\frac A{1-ax}+\frac B{1-bx}$$ where clearing fractions gives $$1=A(1-bx)+B(1-ax)$$
Set $a=\frac 1b$ to obtain $1=B(1-\frac ab)$ so that $B=\frac b{b-a}$ and similarly $A=\frac a{a-b}$ so that $$\frac 1{1+x+x^2}=\sum_{n=0}^\infty\frac a{a-b}a^nx^n-\sum_{n=0}^\infty \frac b{a-b}b^bx^n=\sum_{n=0}^\infty\frac {a^{n+1}-b^{n+1}}{a-b}x^n$$
Now observe $a^2=-1-a=b$ and $a^3=ab=1$ and similarly $b^2=-1-b=a$ and $b^3=1$. For $n=3m$ the coefficient is $\frac {a-b}{a-b}=1$, for $n=3m+1$ the coefficient is $\frac {b-a}{a-b}=-1$ and for $n=3m+2$ the coefficient is $0$.
We can also identify $a=\omega$ and $b=\omega^2$ as being primitive cube roots of $1$. Note how the coefficients are periodic with period $3$. These facts are related, as another answer shows.

Note: I have tried to express this in such a way as to show how partial fractions can be used more generally - even where a convenient short cut is not available - it doesn't matter that you get complex roots, the answer ends up with real coefficients. The only slight trick is that we would normally factorise $$x^2+px+q=(x-c)(x-d)$$ but, setting $a=\frac 1c, b= \frac 1d$ we need the form $$x^2+px+q=cd(1- ax)(1-bx)=q(1-ax)(1-bx)$$In the case above we had $q=1$, but in general the factor must not be forgotten.
A: You could have continue your way.
Starting from
$$\sum_{n=0}^\infty a_nx^{n+2}+\sum_{n=0}^\infty a_nx^{n+1}+\sum_{n=0}^\infty a_nx^n=1$$ you already found $a_0=1$ and $a_1=-1$.
Now, consider a given degree $m >1$. You then have the recurrence relation
$$a_{m-2}+a_{m-1}+a_m=0$$ and the roots of the characteristic equation 
$$r^2+r+1=0 \implies r_\pm=\frac{-1 \pm i \sqrt 3} 2$$ making by the end (I let to you the intermediate steps)
$$a_m=\cos \left(\frac{2 \pi  m}{3}\right)-\frac{1}{\sqrt{3}}\sin \left(\frac{2 \pi 
   m}{3}\right)$$ making $a_{3m}=1$, $a_{3m-1}=0$, $a_{3m+1}=-1$.
