Find the numerical value of this expression If $x$ is a complex number such that $x^2+x+1=0$, then the numerical value of $(x+\frac{1}{x})^2+(x^2+\frac{1}{x^2})^2+(x^3+\frac{1}{x^3})^2+\ldots+(x^{27}+\frac{1}{x^{27}})^{2}$ is equal to?
A) 52 .   B) 56 .   C) 54.   D)58 .  E)None of these
Where is this question from?  I'm pretty sure it comes from one high school math contest, does anyone one know which math contest and of course i can't solve, I have an answer key but I don't know the solution.
 A: $x^2=-x-1.$
$x^2+1=-x\Rightarrow x+\frac{1}{x}=-1\Rightarrow \frac{1}{x}=-x-1=x^2$ $[$as $x \ne 0]$.
$x^3=1.$
$x^n+\frac{1}{x^n}=-1$ as $n = 3k+1,3k+2$
$x^n+\frac{1}{x^n}=2$ as $n = 3k$
So, here the answer is $18+4 \times9=54$
A: Multiply both sides by $x-1\ne 0$:
$$x^2+x+1=0 \Rightarrow (x-1)(x^2+x+1)=0 \Rightarrow x^3-1=0 \Rightarrow x^3=1\Rightarrow \\
x^{54}=1;x^{-54}=1 \quad (1)$$
Expand:
$$(x+\frac{1}{x})^2+(x^2+\frac{1}{x^2})^2+(x^3+\frac{1}{x^3})^2+\ldots+(x^{27}+\frac{1}{x^{27}})^{2}=\\
[x^2+x^4+\cdots+x^{54}]+[x^{-2}+x^{-4}+\cdots+x^{-54}]+2\cdot 27=\\
\frac{x^2(x^{54}-1)}{x^2-1}+\frac{x^{-2}(x^{-54}-1)}{x^2-1}+54\stackrel{(1)}=54.\\
$$
A: $x^3=1$
$x^2+1/x^2=-1$
We need $\sum_{r=0}^8\sum_{n=1}^3(x^{3r+n}+x^{-(3r+n)})^2$
$=\sum_{r=0}^8( (-1)^2+(-1)^2+2^2)$
$=9(6)$
A: Too long for a comment.
Since you already received good explanations, I just focused on the more general problem of
$$S_n=\sum_{k=1}^n \left(x^k+x^{-k}\right)^2 \qquad \text{where}\qquad x^2+x+1=0\implies x=i^{4/3}$$
These are the numbers which are congruent to $\{0, 1, 2\}$ modulo $6$ and there are several ways to write them. If you look here, you will find the nice
$$S_n= 2 n-1+\frac{1}{\sqrt{3}}\sin \left(\frac{2 \pi }{3}n\right)+\cos \left(\frac{2 \pi 
   }{3}n\right)$$
$$S_n=n-1+3 \left\lfloor \frac{n-1}{3}\right\rfloor $$
A: Thank you for all your answers, I just find the other solution to solve this, so I want to post it here.
Since $x^2+x+1=0$, so we can find 
$x+\frac{1}{x}=-1$ 
and $x^2+\frac{1}{x^2}=(x+\frac{1}{x})^2-2=(-1)^2-2=-1$. Let's keep going
$x^3+\frac{1}{x^3}=(x+\frac{1}{x})(x^2+\frac{1}{x^2})-(x+\frac{1}{x})=(-1)(-1)-(-1)=2$
$x^4+\frac{1}{x^4}=(x^2+\frac{1}{x^2})^2-2=(-1)^2-2=-1  $
$x^5+\frac{1}{x^5}=(x^2+\frac{1}{x^2})(x^3+\frac{1}{x^3})-(x^2+\frac{1}{x^2})=(-1)(-1)-2=-1    $
$x^6+\frac{1}{x^6}=(x^5+\frac{1}{x^5})(x+\frac{1}{x})-(x^4+\frac{1}{x^4})=(-1)(-1)-(-1)=2$
......
So it has a period,-1,-1,2,-1,-1,2,-1,-1,-2.......until the last term.
The sum of the one period is $(-1)^2+(-1)^2+(2)^2=6$, and we have 27$\div$ 3=9, so the final value is equal to 6$\times$9=54.
