Trace of an operator matrix (Quantum computation and quantum information)

I'm reading the book Quantum computation and quantum information by Mike & Ike and I'm stuck at 2.60/2.61. There, the author says that, given the operator $A|ψ⟩⟨ψ|$, its trace is:

$${\rm tr}(A|\psi\rangle\langle\psi|) = \sum\limits_i\langle i|A|\psi\rangle\langle\psi|i\rangle$$

Why would that be true? Why can we rearrange the bras and kets like that?

• I worked backwards from equation 2.61 as follows but I'm concerned that my argument is circular so I will post as a comment: $$\langle\psi|A|\psi\rangle =\sum_{i'}\sum_{i''}\langle\psi| i'\rangle\langle i'| A| i''\rangle\langle i''|\psi\rangle$$ $$=\sum_{i'}\sum_{i''}\langle i'| A| i''\rangle \langle i''|\psi\rangle \langle\psi|i'\rangle =\sum_{i'}\langle i'|A|\psi\rangle\langle\psi|i'\rangle =tr(A|\psi\rangle\langle\psi|)$$ Commented Mar 18, 2014 at 21:35
• An entry of a matrix $M$ in Dirac notation is obtained (given a basis $\{|i\rangle\}$) via $M_{ij}=\langle i|M|j\rangle$. The trace is the sum of the diagonal entries, i.e. $\operatorname{tr}(M)=\sum_i M_{ii}$ and that's it... Commented Mar 18, 2014 at 23:50
– Mars
Commented Dec 12, 2022 at 18:02

1. Let $\{|i\rangle\}$ be an orthonormal basis for the Hilbert space of the system. Then the trace of an operator $O$ is given by (See the Addendum below) \begin{align} \mathrm {tr}(O) = \sum_i \langle i|O|i\rangle \end{align}

2. For a given state $|\psi\rangle$, we define an operator $P_\psi$ by \begin{align} P_\psi|\phi\rangle = \langle\psi|\phi\rangle|\psi\rangle. \end{align} As a shorthand, we usually write $P_\psi = |\psi\rangle\langle\psi|$.

3. Using steps 1 and 2, we compute: \begin{align} \mathrm{tr}(A|\psi\rangle\langle\psi|) &= \mathrm{tr}(A P_\psi) \\ &= \sum_i \langle i|AP_\psi|i\rangle\\ &= \sum_i \langle i|A (\langle\psi|i\rangle|\psi\rangle)\\ &= \sum_i \langle i|A|\psi\rangle\langle\psi|i\rangle \end{align} which is the desired result.

For simplicity, I'll restrict the discussion to finite-dimensional vector spaces. Recall that if $O$ is a linear operator on a vector space $V$, and if $\{|i\rangle\}$ is a basis for $V$, then the matrix elements $O_{ij}$ of $O$ with respect to this basis are defined by it's action on this basis as follows: \begin{align} O|i\rangle = \sum_jO_{ji}|j\rangle. \tag{$\star$} \end{align} The trace of the linear operator with respect to this basis is then defined as the sum of its diagonal entries; \begin{align} \mathrm{tr}(O) = \sum_i O_{ii}. \tag{$\star\star$} \end{align} Now it turns out that the trace is a basis-independent number, so we can simply refer to the trace of the the linear operator; it's just the trace with respect to any chosen basis.

Now, suppose that $V$ is equipped with an inner product, like in the case of Hilbert spaces, and let $\{|i\rangle\}$ be an orthonormal basis for $V$, then we can take the inner product of both sides of $(\star)$ with respect to an element $|k\rangle$ of the basis to obtain \begin{align} \langle k|O|i\rangle = \sum_j \langle k|O_{ji}|j\rangle = \sum_j O_{ji}\langle k|j\rangle = \sum_jO_{ji}\delta_{jk} = O_{ki} \end{align} In other words, $\langle k|O|j\rangle$ gives precisely the matrix element $O_{kj}$ of $O$ in the given basis. In particular, the diagonal entries are given by $\langle i|O|i\rangle$. Plugging this into $(\star\star)$, we get \begin{align} \mathrm{tr} (O) = \sum_i \langle i|O|i\rangle \end{align} as desired.

• Right, my question is mainly why is the trace of an operator given by that thing you said, $\sum_i \langle i|O|i\rangle$.
– Red
Commented Mar 18, 2014 at 21:58
• @PedroCarvalho Ah ok. See the addendum I just wrote. Commented Mar 19, 2014 at 1:10

When we speak about traces we usually mean the linear function $$tr : (\mathbb{H}\to_{lin}\mathbb{H})\to_{lin}\mathbb{C}$$. Also we mean that in the space $$\mathbb{H}\to_{lin}\mathbb{H}$$ there are special functions $$|i\rangle\langle j|$$ which form an orthogonal basis, that is $$\forall B\in \mathbb{H}\to_{lin}\mathbb{H} : \exists B_{ij}\in\mathbb{C}: B = \sum_{ij}B_{ij}|i\rangle\langle j|$$ and that $$|i\rangle$$ and $$|j\rangle$$ are different names of the orthogonal basis vectors in $$\mathbb{H}$$.

Now we have a fact about inner product in $$\mathbb{H}$$ ($$\delta_{ij}$$ = 1 if $$i=j$$, 0 otherwise)

$$\langle i|j\rangle =_1 \delta_{ij}$$

We define our trace $$tr$$ for the basis functions like this: $$tr(|i\rangle\langle j|) =_2 \langle j|i\rangle$$ and automatically get from the one hand $$tr(B) = tr(\sum_{ij}B_{ij}|i\rangle\langle j|)=_{lin} \sum_{ij}B_{ij}tr(|i\rangle\langle j|) =_2 \sum_{ij}B_{ij} \langle j|i\rangle =_1 \sum_{ij}B_{ij}\delta_{ij} = \sum_{i}B_{ii}$$ from the other hand (ignore differences in index names), $$\sum_{i}\langle i|B|i\rangle = \sum_{i}\sum_{mn}B_{mn}\langle i|m\rangle\langle n|i\rangle =_1 \sum_{i}\sum_{mn}B_{mn}\delta_{im}\delta_{ni} = \sum_{i}B_{ii}$$ Finally, assume that $$B = A|\psi\rangle\langle\psi|$$ and get the desired $$tr(A|\psi\rangle\langle\psi|) = \sum_{i}\langle i|A|\psi\rangle\langle\psi|i\rangle$$

• Hey, maybe I am just a dunce but: you write $tr : (\mathbb{H}\to_{lin}\mathbb{H})\to_{lin}\mathbb{R}$ shouldn't the trace go to $\mathbb C$? Commented Aug 24, 2022 at 15:34
• Sure! Fixed, thank you. Commented Aug 24, 2022 at 18:43