Understanding the trace operator and non-diagonal matrices

linear algebramatrices

Let $A \in \mathbb{R}^{n \times n}$, and let $B \in \mathbb{R}^{n \times n}$, where $B$ is a diagonal matrix with $b > 0$ along the diagonal.

Then we have $$tr(AB) = tr(BA) = b* tr(A),$$
where we can factor out $b$ from the trace operator.

Now suppose $B$ is no longer a diagonal matrix. Suppose it has $b > 0$ along the diagonal and $b' \in \mathbb{R}$ in the off-diagonals.

If we're interested in computing $tr(AB)$, is it still possible to still factor out some function of $b$ from the trace operator?

Here's a simple example I tried:

$A = \begin{bmatrix}1 & 2 \\ 3 & 9 \end{bmatrix}, B = \begin{bmatrix}b & b' \\ b' & b\end{bmatrix}$

then we have
\begin{align}
tr(BA) &= tr\left(\begin{bmatrix}b & b' \\ b' & b\end{bmatrix}\begin{bmatrix}1 & 2 \\ 3 & 9 \end{bmatrix}\right)\\
&= tr\left(\begin{bmatrix}b + 3b' & 2b + 9b' \\ 3b + b' & 9b + 2b'\end{bmatrix}\right)\\
&= 10b + 5b'
\end{align}

\begin{align}
tr(A) &= tr\left(\begin{bmatrix}1 & 2 \\ 3 & 9 \end{bmatrix}\right)\\
&= 10
\end{align}

So it looks like $$tr(AB) = b * tr(A) + (a_{12} + a_{21}) * b'$$

where $a_{12}, a_{21}$ are the off-diagonal entries in $A$.

Best Answer

Not really. For any four numbers $x$, $y$, $z$, and $t$, you have$$\operatorname{tr}\left(\begin{bmatrix}x&y\\z&t\end{bmatrix}\begin{bmatrix}b&b'\\b'&b\end{bmatrix}\right)=b\operatorname{tr}\begin{bmatrix}x&y\\z&t\end{bmatrix}+b'(z+y).$$