Are the trace relations among matrices generated by cyclic permutations? Let $X_1,\dots,X_n$ be non commutative variables such that $\operatorname{tr} f(X_1,\dots,X_n) = 0$ whenever the $X_i$ are specialized to square matrices in $M_r(k)$ for any $r \geq 1$. Does this imply that $f$ is in the ideal generated by cyclic permutations: $g_1\dots g_k - g_2\dots g_k g_1$ for any polynomials $g_i$ in the $X_i$ and $k \geq 2$?
(And if I have missed any obvious relations, is the statement true up to adding in those relations to the ideal?)
 A: For simplicity, let us assume that $K=\mathbb{C}$ (though, these results apply to any field of characteristic zero). We will use capital letters like $X,Y,Z$ to denote matrices while lower case letters like $x,y,z$ shall denote variables.
We will use the fact that the trace of matrices produces an inner product on $M_{n}(\mathbb{C})$ defined by $\langle A,B\rangle=\operatorname{Tr}(AB^{*})$.
If $F$ is a field, then let $F\langle x_{1},\dots,x_{n}\rangle$ denote the ring of non-commutative polynomials over $F$ in the variables $x_{1},\dots,x_{n}$.
We will now go over a few lemmas.
Lemma: Suppose that $f,g\in F\langle x_{1},\dots,x_{n}\rangle$. Then $f=g$ if and only if whenever $r\geq 1$ and
$X_{1},\dots,X_{n}\in M_{r}(F)$, we have $f(X_{1},\dots,X_{n})=g(X_{1},\dots,X_{n})$.
Proof: Suppose that $f\neq g$, and $u>\text{Deg}(f)+\text{Deg}(g)$. Let $V$ be a finite dimensional vector space over $F$ with linearly independent set
$$(e_{i_{1},\dots,i_{k}}|0\leq k\leq u,i_{1},\dots,i_{k}\in\{1,\dots,n\})$$
You can let $X_{1},\dots,X_{n}:V\rightarrow V$ be linear maps such that
$X_{i}(e_{i_{1},\dots,i_{k}})=e_{i,i_{1},\dots,i_{k}}$ whenever $k<u$ and
$X_{i}(e_{i_{1},\dots,i_{k}})=0$ whenever $k=u$. Then $f(X_{1},\dots,X_{n})\neq g(X_{1},\dots,X_{n})$. Q.E.D.
Lemma: Suppose that $f,g_{1},\dots,g_{n}\in\mathbb{C}\langle x_{1},\dots,x_{n},y_{1},\dots,y_{n}\rangle$ and that
$f(x_{1},\dots,x_{n},y_{1},\dots,y_{n})=g_{1}(x_{1},\dots,x_{n})y_{1}+\dots
+g_{n}(x_{1},\dots,x_{n})y_{n}$. Then the following are equivalent.

*

*$f=0$.


*$g_{1}=0,\dots,g_{n}=0$.


*$\operatorname{Tr}(f(X_{1},\dots,X_{n},Y_{1},\dots,Y_{n}))$ whenever $r\geq 1$ and $X_{1},\dots,X_{n},Y_{1},\dots,Y_{n}\in M_{r}(\mathbb{C})$.
Proof: The directions $1\leftrightarrow 2,1\rightarrow 3$ are clear.
$3\rightarrow 2$ Suppose that 3 holds. We have
$$0=\operatorname{Tr}(f(X_{1},\dots,X_{n},Y_{1}^{*},\dots,Y_{n}^{*}))$$
$$=\operatorname{Tr}(g_{1}(X_{1},\dots,X_{n})Y_{1}^{*}+\dots +g_{n}(X_{1},\dots,X_{n})Y_{n}^{*})$$
$$=\langle g_{1}(X_{1},\dots,X_{n}),Y_{1}\rangle+\dots+\langle
g_{n}(X_{1},\dots,X_{n}),Y_{n}\rangle$$
for each choice of $X_{1},\dots,X_{n},Y_{1},\dots,Y_{n}$. Using basic facts about inner product spaces, we can conclude that $$g_{1}(X_{1},\dots,X_{n})=\dots=g_{n}(X_{1},\dots,X_{n})=0$$ for each choice of matrices $X_{1},\dots,X_{n}$. Therefore, by using the above lemma, we can conclude that $g_{1}=0,\dots,g_{n}=0$. Q.E.D.
For all $k$, let $\phi_{k}:\mathbb{C}\langle x_{1},\dots,x_{n}\rangle\rightarrow \mathbb{C}\langle x_{1},\dots,x_{n}\rangle$ be the $\mathbb{C}$-linear mapping such that $$\phi_{k}(x_{a_{1}}\dots x_{a_{v}})=\sum(x_{a_{i+1}}\dots x_{a_{v}}x_{a_{1}}\dots x_{a_{i-1}}\mid 1\leq i\leq v,a_{i}=k)$$  and $\phi_{k}(c)=0$ for each constant term $c$.
For example, $\phi_{3}(x_{2}x_{3}x_{3})=x_{2}x_{3}+x_{3}x_{2}$. One should intuitively think of the functions $\phi_{k}$ as a formal derivative of the trace operator.
Lemma: (product rule for matrix multiplication) Suppose that $\{E,F\}\subseteq\{\mathbb{R},\mathbb{C}\}$ and $A_{1},\dots,A_{n}:E\rightarrow M_{n}(F)$ are differentiable. Then
$\frac{d}{dt}(A_{1}(t)\dots A_{n}(t))=\sum_{k=1}^{n}A_{1}(t)\dots A_{k-1}(t)A_{k}'(t)A_{k+1}(t)\dots A_{n}(t)$.
In particular, from the cyclicity of the trace, we have
$$\operatorname{Tr}(\frac{d}{dt}(A_{1}(t)\dots A_{n}(t)))
=\frac{d}{dt}\operatorname{Tr}(A_{1}(t)\dots A_{n}(t))$$
$$=\sum_{k=1}^{n}\operatorname{Tr}[A_{k}'(t)A_{k+1}(t)\dots A_{n}(t)A_{1}(t)\dots A_{k-1}(t)]$$
$$=\sum_{k=1}^{n}\operatorname{Tr}[A_{k+1}(t)\dots A_{n}(t)A_{1}(t)\dots A_{k-1}(t)A_{k}'(t)].$$
Corollary: For each $f\in\mathbb{C}\langle x_{1},\dots,x_{n}\rangle$, we have
$$\operatorname{Tr}(\frac{d}{dt}f(A_{1}(t),\dots,A_{n}(t)))=
\operatorname{Tr}[\sum_{k=1}^{n}\phi_{k}(f)(A_{1}(t),\dots,A_{n}(t))A_{k}'(t)].$$
Theorem: Suppose that $f\in\mathbb{C}\langle x_{1},\dots,x_{n}\rangle$. Then
the following are equivalent

*

*$\operatorname{Tr}(f(X_{1},\dots,X_{n}))=0$ whenever $X_{1},\dots,X_{n}$ are matrices.


*$f(0,\dots,0)=0$ and $\phi_{k}(f)=0$ whenever $1\leq k\leq n$.


*$f\in I$ where $I$ is the sub-vector space of $\mathbb{C}\langle x_{1},\dots,x_{n}\rangle$ generated by the vectors of the form $x_{a_{1}}\dots x_{a_{v}}-x_{a_{2}}\dots x_{a_{v}}x_{a_{1}}$.
Proof: The direction $3\rightarrow 1$ is clear from the cyclicity of the trace. The direction $3\rightarrow 2$ is also clear.
$1\rightarrow 2$. Suppose that $\operatorname{Tr}(f(X_{1},\dots,X_{n}))=0$ whenever $r\geq 0$ and $X_{1},\dots,X_{n}\in M_{n}(K)$. Then
$$0=\frac{d}{dt}\operatorname{Tr}(f(X_{1}+tY_{1},\dots,X_{n}+tY_{n}))|_{t=0}$$ for each choice of $X_{1},\dots,X_{n},Y_{1},\dots,Y_{n}$. However,
$$0=\frac{d}{dt}\operatorname{Tr}(f(X_{1}+tY_{1},\dots,X_{n}+tY_{n}))|_{t=0}$$
$$=\operatorname{Tr}(\phi_{1}(f)(X_{1},\dots,X_{n})Y_{1}+\dots+\phi_{n}(f)(X_{1},\dots,X_{n})Y_{n}).$$
Therefore, we conclude using the above lemma that $\phi_{1}(f)=\dots=\phi_{n}(f)=0$.
$2\rightarrow 3$. Let $$\theta_{i}:\mathbb{C}\langle x_{1},\dots,x_{n}\rangle\rightarrow\mathbb{C}\langle x_{1},\dots,x_{n}\rangle$$ be the linear mapping such that $$\theta_{i}(x_{a_{1}}\dots x_{a_{r}})=\frac{1}{r+1}x_{i}x_{a_{1}}\dots x_{a_{r}}$$ whenever $r\geq 0,\{a_{1},\dots,a_{r}\}\subseteq\{1,\dots,n\}$.
Define a linear operator $L:\mathbb{C}\langle x_{1},\dots,x_{n}\rangle\rightarrow
\mathbb{C}\langle x_{1},\dots,x_{n}\rangle$ by letting
$$L(f)=f(0,\dots,0)+\theta_{1}(\phi_{1}(f))+\dots+\theta_{n}(\phi_{n}(f))-f.$$ Then we have $L(x_{a_{1}}\dots x_{a_{v}})\in I$ whenever $v\geq 0$ and $L(c)=0\in F$, so by linearity, we conclude that $L(f)\in I$ for each
$f\in\mathbb{C}\langle x_{1},\dots,x_{n}\rangle$. Therefore, if $$\phi_{1}(f)=0,\dots,\phi_{n}(f)=0,f(0,\dots,0),$$ then
$f=-L(f)\in I$. Q.E.D.
A: The reformulation suggested  by Christian Remling and Benjamin Steinberg is true (at least over a field $k$ of characteristic zero):
If $\operatorname{tr} f(X_1,\dots, X_n)=0$ for all $X_1,\dots, X_n$ in $M_r(k)$ then $f$ is a linear combination of differences of cyclically permuted words.
An equivalent, linearly dual, statement:
For $m$ words $w_1,\dots, w_m$ in the variables $X_1,\dots, X_n$, if none is the cyclic permutation of the other, then for any $a_1,\dots, a_n$ in $k$, there exist $r$ and $X_1,\dots X_n \in M_r(k)$ such that $\operatorname{tr}(w_i)=a_i$ for all $i$.
This implies the previous statement because, for each word appearing in $f$, we can add up the coefficients by which all cyclic permutations of that word appear in $f$. If this sum is zero for all words then $f$ is a linear combination of differences of cyclic permutations, and if it is nonzero for some word we can take $a_i=1$ for that word and $a_i=0$ for all remaining words.
Proof: Without loss of generality, assume that the words $w_1,\dots, w_n$ are in nondecreasing order of length.
It suffices to find for each $i$ matrices $Y_{1,i},\dots, Y_{n,i}$ such that $\operatorname{tr} w_j( Y_{1,i}, \dots, Y_{n,i})=0$ for $j<i$ and $\neq 0$ for $j=i$. Then we can construct $X_i$ as a direct sum of suitable scalar multiples of the $Y_{j,i}$.
Suppose the word $w_i$ is $X_{j_1} X_{j_2} \dots X_{j_\ell}$. Define $Y_{j,i}$ as the $\ell \times \ell$ matrix whose entry in the $a$th row and $b$th column is
$$(Y_{j,i})_{ab} =\begin{cases}  1 &  b\equiv a+1 \textrm{ mod }\ell \textrm{ and } j_b=j \\ 0 & \textrm{otherwise} \end{cases} $$
Because the only nonzero enties in these matrices have $b\equiv a+1\textrm{ mod }\ell$, the only nonzero entries in the product of $d$ such matrices have $b \equiv a+d\textrm{ mod }\ell$, so the trace of such a product is nonzero only if $d$ is divisible by $\ell$. Thus the trace vanishes for all shorter words.
For a word of length exactly $\ell$, the only contribution to the trace of the product is from products of entries that follow the cyclic math around, i.e.
$$ \operatorname{tr} Y_{s_1,i} Y_{s_2,i} \dots Y_{s_{\ell-1},i} Y_{s_\ell,i} = \sum_{c=1}^{\ell} (Y_{s_1,i} )_{c (c+1)}  (Y_{s_2,i} )_{(c+1)(c_2)} \dots  (Y_{j_{\ell-1},i} )_{(c-2)(c-1)} (Y_{s_\ell,i} )_{(c-1)c}$$ which is equal to the number of cyclic permutations of $s_1,\dots s_\ell$ that equals $j_1,\dots, j_\ell$ and thus vanishes unless $s_1,\dots, s_\ell$ is a cyclic permutation of $j_1,\dots ,j_\ell$ and is nonzero in case it is a cyclic permutation, as desired.
