# Operator in Dirac notation

Lets say I have a operator $\textbf{A}$ = $\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$ in a canonical basis {|a⟩ ,|b⟩}.

The operator can be re-written in Dirac notation as $\textbf{A}$= $|a⟩⟨a| + 2 |a⟩⟨b| + 3|b⟩⟨a| + 4 |b⟩⟨b|$, since any operator can be written as the sum of basis states $\sum_{i,j}^{} c_{ij} |i⟩⟨j|$ where $c_{ij}$ are the matrix elements. Does anyone know the derivation of this ? I just applied the formula, but want to know how that is true.

Write $$\boldsymbol{A}=\sum_{ij} c_{ij}\vert i\rangle\langle j\vert\, .$$

Then \begin{align} A_{11}&=1\, ,\\ &=\langle 1\vert A\vert 1 \rangle =\sum_{ij} c_{ij} \langle 1\vert i\rangle\langle j\vert 1\rangle\, , &=c_{11}\, , \\ A_{12}&=2\, ,\\ &=\langle 1\vert A\vert 2 \rangle =\sum_{ij} c_{ij} \langle 1\vert i\rangle\langle j\vert 2\rangle\, , &=c_{12}\, , \end{align} etc.

This formula derivates from how you write the representation of Operators, so, you begin to the operator equation

$$\hat{A} \vert \psi \rangle = \vert \phi \rangle$$

$\vert \psi \rangle$ is a complete set of orthogonal basis, thus, they are expanded

$$\vert \phi \rangle = \hat{A} \vert \psi \rangle = \hat{A}\sum_i \vert \xi_i\rangle \langle \xi_i \vert \psi \rangle$$

Multiply for $\langle \xi_j \vert$

$$\langle \xi_j \vert \phi \rangle = \langle \xi_j \vert \hat{A}\sum_i \vert \xi_i\rangle \langle \xi_i \vert \psi \rangle = \sum_i \langle \xi_j \vert \hat{A}\vert \xi_i\rangle \langle \xi_i \vert \psi \rangle$$

The terms $\langle \xi_j \vert \hat{A}\vert \xi_i\rangle$ are the matrix elements of the operator $\hat{A}$ respect to the basis states $\vert \xi_i \rangle$ and can write as

$$\langle \xi_j \vert \hat{A}\vert \xi_i\rangle = A_{ji}$$

Then $$\phi_j = \sum_i A_{ji} \psi_i$$

This can writes as a matrix: $$\begin{bmatrix} \phi_1 \\ \phi_2 \\ \phi_3 \\ \vdots \\ \phi_j \end{bmatrix} = \begin{bmatrix} A_{11} & A_{12} & \ldots & A_{1j} \\ A_{21} & A_{22} & \ldots & A_{2j} \\ A_{31} & A_{32} & \ldots & A_{3j} \\ \vdots & \vdots & \ddots & \vdots \\ A_{i1} & A_{i2} & \ldots & A_{ij} \end{bmatrix} \begin{bmatrix} \psi_1 \\ \psi_2 \\ \psi_3 \\ \vdots \\ \psi_i \end{bmatrix}$$