We are given $U$, $V$ unitary matrices of size $N \times N$ whose spectral decomposition is known (in my specific problem, $N=4$, and $U$, $V$ are matrices with real coefficients but we can keep it general). We are asked to evaluate
$$ \mathrm{Tr} \left( U^{m_1}V^{k_1} \cdots U^{m_n}V^{k_n}\right) $$ for $m_1,\ldots,m_n$ and $k_1,\ldots,k_n$ given integers $\geq 0$.
Do you know an analytic approach to compute these traces?
PS: The hope is that some analytic approach is effective, but any other idea or reference is welcome.
Edit: Do not assume $U$, $V$ to commute. Though I was expecting a generic answer (as may be useful for more users), let us mention the concrete case of interest: $$ U = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & -1 & 0 & 0 \\ 0 & 0 & 1 & -1 \\ 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 1 \end{pmatrix}, ~~ V = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & -1 & 0 & 0 \\ 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & -1 \\ 0 & 0 & 1 & 1 \end{pmatrix}. $$
Not a complete answer, but might be an useful approach for the problem:
Use the known spectral decomposition:
$$ U = \sum_{a} \lambda_a P_a, \qquad V= \sum_{b}\eta_b \pi_b $$ Where $P_a,\pi_b$ are complete systems of hermitian projectors so that
$$ \sum_a P_a = \sum_b \pi_b ={\bf 1}, \qquad P_a P_b = 0, \quad\mbox{and} \quad \pi_a \pi_b =0\quad \mbox{if}\quad a\neq b $$ Here $\lambda_a$ and $\eta_b$ are complex numbers on the unit circle $|\lambda_a| = |\eta_b|= 1$. Then we have
$$ U^n = \sum_a (\lambda_a)^n P_a, \quad V^k = \sum_{b} (\eta_b)^k \pi_b $$ Next we would need to work out the traces of the form
$$Tr(P_{a_1} \pi_{b_1} \cdots P_{a_q}\pi_{b_q})$$ and sum over. Here the set of $P_a$ and the set of $\pi_b$ will not be simultaneously diagonal, but some simple algebraic relations coud exist amongst them in special cases. In the case of your particular matrices there might be some simplification, one would have to check.