The matrix elements of an operator \(\hat{O}\) are the entries of the matrix representation of the operator.

Consider a linear map from a vector space \(V\) to the same vector space, i.e. \(\vert\phi\rangle=\hat{O}\vert\psi\rangle\), where \(\vert\psi\rangle,\vert\phi\rangle\in V\) and the orthonormal basis states \(\vert\varphi_n\rangle\) span \(V\). The matrix representation of the equation is
$$\begin{pmatrix} \phi_1\\\phi_2 \\ \vdots \end{pmatrix}=\begin{pmatrix} O_{11} &O_{12} &\cdots \\ O_{21} &O_{22} &\cdots \\ \vdots & \vdots &\ddots \end{pmatrix}\begin{pmatrix} \psi_1\\\psi_2 \\ \vdots \end{pmatrix}$$
where \(\phi_m\) and \(\psi_n\) are the coefficients of the vectors \(\vert\phi\rangle\) and \(\vert\psi\rangle\) respectively.
The matrix elements of \(\vert\phi\rangle\) are given by
$$\phi_m=\sum_{n}O_{mn}\psi_n\; \; \; \; \; \; \; \; 32a$$
Since the orthonormal basis states \(\vert\varphi_n\rangle\) span \(V\), we have \(\vert\psi\rangle=\psi_1\vert\varphi_1\rangle+\psi_2\vert\varphi_2\rangle+\cdots=\sum_n\vert\varphi_n\rangle\langle\varphi_n\vert\psi\rangle\). So,
$$\vert\phi\rangle=\hat{O} \sum_{n}\vert\varphi_n\rangle\langle\varphi_n\vert\psi\rangle =\sum_{n}\hat{O}\vert\varphi_n\rangle\langle\varphi_n\vert\psi\rangle$$
where we have used the fact that a linear operator distributes over addition for the second equality.

Question
Prove that a linear operator distributes over addition.
Answer
We want to show that \(\hat{O}(\boldsymbol{x}+\boldsymbol{y})=\hat{O}\boldsymbol{x}+\hat{O}\boldsymbol{y}\), where \(\boldsymbol{x}\) and \(\boldsymbol{y}\) are column vectors. The \(i\)-th component of \(\hat{O}(\boldsymbol{x}+\boldsymbol{y})\) is
$$\begin{align*}[\hat{O}(\boldsymbol{x}+\boldsymbol{y})]_i&=\sum_jO_{ij}(x_j+y_j)=\sum_j(O_{ij}x_j+O_{ij}y_j)\\&=\sum_jO_{ij}x_j+\sum_jO_{ij}y_j=(\hat{O}\boldsymbol{x})_i+(\hat{O}\boldsymbol{y})_i\end{align*}$$
Since every component is equal, \(\hat{O}(\boldsymbol{x}+\boldsymbol{y})=\hat{O}\boldsymbol{x}+\hat{O}\boldsymbol{y}\).
It follows that
$$\langle\varphi_m\vert\phi\rangle=\sum_{n}\langle\varphi_m\vert\hat{O}\vert\varphi_n\rangle\langle\varphi_n\vert\psi\rangle$$
Similarly, \(\vert\phi\rangle=\phi_1\vert\varphi_1\rangle+\phi_2\vert\varphi_2\rangle+\cdots\) and so
$$\phi_m=\sum_{n}\langle\varphi_m\vert\hat{O}\vert\varphi_n\rangle\psi_n\; \; \; \; \; \; \; \; 33$$
Comparing eq33 with eq32a, \(O_{mn}=\langle\varphi_m\vert\hat{O}\vert\varphi_n\rangle\). Therefore, \(O_{mn}\) are the matrix elements of \(\hat{O}\) with respect to the basis states of \(\vert\varphi_n\rangle\).
