Solution (source code)

= Solution

The <matrix trace> is linear, and
$$
\operatorname{tr}(\mathbf e_n\mathbf e_n^{\mathsf T})
=\sum_j(e_n)_j^2=\|\mathbf e_n\|^2=1.
$$
Taking the <trace> of the <spectral decomposition> therefore proves
$$
\boxed{\operatorname{tr}A=\sum_{n=1}^N\lambda_n.}
$$