Matrix vs. bra ket notation (QM) I have a question. It's very simple to understand, yet it doesn't make sense to me.
Say we have a system with a 2D orthonormal basis $|1⟩$, $|2⟩$. For this system, the energy operator
(Hamiltonian) is:
$$ \hat{H} = E\left[|1⟩⟨1| − |2⟩⟨2| + |1⟩⟨2| + |2⟩⟨1|\right] $$
I want to find the matrix of $\hat{H}$, the eigenvalues of $\hat{H}$ and the normalised eigenvectors of $\hat{H}$.
I know that to find the elements of an operator in a matrix, firstly for a space with $m$ eigenvectors, the matrix is $m\times m$. So in this example, the matrix must be $2\times2$.
The way to find the ith and jth element of the matrix is by using this:
$$  \hat{H}_{i,j} = ⟨\psi_i|\hat{H}|\psi_j⟩ $$
My problem is that for my $\hat{H}$ in the question, doesn't it just go to 0? Because $|1⟩⟨2| = |2⟩⟨1| = 0$ due to orthonormality, and $|1⟩⟨1|=|2⟩⟨2|=1$, hence $\hat{H}$?
Or have I missed something completely here? Also what is $E$? Once I get the matrix, what steps shall I take to find the eigenvalues of $\hat{H}$? To find the eigenfunction, I presume I just apply $\hat{H}$ it to each vector.
I'm really struggling with this, any suggestions would be welcomed.
 A: Be careful with the notation $|x⟩⟨y|$ denotes the outer product while $\langle x | y \rangle$ denotes inner product
$$ H = E[|1⟩⟨1| − |2⟩⟨2| + |1⟩⟨2| + |2⟩⟨1|] $$
where $|1⟩ = \begin{pmatrix}
1 \\
0
\end{pmatrix}$ and $|2⟩ = \begin{pmatrix}
0 \\
1
\end{pmatrix}$
Thus the inner products
$$\langle x|y⟩ = \begin{cases}
    1, & \text{if $x=y$}.\\
    0, & \text{otherwise}.
  \end{cases} $$
For instance matrix elements of $H_{11}$ is
$$\langle 1 |H| 1 \rangle = E\langle 1| \big(|1⟩⟨1| − |2⟩⟨2| + |1⟩⟨2| + |2⟩⟨1|\big)|1 \rangle  = E(\langle 1 | 1 \rangle \langle 1 | 1 \rangle-\langle 1 | 2 \rangle\langle 2 | 1 \rangle+\langle 1 | 1 \rangle\langle 2 | 1 \rangle+\langle 1 | 2 \rangle\langle 1 | 1 \rangle)= E$$
to find the eigenvalues, construct the matrix $H$ this is just vector multiplication then apply
$$\det|H-\lambda I|=0$$
get the characteristic polynomial and eigenvalues will be $\lambda{...}$ with some multiplicity. Your eigenvectors $\textbf{x}$ will be found by substituting each eigenvalues separately into
$$(H-\lambda I)\cdot \textbf{x} =0$$
A: We can define $|1\rangle=\pmatrix{1\\0}$ and $|2\rangle=\pmatrix{0\\1}$. This is just a definition and we can always write states as unit vectors as long you specify in which basis column vectors like $\pmatrix{a\\b}$ are written. Using this definition bra's can be written as row vectors i.e. $\langle 1|=|1\rangle^\dagger=\pmatrix{1&0}^*=\pmatrix{1&0}$ and $\langle 2|=\pmatrix{0&1}$. Writing it this way makes it easier to see that $|i\rangle\langle j|$ is and operator: something which takes a ket as input and outputs another ket, while $\langle i|j\rangle$ is just a number. Visually you can see that the vertical bars in bra's and kets face towards spots where you would expect another bra/ket. As an example $|1\rangle\langle 2|$ is just
$$|1\rangle\langle 2|=\pmatrix{1\\0}\pmatrix{0& 1}=\pmatrix{0&1\\0&0}.$$
A general $2\times 2$ matrix  can be written as
\begin{align}A&=a|1\rangle\langle 1|+b|1\rangle\langle 2|+c|2\rangle\langle 1|+d|2\rangle\langle 2|\\&=\pmatrix{a&b\\c&d}\end{align}
