Product of nilpotent matrices.

The answer is no.

Take $A=\left(\begin{array}{cccc} 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 \end{array}\right)$, $B=XAX^{-1} = \left(\begin{array}{cccc} -1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ -1 & 1 & -1 & 1\end{array}\right)$, where we chose $X=\left(\begin{array}{cccc} 1 & 0 & 0 & 0 \\ 1 & 1 & 0 & 0 \\ 0 & 1 & 1 & 0 \\ 0 & 0 & 1 & 1 \end{array}\right)$.

Then $[A,B]= \left(\begin{array}{cccc} 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ -1 & 1 & -1 & 1 \\ 0 & 1 & -1 & 1 \end{array}\right)$ is nilpotent, but we have $AB=\left(\begin{array}{cccc} 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ -1 & 1 & -1 & 1 \\ 0 & 0 & 0 & 0 \end{array}\right)$ and $\operatorname{trace}(AB)=-1\not=0$.


No. While the conjecture is true for $n=2$ and computer experiments suggest that it may also be true for $n=3$, counterexamples are abundant when $n=4$. Let $A$ be the $4\times4$ Jordan block. The following $B$s are some computer generated random counterexamples that satisfy the condition $B^4=(AB-BA)^4=0$ but $\mathrm{trace}(AB)\neq0$. \begin{align*} \pmatrix{0&0&0&0\\ 0&1&1&0\\ -1&-1&-1&0\\ 1&0&0&0}, &\pmatrix{ 4& -4& 4& -6\\ 2& -2& 2& -3\\ 14&-14& 14&-13\\ 16&-16& 16&-16 },\\ \\ \pmatrix{ 1& 1& 1& 2\\ 0& 0& 0& 0\\ 1& 2& 1& 2\\ -1& -2& -1& -2\\ }, &\pmatrix{ -1& -1& 0& 0\\ 1& 1& 0& 0\\ 0& 0& 0& 1\\ 1& 1& 0& 0\\ }. \end{align*}