Modified: March 16, 2022
trace
This page is from my personal notes, and has not been specifically reviewed for public consumption. It might be incomplete, wrong, outdated, or stupid. Caveat lector.Trace of a Linear Operator
We define the trace as the sum of diagonal elements of a matrix:
Lemma: If and are square, then . Proof: Using the notation above, we write
An analogous argument using the general notation for multiple matrices shows that in general trace is invariant to cyclic permutation, i.e. it holds that . Note that trace is not invariant to arbitrary permutations (or even just swapping of adjacent pairs). For example, in general.
Now we can prove an important result.
Theorem: Trace is preserved under change of basis. Proof: Let be an invertible matrix. Then by the circular permutation argument above. This shows that for any change-of-basis matrix , the trace of is preserved in the new basis.
From this we get an easy, but important corollary.
Theorem: The trace of a linear operator is the sum of its eigenvalues. Proof: Let be a diagonalizable linear operator, i.e., one with a full set of orthonormal eigenvectors. Then we can write in its eigenbasis
where is the diagonal matrix of eigenvalues and the rows of are the eigenvectors . Now by the theorem above, we have
Note this theorem is actually true even for non-diagonalizable operators (i.e., where we can't write an explicit eigendecomposition because there aren't linearly independent eigenvectors), but you need a different proof.
Randomized Approximation
Suppose we want to compute , but we don't want to invert since that requires time. There's a randomized trick which gets around this. Let . Then
So we can approximate the trace by sampling a bunch of vectors , and averaging the resulting values of . We can compute each such value in time by solving the linear system , then multiplying . As long as we have to do this fewer than times to get a good approximation, we'll be saving time.
There could probably be some theory here about how many samples we'll actually need to get a good approximation. I think http://scgroup.hpclab.ceid.upatras.gr/faculty/stratis/Papers/Sardenia_Talk.pdf has more info.