# How is $\sum_i\langle i|M|i\rangle$ correlated to $\mathrm{tr}(M)$?

In the book Quantum computation and quantum information, it says to evaluate $$tr(A|\psi\rangle\langle\psi|)$$ using Gram-Schmidt procedure to extend $$|\psi\rangle$$ to an orthonormal basis $$|i\rangle$$ which includes $$|\psi\rangle$$ as the first element. Then:

$$tr(A|\psi\rangle\langle\psi|)=\sum_i\langle i|A|\psi\rangle\langle\psi|i\rangle\tag{2.60}$$ $$=\langle\psi|A|\psi\rangle\tag{2.61}$$

I understood that equation 2.61 that uses the special basis $$|i\rangle$$ described. But in equation 2.60, how $$\sum_i\langle i|M|i\rangle$$ is correlated to $$tr(M)$$ ? Can you help me with a more detailed description of it ?

• The equation in bold is just the definition of a trace computed in the computational basis $\{|i\rangle \}$ where $i=1\dots d$ and $d$ is the dimension of the system. You can pick any basis since trace is basis-independent Feb 1 at 18:30
• Note that by definition: $Tr(M) = \sum_i M_{ii}$ and note that $\langle i| M | i\rangle = M_{ii}$. Feb 1 at 18:52

Thanks for the comments, so $$tr(M)$$ is exactly $$\sum_i\langle i|M|i\rangle$$ as pointed. I just discovered the same question answered with a proof in the physics stackexchange: https://physics.stackexchange.com/a/104155/273977