# Derivation of the identity $\sum_j p_j \langle \psi_j|M|\psi_j \rangle = \sum_j p_j \operatorname{tr}\left(|\psi_j \rangle \langle \psi_j|M\right)$

For measurement, we know

$$\langle M \rangle = \sum_j p_j \langle \psi_j|M|\psi_j \rangle = \sum_j p_j \operatorname{tr}\left(|\psi_j \rangle \langle \psi_j|M\right).$$

My question is, how can we go from the first expression to the second one with trace operation? What's the math behind it?

First, note that by definition: $$Tr(X) = \sum_i X_{ii} = \sum_i \langle i| X | i\rangle$$ then now let $$Y = |\psi\rangle \langle\psi|$$ then this implies that

$$Tr(YX) = Tr(XY) = \sum_i \langle i|XY|i\rangle = \sum_i \langle i|X |\psi\rangle \langle\psi |i\rangle = \sum_i \langle \psi| i \rangle \langle i|X |\psi\rangle = \langle\psi|X|\psi\rangle = \langle X \rangle$$

• How have you gotten from $\sum_i \langle i|X |\psi\rangle \langle\psi |i\rangle$ to $\sum_i \langle\psi| X|i\rangle\langle i| \psi \rangle$? I understand how $\langle i|X |\psi\rangle =\langle\psi| X|i\rangle$ if X is hermitian, but $\langle\psi|i\rangle \neq \langle\psi|i\rangle$ Commented Jan 29, 2021 at 16:12
• Thanks for the comment! I edited it... Commented Jan 29, 2021 at 16:25
• Ignore my follow up. Fuck I was scratching my head on where I was going wrong there XD Commented Jan 29, 2021 at 16:28
• Thanks! I have other two basic questions. One is why we can switch $$\langle i|X |\psi\rangle \langle\psi |i\rangle$$ The other one is why we ignore $$| i \rangle \langle i|$$ Commented Feb 1, 2021 at 10:26
• 1) Note that $\langle i|X|\psi\rangle$ is just a number, says $a$; And similarly $\langle \psi | i\rangle$ is also just a number, says $b$. Hence you can switch their order no problem since $a*b = b*a$. 2) Note that the sum of $|i\rangle \langle i|$ is just an idenity operator. Commented Feb 1, 2021 at 10:59

I think the easiest way to see this is through the fact that the trace is independent of the basis in which we take it. That is, for any operator $$A$$ and any orthonormal basis $$\{|i\rangle\}_i$$ we can write $$\mathrm{Tr}[A] = \sum_i \langle i | A | i \rangle.$$

So if $$|\psi_j\rangle$$ is normalised we can just choose any orthonormal basis which includes $$|\psi_j\rangle$$, let's write such a basis as $$\{|\psi_j\rangle, |\psi_{j,1}^{\perp}\rangle, |\psi_{j,2}^{\perp}\rangle, \dots\}$$. Then we have \begin{aligned} \mathrm{Tr}[|\psi_j\rangle \langle\psi_j|M] &= \langle\psi_j|\psi_j\rangle\langle\psi_j|M|\psi_j\rangle + \sum_{i} \langle\psi_{j,i}^{\perp}|\psi_j\rangle\langle\psi_j|M|\psi_{j,i}^{\perp}\rangle \\ &= \langle\psi_j|\psi_j\rangle\langle\psi_j|M|\psi_j\rangle \\ &= \langle\psi_j|M|\psi_j\rangle, \end{aligned} where on the second line we used the fact that $$\langle\psi_{j,i}^{\perp}|\psi_j\rangle = 0$$ for all $$i$$ as they form an orthonormal basis and on the final line we used normalization $$\langle\psi_j|\psi_j\rangle = 1$$.

• Thanks! It's really clear! I just have a simple question. If we have a complicated expression like $$\langle\psi_j|\psi_j\rangle\langle\psi_j|M|\psi_j\rangle$$ How to determine the order of calculation of each vector/matrix in such expression? In your explanation, you group $$\langle\psi_j|\psi_j\rangle$$ and $$\langle\psi_j|M|\psi_j\rangle$$ Commented Feb 1, 2021 at 10:52
• @peachnuts We can do the computations in whatever order we want as matrix multiplication is associative, i.e. $(AB)C = A(BC)$. This allows us to split the computation as above into two parts $ABCDE = (AB)(CDE)$. Treating bras and kets as $1 \times n$ and $n \times 1$ matrices respectively. Commented Feb 1, 2021 at 12:58
• I see! Thanks for your explanation! Commented Feb 2, 2021 at 15:05

$$\langle M\rangle=\sum_{j}p_{j}\langle\psi_{j}|M|\psi_{j}\rangle=\sum_{j}p_{j}\langle\psi_{j}|M\sum_{i}|e_{j}\rangle\langle e_{j}|\psi_{j}\rangle=\sum_{j}p_{j}\sum_{i}\langle e_{j}|\psi_{j}\rangle\langle\psi_{j}|M|e_{j}\rangle=\sum_{j}p_{j} tr(|\psi_{j}\rangle\langle\psi_{j}|M)$$

This involves two steps. In the first, we use the fact that the trace of a number, thought of as a $$1 \times 1$$ martix, is that number. In the second, we use the cyclic property of the trace.

Explicitly, the steps are

$$\langle M \rangle = \sum_j p_j \langle \psi_j|M|\psi_j \rangle = \sum_j p_j \operatorname{tr}\left(\langle \psi_j|M|\psi_j \rangle\right) = \sum_j p_j \operatorname{tr}\left(|\psi_j \rangle \langle \psi_j|M\right).$$