<s>[INST] Product of a Finite Number of Matrices Related to Roots of Unity Does anyone have an idea how to prove the following identity? 
$$
\mathop{\mathrm{Tr}}\left(\prod_{j=0}^{n-1}\begin{pmatrix}  
x^{-2j} & -x^{2j+1} \\
1 & 0
\end{pmatrix}\right)=
\begin{cases}
2 & \text{if } n=0\pmod{6}\\
1 & \text{if } n=1,5\pmod{6}\\
-1 & \text{if } n=2,4\pmod{6}\\
4 & \text{if } n=3\pmod{6}
\end{cases},
$$
where $x=e^{\frac{\pi i}{n}}$ and the product sign means usual matrix multiplication.
I have tried induction but there are too many terms in all of four entries as $n$ grows. I think maybe using generating functions is the way?
 [/INST] UPDATE: As pointed out by Peter Mueller in the comments below, this reduction to continuants does not quite work as stated. I still believe that there is some connection with (possibly generalized) continuants and leave this answer as an unsuccessful attempt to demonstrate it (in hope to fix it later).
Notice that
$$\begin{pmatrix}  
x^{-2j} & -x^{2j+1} \\
1 & 0
\end{pmatrix} = 
\begin{pmatrix}  
-x^{2j+1} & 0 \\
0 & 1
\end{pmatrix}
\cdot
\begin{pmatrix}  
-x^{-4j-1} & 1 \\
1 & 0
\end{pmatrix}.$$
Since diagonal matrices commute with others and $\prod_{j=0}^{n-1} (-x^{2j+1}) = (-1)^n x^{n^2} = 1$, we have
$$\prod_{j=0}^{n-1} \begin{pmatrix}  
x^{-2j} & -x^{2j+1} \\
1 & 0
\end{pmatrix} = 
\prod_{j=0}^{n-1} \begin{pmatrix}  
-x^{-4j-1} & 1 \\
1 & 0
\end{pmatrix}.$$
The last product can be expressed in terms of continuants $K_m(a_1,\dots,a_m)$. Namely, for $j=0,\dots,n-1$, let $a_{j+1} = -x^{-4j-1}$. Then
$$\prod_{j=0}^{n-1} \begin{pmatrix}  
-x^{-4j-1} & 1 \\
1 & 0
\end{pmatrix}=
\begin{pmatrix} K_n(a_1,\ldots,a_n) & K_{n-1}(a_1,\ldots,a_{n-1}) \\ 
K_{n-1}(a_2,\ldots,a_n) & K_{n-2}(a_2,\ldots,a_{n-1}) \end{pmatrix}.
$$
So, it remains to compute values of these continuats. 
P.S. Fedor's answer provides a way to compute the continuants, using Euler's rule.
</s>