Edit: Maybe I should make it clear that by a solution I mean a pair of matrices $(A,B)$ such that the identity below holds for any complex numbers $x,y$.

One of my friend asked me the following question (with some variation): Let $A$,$B$ be two $n\times n$ complex matrices, let $x$ and $y$ be two complex variables. Suppose that $$ (xA+yB)^n=(x^n+y^n)I_n $$ For all $x$ and $y$, Where $xA$ is the scalar multiplication of $A$ by $x$. $I_n$ is the identity matrix.

Question: Can we get explicit solutions when $n$ is small? Can we at least say that the solutions forms a manifold of certain dimension for arbitrary $n$?

You can expand both sides, and move the right side to the left, getting a polynomial whose coefficients are matrices which is identical to $0$. This means the coefficients are all $0$, thus we get a system of homogeneous equations on $A$ and $B$. We can observe that the solution set is stable under taking conjugation by the same invertible matrix. Since $A^n=I_n$, we know that it's diagonalizable, whose eigenvalues are $n$-th roots of unity. Hence we can assume that $A$ is a diagonal matrix. By this simplification, using elementary methods, I was able to find the explicit solution for n=2 and 3. But as $n$ getting large, even for $n=5$, the redundant method requires one to solve a system of polynomial equations of 25 variables. I actually tried it using mathematica, but my poor computer became unresponsive very soon. Any suggestion is appreciated.