(This is a homework question.) The question is to prove that a general operator $\hat{A}$ commutes with any function $\hat{B} = f(\hat{A})$. $$ \newcommand{\ket}[1]{\left| #1 \right\rangle} \newcommand{\bra}[1]{\left\langle #1 \right|} $$ I started off by stating that it's enough to prove that $\hat{A} \hat{B}=\hat{B} \hat{A}$. I want to understand the proof for discrete vector space before moving into other spaces.
So I write $\hat{A} = \sum\limits_{i} a_i\ \ket{a_i}\bra{a_i}$, and $f(\hat{A}) = \sum\limits_{j} f(a_j)\ \ket{a_j}\bra{a_j}$; where $a_i$ and $\ket{a_i}$ are eigen values and eigen vectors of $\hat{A}$ respectively.
I start off with LHS $\\= \hat{A} \hat{B} \\= \sum\limits_{i} a_i\ \ket{a_i}\bra{a_i} \times \sum\limits_{j} f(a_j)\ \ket{a_j}\bra{a_j} \\= \sum\limits_{i} \sum\limits_{j} a_i\ f(a_j)\ \ket{a_i} (\bra{a_i} \ket{a_j})\bra{a_j} \\= \sum\limits_{i} \sum\limits_{j} a_i\ f(a_j)\ \ket{a_i}\ \delta_{ij}\ \bra{a_j} \\= \sum\limits_{i} \sum\limits_{j} a_i\ f(a_j)\ \ket{a_i}\bra{a_j}$
And similarly, RHS $\\=\hat{B} \hat{A} \\ = \sum\limits_{j} f(a_j)\ \ket{a_j}\bra{a_j} \times \sum\limits_{i} a_i\ \ket{a_i}\bra{a_i} \\= \sum\limits_{j} \sum\limits_{i} f(a_j)\ a_i\ \ket{a_j} (\bra{a_j} \ket{a_i})\bra{a_i} \\= \sum\limits_{j} \sum\limits_{i} f(a_j)\ a_i\ \ket{a_j}\ \delta_{ji}\ \bra{a_i} \\= \sum\limits_{j} \sum\limits_{i} f(a_j)\ a_i\ \ket{a_j}\bra{a_i}$
But I'm stuck as I see that $\ket{a_j}\bra{a_i} \ne \ket{a_i}\bra{a_j}$.
EDIT: My question is: Can this be proved using the eigen vectors of $\hat A$? (Am I supposed to knock off a summation subscript when I take the $\delta_{ij}$ product?)
\newcommand
. $\endgroup$