Quantum Expectation Values I'm having trouble understanding the motivation for the definition of the expectation of a self adjoint operator $A$:
$$\langle A \rangle _\psi=\int_{\mathbb{R}}\psi^*A\hspace{0.2cm} \psi \hspace{0.2cm} dx$$
where $\psi(x,t)$ is a normalised state.
I can understand the expectation of the position operator in terms of basic probability: one of the assumptions of QM being that $|\psi|^2$ is the probability to find the particle at $x$. The expected value is just the sum of the positions multiplied by their probabilities:
$$\langle x \rangle _\psi=\int_{\mathbb{R}}x \hspace{0.1cm} |\psi(x,t)|^2 dx=\int_{\mathbb{R}}\psi^* \hspace{0.2cm} x \hspace{0.1cm} \psi \hspace{0.1cm}dx$$ by commutativity.
I don't understand how this might work with the momentum operator, for example. The lecture notes for my course say that the expectation of self adjoint operators are defined in analogy to this, so that
$$\langle p \rangle _\psi=\int_{\mathbb{R}}\psi^*\hspace{0.1cm}p \hspace{0.1cm}\psi\hspace{0.1cm} dx$$
I can't satisfy myself with this explanation; $p$ is a differential operator and so can't be moved about within the integral like $x$ can. For example
$$\int_{\mathbb{R}}\psi^*\hspace{0.1cm}\psi\hspace{0.1cm} p\hspace{0.1cm} dx$$ makes no sense to me, as the operator hasn't been applied to anything. In any case, $\int_{\mathbb{R}}|\psi(x,t)|^2 p dx$ doesn't mean anything to me probability-wise.
So basically I'm looking for an explanation as to why the expectation of self-adjoint operators are so defined. Thanks for any replies!
 A: You need to apply the operator first and then evaluate the integral:
$⟨P⟩_ψ = i\hbar\int{\psi^*(x)\frac{d\psi(x)}{dx}dx}$
A: It is very common to abuse the notation here, so I'll try to clarify a bit. The state of a physical system can be described by an abstract vector $\left|\psi\right\rangle$, which is an element of a Hilbert space. The wavefunction, $\psi(x)$ is the representation of that vector in the position basis, $\psi(x)\equiv\left\langle x | \psi\right \rangle \equiv \left\langle x , \psi\right \rangle$. In this notation, $\left|x\right\rangle$ is a state which is located at the point $x$ and nowhere else. 
Think of $\left|\psi\right\rangle$ as a column vector whose components are the values of $\psi(x)$ at each $x$.
$$\psi(x) = \begin{pmatrix}\vdots\\\psi(x_1)\\\psi(x_2)\\\psi(x_3)\\\vdots\end{pmatrix}$$
This vector also has a dual, $\left\langle\psi\right| = \left|\psi\right\rangle^\dagger$, which is the transpose conjugate.
In a different basis, this vector would have different components. Another common basis is the momentum basis, with components $\psi_p(p)=\left\langle p | \psi\right\rangle$, typically written as simply $\psi(p)$.
Just like we could write a 3d vector $\bf{v}$ in the $\bf{i},\bf{j},\bf{k}$
 basis as ${\bf v} = {\bf v}_1{\bf i} + {\bf v}_2{\bf j} + {\bf v}_3{\bf k}$, we can write $\left|\psi\right\rangle$ as a sum of $x$ components, 
$$\begin{align} 
\left|\psi\right\rangle&= \int^{\infty}_{-\infty}\left|x\right\rangle\,\psi(x)\,\text{d}x \\
&= \int^{\infty}_{-\infty}\left|x\right\rangle\!\left\langle x | \psi\right \rangle \,\text{d}x 
\end{align}$$
From this it is clear that $\int^{\infty}_{-\infty}\left|x\right\rangle\!\left\langle x \right|\text{d}x$ is an identity, since when it acts on $|\psi\rangle$ it gives $|\psi\rangle$ back.
Eigenvectors are usually labeled by their eigenvalues, so that if $\hat p$ is an operator with an eigenvalue $p$, we write $\hat{p}\left|p\right\rangle = p\left|p\right\rangle$.
The eigenvectors of a self-adjoint operator form a complete set of states, which is to say that the sum of all the projection operators is the identity, $\int \left|p\right\rangle\left\langle p\right| \,\text{d}p $. This means you could also write 
$$\begin{align}
\langle p\rangle&= \left\langle\psi\right|\hat{p}\left|\psi\right\rangle \\
&=\left\langle\psi\right|\hat{p}\int\left|p\right\rangle\!\left\langle p\right|\,\text{d}p\,\left| \psi\right\rangle\\
&=\int{p}\,\langle\psi\left|p\right\rangle\!\left\langle p\right| \psi\rangle\,\text{d}p\\
&=\int p\,\psi^*\!(p)\,\psi(p)\text{d}p
\end{align}$$
where $\psi(p)=\left\langle p | \psi\right\rangle$. This might make more sense, since it is more obviously an average value of p.
The reason that $\hat p = -i\hbar{\partial \over \partial x}$ in the x basis is that a momentum eigenstate (a state with a single wavelength) is a plane wave, $\langle x \left|p\right\rangle = {1 \over \sqrt{2\pi}} e^{ipx/\hbar}$, and that means that in the x basis, $\left\langle x \right| \hat p\left|p\right\rangle = {p \over \sqrt{2\pi}} e^{ipx/\hbar} = {-i\hbar \over \sqrt{2\pi}}{\partial \over \partial x} e^{ipx/\hbar}$.
