# Verify that if $A$ and $B$ are diagonal in the same orthonormal basis, then $[A,B]=0$

This is from Nielson and Chuang's textbook "Quantum Computation and Quantum Information".

They state the Simultaneous Diagonalisation Theorem: Suppose $$A$$ and $$B$$ are Hermitian operators. Then $$[A,B]=AB - BA = 0$$ iff there exists an orthonormal basis such that both $$A$$ and $$B$$ are diagonal with respect to that basis.

In the proof of this theorem, they say "you can easily verify that if $$A$$ and $$B$$ are diagonal in the same orthonormal basis, then $$[A,B]=AB-BA=0$$.

I think you could prove this by letting $$U$$ be a unitary operator performing the change of basis from orthonormal to canonical basis. Then $$A = UDU^{*}$$ and $$B=UEU^{*}$$ Then $$AB=UDU^{*}UEU^{*}=UDEU^{*}=UEDU^{*}=UEU^{*}UDU^{*}=BA$$ ($$D$$ and $$E$$ are diagonal)

$$\newcommand\bra[1]{\left\langle#1\right|}\newcommand\ket[1]{\left|#1\right\rangle}$$ However, the notation the book specifies is the diagonal representation $$A=\sum_{i} a_{i} \ket{i} \bra{i}$$ and $$B = \sum_{i} b_{i} \ket{i} \bra{i}$$ where $$\ket{i}$$ is some common orthonormal set of eigenvectors for $$A$$ and $$B$$. How do I prove that if $$A$$ and $$B$$ are diagonal, then $$[A,B]=0$$ using this notation?

$$A B = (\sum_i a_i|i\rangle\langle i|)(\sum_j b_j|j\rangle\langle j|) = \sum_i \sum_j a_i b_j |i\rangle\langle i|j\rangle\langle j| = \sum_i a_i b_i |i\rangle\langle i|$$ since $$\langle i|j\rangle$$ is 0 if $$i \neq j$$ and 1 if $$i = j$$ due to the basis being orthonormal. From there you can just reverse $$a_i$$ and $$b_i$$ since they are scalars and do the same algebra backwards to get $$BA$$.