Expectation value of pure state in quantum mechanics It's well known that in quantum mechanics, the expectation value of a self-adojint operator $A$ in pure state  $|\psi\rangle$ is  $\langle\psi |A|\psi\rangle = \operatorname{Tr}(A |\psi \rangle \langle\psi |)$. 
My question: why this equality holds? 
I can't see it. I am also unable to find the proof anywhere.
 A: I'll prove the following fact which you may find useful in general: Let $A$ and $B$ be two matrices.  If either of the products $AB$ or $BA$ is well-defined and square, then they both are, and $\mathrm{Tr}(AB)=\mathrm{Tr}(BA)$.
Proof: That $AB$ is well-defined and square means that $B$ is the same shape as the transpose of $A$, so $BA$ is also well-defined and square.  So let $A$ have dimensions $m\times n$ and $B$ have dimensions $n\times m$.  Then the trace of $AB$ is $\sum_{i=1}^m (AB)_{ii} = \sum_{i=1}^m\sum_{j=1}^n a_{ij} b_{ji}$, and interchanging the order of summations we get $\sum_{j=1}^n \sum_{i=1}^m b_{ji}a_{ij} = \sum_{j=1}^n(BA)_{jj}$, which is the trace of $BA$.
In your case, you just need to apply this result to the matrices $\langle\psi|$ and $A|\psi\rangle$: you obtain $\mathrm{Tr}(A|\psi\rangle\langle\psi|) = \mathrm{Tr}(\langle\psi|A|\psi\rangle) = \langle\psi|A|\psi\rangle$, since the latter is just a number.
A: Given a pure state $| \psi \rangle$ in a Hilbert space $\mathcal{H},$ how is the expectation of an observable $A$ calculated? From your question we know of two compatible methods, i.e. $\langle \psi | A | \psi \rangle$ or $\mbox{Tr} (A | \psi \rangle \langle \psi |),$ where $\mbox{Tr}$ denotes the trace. How is equivalence shown? 
Let's start with evaluation of the latter, namely 
$$Tr (A | \psi \rangle \langle \psi |) = \sum_{j} \langle j | A | \psi \rangle \langle\psi | j \rangle.$$ 
We have used the Gram-Schmidt procedure to extend $|\psi \rangle$ to an orthonormal basis $| j \rangle$ which includes $| \psi \rangle$ as the first element. Now, we can take advantage of commutativity to write 
$$\sum_{j} \langle j | A | \psi \rangle \langle\psi | j \rangle = \sum_{j} \langle\psi | j \rangle \langle j | A | \psi \rangle.$$ 
Lastly, we use the resolution of the identity, i.e. 
$$\sum_{j} \langle\psi | j \rangle \langle j | A | \psi \rangle = \langle \psi | A | \psi \rangle.$$
