<s>[INST] If $1+x^2=\sqrt{3}x$ then $\sum _{n=1}^{24}\left(x^n+\frac{1}{x^n}\right)^2$ is equal to I tried this problem by different methods but i am not able to get the answer in easy way . First i found the roots of equation and then represented it in polar form of complex number . I got $\cos \left(30^{\circ}\right)\pm i\sin \left(30^{\circ}\right)$ . 
Then i tried to open whole square of question and the only thing i could sum up was that the terms of $x^2$ and $1/x^2$ must have cancelled and got the answer as $-48$ . I have seen one question like this in a book where equation was $x^2 + x + 1 =0$ and the roots of this equation are $\omega$ and $\omega ^2$ . Then they solved by putting values of $\omega$ in different sums but what if sum is large like upto $27$ terms ? 
Is there a specific way to approach these kind of problems ?
Thanks for the help
 [/INST] For $\quad x=\cos 30^{\circ}+i\sin 30^{\circ}\quad$ from De Moivrè's formula follows
\begin{align}
x^n&=\cos (30^{\circ}n)+i\sin (30^{\circ}n)\\
\frac{1}{x^n}=x^{-n}&=\cos (30^{\circ}n)-i\sin (30^{\circ}n)\\
\end{align}
Hence,
$$x^n+\frac{1}{x^n}=2\cos(30^{\circ}n)\tag{1}$$
On the other hand, $\cos (x+360^{\circ})=\cos x$, so
$$\sum_{n=1}^{24}\left(x^n+\frac{1}{x^n}\right)^2=\sum_{n=1}^{24}\left[2\cos(30^{\circ}n)\right]^2=4\sum_{n=1}^{24}\left[\cos(30^{\circ}n)\right]^2=2\cdot4 \sum_{n=1}^{12}\cos^2(30^{\circ}n)\tag{2}$$
As $\cos (x+180^{\circ})=-\cos x$ we get $\quad\cos^2 [30^{\circ}(k+6)]=\cos^2 (30^{\circ}k),\quad$ then ($2$) becomes
\begin{align}
\sum_{n=1}^{24}\left(x^n+\frac{1}{x^n}\right)^2&=2\cdot4\cdot 2 \sum_{n=1}^{6}\cos^2(30^{\circ}n)\\
&=16\left[\cos^2 30^{\circ}+\cos^2 60^{\circ}+\cos^2 90^{\circ}+\cos^2(60^{\circ})+\cos^2(30^{\circ})+\cos^2(180^{\circ})\right]\\
&=16\left[2\cdot\left(\frac{\sqrt{3}}{2}\right)^2+2\cdot\left(\frac{1}{2}\right)^2+0+1\right]\\
&=16(3)\\
&=48
\end{align}
Here we have used the fact that $\;\;\;\cos (180^{\circ}-x)=-\cos x\;\;\;$ to get $\;\;\;\cos^2 (180^{\circ}-x)=\cos^2 x$. The same is true for $\;\;\; x=\cos 30^{\circ}-i\sin 30^{\circ}\;\;$ cause ($1$) is still true in such case.
</s>