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.
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$.