# Numerically Calculate expectation of $xp+px$?

I'm curious if there is a quick way to numerically calculate $\langle xp + px \rangle$ if we had the density function of our system. For example, if for x we can take the density function in the x-dimension and simply approximate

$\langle x \rangle \approx \sum_{x domain} x |\langle x | \psi \rangle|^2$

or if we wanted $p$ we could fourier transform $\langle x | \psi \rangle$ into the $p$ dimension and calculate

$\langle p \rangle \approx \sum_{p domain} p |\langle p | \psi \rangle|^2$.

xp+px is hermitian, however I do not see an intuitive way to get the density function in a useable form to numerically evaluate $\langle xp + px \rangle$. So even though we have a hermitian operator is not always possible to find a basis to work in? I'm curious for some thoughts, unless I'm missing something obvious.

• A couple of clarifications.There are a number of things that "density function" could be referring to in this context. You seem to mean the probability density functions $f(x) = |\langle x |\psi\rangle|^2$ and $f^\prime(p) = |\langle p |\psi\rangle|^2$ depending on whether you are trying to calculate $\langle x \rangle$ or $\langle p \rangle$. Is this correct? Secondly what exactly is the approximation that you are making? Are you summing over a lattice to approximate the integral over continuous states? or is it something else? – By Symmetry May 22 '17 at 7:51
• Can you not use $p = i\hbar \partial/\partial x$? – Bzazz May 22 '17 at 9:04