TITLE: Conditions on matrices imply that 3 divides $n$
QUESTION [6 upvotes]: A quite popular exercise in linear algebra is the following (or very related exercises, see for example https://math.stackexchange.com/questions/299651/square-matrices-satisfying-certain-relations-must-have-dimension-divisible-by-3 and https://math.stackexchange.com/questions/3109173/ab-ba-invertible-and-a2b2-ab-then-3-divides-n):

Let $K$ be a field of characteristic different from 3 and $X$ and $Y$ two $n\times n$-matrices with $X^2+Y^2+XY=0$ and $XY-YX$ invertible. Then 3 divides $n$.

A (representation-theoretic) proof can be given as in the answer of Mariano Suárez-Álvarez in https://math.stackexchange.com/questions/299651/square-matrices-satisfying-certain-relations-must-have-dimension-divisible-by-3 .

Question: Is this also true for fields of characteristic 3?



edit: So it turned out that the result holds for any field. A bonus question might be to find a proof that works independent of the characteristic of the field.

REPLY [5 votes]: Let me start from $M^2=[M,Y]$ with $M\in {\bf GL}_n(k)$, as suggested by Andrea. Wlog, I assume that the characteristic polynomial of $M$ splits over $k$, and I decompose $k^n$ as the direct sum of characteristic subspaces $E_\mu=\ker(M-\mu I_n)^n$. It is enough to prove that the dimension of each $E_\mu$ is a multiple of $3$. To this end, observe that $Y$ acts over $E_\mu$. In details, let $x$ be an eigenvector, $Mx=\mu x$. Then $(M-\mu)Yx=\mu^2x$. Because $M$ is invertible, $\mu\ne0$ and therefore 
$$Yx\in\ker(M-\mu)^2\setminus\ker(M-\mu).$$
Likewise
$$(M-\mu)Y^2x=2\mu^2Yx+2\mu^3x,$$
hence $Y^2x\in\ker(M-\mu)^3\setminus\ker(M-\mu)^2$.
Eventually, using again ${\rm char}(k)=3$, we have 
$$(M-\mu)Y^3x=0.$$
We deduce that a basis $E_\mu$ is obtained by taking a basis $\cal B$ of $\ker(M-\mu)$, and adjoining the vectors of $Y\cal B$ and $Y^2\cal B$ ; all of them are linearly independent, as seen above. Thus $\dim E_\mu=3\dim\ker(M-\mu)$.