# Writing operators in the position basis

To calculate an expecation value in quantum mechanics of some operator $$\hat A$$ you can generally write it in Dirac notation $$\langle \hat A\rangle=\langle\psi|\hat A|\psi\rangle.$$ In the position basis this becomes the following integral: $$\int \mathrm {d}x\ \psi^*(x)A(x)\psi(x).$$ But when I try to derive this explicitly from Dirac notation I get \begin{align}\langle\psi|\hat A|\psi\rangle &=\langle\psi|\left(\int \mathrm{d}x|x\rangle\langle x|\right)\hat A\left(\int \mathrm{d}x'|x'\rangle\langle x'|\right)|\psi\rangle\\ &=\int \mathrm{d}x\ \mathrm{d}x'\langle\psi|x\rangle\langle x|\hat A|x'\rangle\langle x|\psi\rangle\\ &=\int \mathrm{d}x\ \mathrm{d}x'\ \psi^*(x)\,\langle x|\hat A|x'\rangle\,\psi(x'). \end{align} The reason I'm stuck is that I don't remember ever calculating the matrix elements in the position basis. How do you calculate these matrix elements in the position basis (or more generally in any basis)?

In order to calculate the matrix elements of an operator, you need to know how the operator acts on the basis states. This is usually something that you're given (because it's almost always how an operator is defined in the first place - by its action on basis states). So, if you want to calculate the matrix elements, you need at least that much information (which can be provided directly, or in shorthand using the operator's position-space representation described below).

If $$\hat{A}$$ happens to have every $$|x\rangle$$ basis state as an eigenstate, then you can write $$\hat{A}|x\rangle=A(x)|x\rangle$$, where $$A(x)$$ is the operator's position-basis representation. Then you can say that $$\langle x'|\hat{A}|x\rangle=A(x)\langle x'|x\rangle=A(x)\delta(x-x')$$. For example, for the simple-harmonic-oscillator potential operator $$\hat{A}=\kappa\hat{x}^2$$, we have that $$\langle x'|\hat{A}|x\rangle=\kappa x^2\delta(x-x')$$.

This condition is not necessarily true in general, though, and there are many operators which simply don't have a nice position-space representation like this. My favorite example is the position translation operator $$\hat{T}_a$$. The action of this operator on the basis states is defined to be as follows: $$\hat{T}_a|x\rangle=|x+a\rangle$$. As you can see, this operator has none of the position basis states as eigenstates! So the matrix element will look slightly different:

$$\langle x'|\hat{T}_a|x\rangle=\langle x'|x+a\rangle=\delta(x+a-x')$$

which you'll notice doesn't conform to the structure $$A(x)\delta(x-x')$$.

• You are absolutely right. I deleted my answer. Sep 29, 2019 at 23:34
• Does that mean that $\langle\hat A\rangle=\int \mathrm {d}x\ \psi^*(x)A(x)\psi(x)$ is not generally true? Would this be true for the (usual) Hamoltonian operator $\hat H=\hat p^2/(2m)+\hat V$? Sep 30, 2019 at 11:54
• @user3502079 It depends on whether or not you consider $A(x)$ to be a function (which yields a number) or a functional (a function which acts on other functions, for example $A(x)=\frac{\partial}{\partial x}$). If $A(x)$ is a function, then no, you have $\langle \hat{p}^2\rangle=\int dx \psi^*(x)\hbar^2\frac{\partial^2\psi}{\partial x^2}(x)$. If $A(x)$ is a functional, then you can declare $A(x)=\hbar^2\frac{\partial^2}{\partial x^2}$. Sep 30, 2019 at 14:08