Name of an identity for traceless matrices in $\mathbb{R}^3$? While working on a more compact presentation of a derivation in the context of incompressible fluid flow we tried to simplify things by introducing intermediate steps instead of writing out lengthy terms. One result was the following identity dealing with traceless matrices in $\mathbb{R}^3$. Is there a name for this, possibly in a more general context?
Let the matrix $A \in \mathbb{R}^{3 \times 3}$ be traceless, i.e., $\mathop{\rm tr}(A) := \sum_{i=1}^3 a_{ii} = 0$. Then
\begin{equation}
x^\top A y = \sum\nolimits_{i=1}^3 (A(x \times e_i))^\top \cdot (e_i \times y).
\end{equation}
Here, $x,y \in \mathbb{R}^3$ and $e_i$ denote the $i$th unit vector. I proved this by writing everything out explicitly and canceling terms, but the following Python-code also shows this symbolically:
from sympy import *

a = Matrix([symbols('a11 a12 a13'), \
            symbols('a21 a22 a23'), \
            symbols('a31 a32 a33')])
x = Matrix(symbols('x1 x2 x3'))
y = Matrix(symbols('y1 y2 y3'))

e = [Matrix([1,0,0]), Matrix([0,1,0]), Matrix([0,0,1])]

res = x.T*a*y \
  - (x.cross(e[0]))*a.T*(e[0].cross(y).T) \
  - (x.cross(e[1]))*a.T*(e[1].cross(y).T) \
  - (x.cross(e[2]))*a.T*(e[2].cross(y).T)

print simplify(res.subs(a[2,2], -(a[0,0]+a[1,1]))) # trace-free

 A: I did not found the name of the identity above, but I hope my answer can clarify some aspects, possibly where the need for the condition $\text{tr}(A)=0$ arises.
The key point is that the vectors $x,y$ aren't playing an active role. What is actually enforcing the identity regards the matrix $A$ and a certain matrix $B$, which will be defined below.
Preliminarly, observe that the cross product in $\mathbb{R}^3$ can more conveniently be expressed with matrix multiplication. More precisely, the cross product of a generic vector $v \in \mathbb{R}^{3 \times 1}$ for the canonical base vectors $e_i$, with $i=1,2,3$, is of the type
$v \times e_i = C_i v$
where $C_i$ are the following skew-symmetric ($C_i^T = - C_i$) matrices:
$
C_1 = \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & -1 & 0 \end{bmatrix}, \quad
C_2 = \begin{bmatrix} 0 & 0 & -1 \\ 0 & 0 & 0 \\ 1 & 0 & 0 \end{bmatrix}, \quad
C_3 = \begin{bmatrix} 0 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}
$
Thanks to this fact and by observing that $e_i \times y = -(y \times e_i)$, the initial identity can be rewritten as follows
$
\begin{split}
x^T A y &= \sum_{i=1}^3 (x \times e_i)^T A^T (e_i \times y) = - \sum_{i=1}^3 (x \times e_i)^T A^T (y \times e_i) = - \sum_{i=1}^3 (C_i x)^T A^T (C_i y) \\
&= - \sum_{i=1}^3 x^T \underbrace{C^T_i}_{ = - C_i} A^T C_i y = \sum_{i=1}^3 x^T C_i A^T C_i y = x^T \underbrace{\left( \sum_{i=1}^3 C_i A^T C_i \right)}_{=B} y
\end{split}
$
where the matrix $B$ has been stated. Now, the identity is of an easy form, from which
$
x^T A y = x^T B y \iff x^T(A-B)y = 0
$
and observe that the left-hand side must hold for all vectors $x,y \in \mathbb{R}^{3 \times 1}$. Thus, it follows that the identity holds iff $A-B=\mathbf{O}$, where $\mathbf{O}$ is the zero matrix. Now, observe that
$$
\sum_{i=1}^3 C_i^2 = -2 I_3
$$
where $I_3$ is the identity matrix of order 3. Using the properties of the trace, it follows that
$$
(*) \quad \text{tr}(B) = -2 \text{tr}(A)
$$
Now, $A-B=\mathbf{O} \Longrightarrow \text{tr}(A - B)=0$. Using $(*)$ and defining the matrix $D=A-B$, we get
$
\text{tr}(D) = 3 \text{tr}(A)
$
which is equal to zero iff $\text{tr}(A)=0$.

Old proof. In general, what holds true is the following

$
a_{ij} = b_{ij} \quad \forall i \neq j
$
that is, the matrix $B$ differs from the matrix $A$ only for the elements on the main diagonal. This can be proven by direct computation and is always true, regardless of the trace of $A$. Moreover, it can proven (by direct computation) that the matrix $D = A - B$ is a diagonal matrix whose elements on the main diagonal are all equal to the trace of the matrix $A$. In other words,
$
D = \begin{bmatrix} \text{tr}(A) & 0 & 0 \\
0 & \text{tr}(A) & 0 \\
0 & 0 & \text{tr}(A)
\end{bmatrix} = \text{tr}(A) I_3
$
Thus, the following fact can be proved: the identity in the original question, i.e., $x^T D y=0$, holds true if and only if $D$ is the zero matrix. But $D$ is the zero matrix if and only if $\text{tr}(A)=0$.
I hope this can, at least, help to give you a different perspective.
