Student handout: Position operator

Computational Physics Lab II 2022
Students find matrix elements of the position operator \(\hat x\) in a sinusoidal basis. This allows them to express this operator as a matrix, which they can then numerically diagonalize and visualize the eigenfunctions.
What students learn

  1. An operator can be represented in a basis by a matrix, and the elements of that matrix are called "matrix elements" and are given by \(x_{nm} = \langle n|\hat x|m\rangle\).
  2. An operator represented in an infinite basis set is an infinite matrix. And this is okay.
  3. We can approximate an operator using a matrix representing only a subset of the basis functions. (Just like we were able to approximate \(\psi(x)\) with a finite subset of our basis.

Optional learning goals
  1. Eigenstates of position operator are delta functions.

Learning goals shared with last week
  1. Functions can be orthogonal.
  2. Sometimes a wave function is orthogonal to a basis state, esp. when they have different symmetry.
  3. If we inexactly compute a number that is zero, we often get a result that is nonzero, but small.
  4. \(\langle n|m\rangle = \delta_{nm}\) for an orthonormal basis.
Side effects
  1. Real matrices for Hermitian operators are symmetric. (Actually Hermitian, but students won't see that here.)

Operators in quantum mechanics

(In case hasn't covered this yet.) An operator in quantum mechanics corresponds to a linear transformation of a state (or ket). In a matrix representation, an operator would be a matrix, and would transform a column vector to another column vector by matrix multiplication. We represent operators with hats, such as \(\hat{S_z}\).

Any quantity that we could observe, like the spin or position of a particle has a corresponding Hermitian operator. The eigenvalues of the operator corresponding to an obsevables are the set of values that could be measured when that observable is measured. For instance, the \(z\) component of the spin \(\hat{S_z}\) for a spin-\(\frac12\) particle has eigenvalues of \(\pm\frac12\hbar\), which is why only those two spin values are measured.

Any operator can be written as a matrix using any basis set (of the corresponding system). The elements of that matrix, which represents the operator, are called matrix elements, and are given by \(O_{ij} \equiv \left\langle {i}\right|\hat O\left|{j}\right\rangle \), where \(\left|{i}\right\rangle \) and \(\left|{j}\right\rangle \) are two basis states, \(\hat O\) is some operator, and \(O_{ij}\) is an elment of the matrix corresponding to that operator.

Operators on wave functions

A wave function represents the state of a particle in space, just as a ket or an array of two elements represents the state of a spin-\(\frac12\) particle. Just as there are operators for spins that relate to physical observables, there are also operators for particles in space, which act on wave functions.

We will be considering just one operator this week: the position operator. The position operator in the wave function representation is given by \begin{align} \hat x\, &\dot=\, x \end{align} You might have some trouble understanding what this means, given that the hat and the dot are both new notations. I'll try to explain element by element.

\(\hat x\)
This is the operator corresponding to the classical observable \(x\). When we write an operator with a hat like this, we are being abstract in terms of what representation we are using. Warning! We annoyingly use the same notation for a unit vector in the \(x\) direction in Cartesian coordinates! This is unfortunate, but context should allow you to identify the meaning of the hat.
This means that the thing on the left (which is representation-independent) can be represented (often in a particular basis) by the thing on the right (which is specific to that representation/basis).
This is the representation of the position operator in the wave function representation, which we can also call the position basis, since it is the representation in which \(\hat x\) is represented by \(x\). In contrast, next quarter you will learn about a momentum basis, in which \(\hat x\,\dot=\, i\hbar\frac{\partial}{\partial p}\).
Last week we explored how we can represent a wave function in a sinusoidal basis. Today we will explore how to represent the position operator in the sinusoidal basis. In order to do this, we will compute what is called a matrix element. The matrix element is defined by \begin{align} x_{nm} &= \langle n|\hat x|m\rangle \\ &= \int \phi_n^*(x)x\phi_m(x)dx \end{align} and you can think it as one of the "elements" that shows up in a matrix.

Why is this thing a "matrix element"?

Recall that we started by finding the average position, which was \begin{align} \langle x\rangle &= \int \mathcal{P}(x) x dx \\ &= \int |\psi(x)|^2 x dx \\ &= \langle \psi | \hat x | \psi \rangle \end{align} You then found that you could write \(\psi(x)\) as a sum of basis functions \begin{align} |\psi\rangle &= \sum_{n=1}^\infty C_n|n\rangle \\ &= \sum_{n=1}^\infty \langle n|\psi\rangle |n\rangle \end{align} and thus \begin{align} \psi(x) &= \sum_{n=1}^\infty C_n \phi_n(x) \end{align} We can now put these two expressions together by substituting the expressions for \(\psi(x)\) into the expression for \(\langle x\rangle\): \begin{align} \langle x\rangle &= \int \psi(x)^* x \psi(x) dx \\ &= \int\left(\sum_{n=1}^\infty C_n\phi_n(x) \right)^* x \left(\sum_{n=1}^\infty C_n\phi_n(x) \right) dx \end{align} At this point we run into a possible confusion. I've written down two summations with the same summation index. This is a natural outcom of plugging in the equation for \(\psi(x)\), but we've now got two different index variables with the same name. Whenever this happens to you, it's a good idea to change the equation to give them different names. Since we're summing over them, these index variables are "dummy indexes", just as our integral variable \(x\) is a "dummy variable" and could be renamed at will. We could change one of them to \(n'\) or we could change one of them to \(m\). I'll pick the latter. \begin{align} \langle x\rangle &= \int\left(\sum_{n=1}^\infty C_n\phi_n(x) \right)^* x \left(\sum_{m=1}^\infty C_m\phi_m(x) \right) dx \end{align} Now that we have different dummy variables for summation, we can pull reorder our summations and pull them out of the integral \begin{align} \langle x\rangle &= \sum_{n=1}^\infty\sum_{m=1}^\infty C_n^*C_m\int \phi_n(x)^* x \phi_m(x) dx \\ &= \sum_{n=1}^\infty\sum_{m=1}^\infty C^*_nC_m\langle n|\hat x|m\rangle \\ &= \begin{matrix} \begin{pmatrix} C^*_1 & C^*_2 & C^*_2 & \cdots \end{pmatrix} \\ \\ \\ \\ \end{matrix} \begin{pmatrix} \langle1|\hat x|1\rangle &\langle1|\hat x|2\rangle &\langle1|\hat x|3\rangle & \cdots \\ \langle2|\hat x|1\rangle &\langle2|\hat x|2\rangle &\langle2|\hat x|3\rangle & \cdots \\ \langle3|\hat x|1\rangle &\langle3|\hat x|2\rangle &\langle3|\hat x|3\rangle & \cdots \\ \vdots &\vdots &\vdots & \ddots \\ \end{pmatrix} \begin{pmatrix} C_1 \\ C_2\\C_2\\ \vdots \end{pmatrix} \\ &= \langle \psi|\hat x|\psi\rangle \end{align} Thus we can see that the \(\hat x\) operator does seem to be represented in our sinusoidal basis as a matrix of infinite dimension with its elements given by \(x_{nm} = \langle n|\hat x|m\rangle\). Thus we can also write that \begin{align} \hat x \,\dot= \begin{pmatrix} \langle1|\hat x|1\rangle &\langle1|\hat x|2\rangle &\langle1|\hat x|3\rangle & \cdots \\ \langle2|\hat x|1\rangle &\langle2|\hat x|2\rangle &\langle2|\hat x|3\rangle & \cdots \\ \langle3|\hat x|1\rangle &\langle3|\hat x|2\rangle &\langle3|\hat x|3\rangle & \cdots \\ \vdots &\vdots &\vdots & \ddots \\ \end{pmatrix} \end{align} meaning that in the sinusoidal basis the \(x\) position operator is represented by this matrix.

Your task

  1. Write a function that given \(n\) and \(m\) solves for and returns \(\langle n|\hat x|m\rangle\). Please do your integrals numerically. (Yes, these integrals can be done analytically, but that is a bit of a pain, and this is a computational course.)
  2. Create a matrix (or 2D array) for the position operator \(\hat x\). You'll have to choose a maximum value of \(n\) to make this a finite matrix. Please pick something practical, but reasonably big. This is going to require that you index your array. In python, as with most programming languages, arrays are indexed starting with zero, so the index you will put into the array will be one less than the value of \(n\) that you mean.
  3. Visualize this matrix with a color plot. Raise your hand when you have visualized the position operator matrix! Try increasing the number of basis functions included. Does the matrix seem to "converge" like your wavefunctions did last week?

Your next task

Once you have a matrix (or 2D array) corresponding to the position operator in the sinusoidal basis, we will want to determine the eigenstates and eigenvalues of the position operator. Those eigenstates can be expressed in more than one representation. Because the position matrix you construct is in the representation of our sinusoidal basis set, the eigenvectors that you obtain will also be in that representation. \begin{align} \hat x |v_i\rangle &= \lambda_i|v_i\rangle \\ \begin{pmatrix} \langle1|\hat x|1\rangle &\langle1|\hat x|2\rangle &\langle1|\hat x|3\rangle & \cdots \\ \langle2|\hat x|1\rangle &\langle2|\hat x|2\rangle &\langle2|\hat x|3\rangle & \cdots \\ \langle3|\hat x|1\rangle &\langle3|\hat x|2\rangle &\langle3|\hat x|3\rangle & \cdots \\ \vdots &\vdots &\vdots & \ddots \\ \end{pmatrix} \begin{pmatrix} v_{i1} \\ v_{i2} \\ v_{i3} \\ \vdots \end{pmatrix} &= \lambda_i \begin{pmatrix} v_{i1} \\ v_{i2} \\ v_{i3} \\ \vdots \end{pmatrix} \\ |v_i\rangle &= \sum_{n=1}^{\infty} v_{in} |n\rangle \\ v_i(x) &= \sum_{n=1}^{\infty} v_{in} \phi_n(x) \end{align}
  1. Solve for the eigenvalues and eigenvectors of the position matrix (numpy has a function to do this).
  2. Visualize a few of the eigenfunctions of the position operator. These eigenfunctions are given by \begin{align} v_i(x) &= \sum_{n=1}^{\infty} v_{in} \phi_n(x) \end{align}
  3. On the same graph (with the eigenfunctions) visualize the corresponding eigenvalues as vertical lines. Raise your hand when you have visualized at least a couple of eigenfunctions of the position operator along with their corresponding eigenvalues!
  4. Try increasing the size of your matrix, and see how the eigenvalues and eigenfunctions change. What do the eigenfunctions seem to be converging to?
Paper fun

Solve analytically for the eigenstates of the position operator in a wave function representation. Compare them with your approximate numerical eigenstates above.

To do this, you'll want to try picking a function, any function, and then sketch that function and \(x\) times that function. If they look the same, you found the eigenfunction. Otherwise try again.

quantum mechanics operator matrix element particle in a box eigenfunction
Learning Outcomes
  • ph366: 1) Write functions and entire programs in python
  • ph366: 2) Apply the python programming language to solve scientific problems
  • ph366: 3) Use the matplotlib and numpy packages
  • ph366: 4) Model the physical systems studied in the course