## Activity: 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 Quantum Fundamentals 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.
$\dot=$
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).
$x$
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.

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?

This visualization can be a bit tricky. Students may be likely to use pcolor or pcolormesh. Both will give a correct visualization, but the “diagonal” of the matrix (which is prominently visible) will be going from lower-left to upper-right, which is not how we write matrices. I tend to address this by asking students where the 1-1 element of the matrix is. In these cases, it will be in the lower-left, and once students realize that they are likely to follow the rest.

There is another function called matshow which is designed for displaying matrices. It wouldn't hurt to direct students towards this. The key is to use the word “matrix” in the search, as in searching for matplotlib plot matrix.

Another feature I would ask about is where the matrix has big and small elements. If students omit to show a colorbar, they may not be aware of which elements are almost zero.

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!

There are two common errors: students will often get the indices backwards when indexing into the 2D array of eigenvectors (or equivalently access rows rather than columns), which gives essentially random eigenfunctions.

The other error is to have an off-by-one error in computing the eigenfunctions, skipping an $n+1$, forgetting about their n counting from zero rather than 1. This gives a peak that looks a lot like a derivative of the correct eigenfunction.

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?

We would like students to observe that there are in fact an infinite number of eigenvalues of the position operator (and eigenfunctions), equally spaced between $0$ and $L$.

Need to wrap up by discussing how these eigenstates converge (slowly), and what they converge 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.

• keyboard Kinetic energy

keyboard Computational Activity

120 min.

##### Kinetic energy
Computational Physics Lab II 2022

Students implement a finite-difference approximation for the kinetic energy operator as a matrix, and then use numpy to solve for eigenvalues and eigenstates, which they visualize.
• group Operators & Functions

group Small Group Activity

30 min.

##### Operators & Functions
Quantum Fundamentals 2022 (3 years) Students are asked to:
• Test to see if one of the given functions is an eigenfunction of the given operator
• See if they can write the functions that are found not to be eigenfunctions as a linear combination of eigenfunctions.
• group Energy and Angular Momentum for a Quantum Particle on a Ring

group Small Group Activity

30 min.

##### Energy and Angular Momentum for a Quantum Particle on a Ring

Quantum Ring Sequence

Students calculate probabilities for a particle on a ring using three different notations: Dirac bra-ket, matrix, and wave function. After calculating the angular momentum and energy measurement probabilities, students compare their calculation methods for notation.
• group Raising and Lowering Operators for Spin

group Small Group Activity

60 min.

##### Raising and Lowering Operators for Spin
Central Forces 2023 (2 years)
• group Outer Product of a Vector on Itself

group Small Group Activity

30 min.

##### Outer Product of a Vector on Itself
Quantum Fundamentals 2022 (2 years)

Students compute the outer product of a vector on itself to product a projection operator. Students discover that projection operators are idempotent (square to themselves) and that a complete set of outer products of an orthonormal basis is the identity (a completeness relation).
• group Matrix Representation of Angular Momentum

group Small Group Activity

10 min.

##### Matrix Representation of Angular Momentum
Central Forces 2023 (2 years)
• assignment Matrix Elements and Completeness Relations

assignment Homework

##### Matrix Elements and Completeness Relations
Quantum Fundamentals 2022 (2 years)

Writing an operator in matrix notation in its own basis is easy: it is diagonal with the eigenvalues on the diagonal.

What if I want to calculate the matrix elements using a different basis??

The eigenvalue equation tells me what happens when an operator acts on its own eigenstate. For example: $\hat{S}_y\left|{\pm}\right\rangle _y=\pm\frac{\hbar}{2}\left|{\pm}\right\rangle _y$

In Dirac bra-ket notation, to know what an operator does to a ket, I needs to write the ket in the basis that is the eigenstates of the operator (in order to use the eigenvalue equation.)

One way to do this to stick completeness relationships into the braket: \begin{eqnarray*} \left\langle {+}\right|\hat{S_y}\left|{+}\right\rangle = \left\langle {+}\right|(I)\hat{S_y}(I)\left|{+}\right\rangle \end{eqnarray*}

where $I$ is the identity operator: $I=\color{blue}{\left|{+}\right\rangle _{yy}\left\langle {+}\right|}\;+\;\color{blue}{\left|{-}\right\rangle _{yy}\left\langle {-}\right|}$. This effectively rewrite the $\left|{+}\right\rangle$ in the $\left|{\pm}\right\rangle _y$ basis.

Find the top row matrix elements of the operator $\hat{S}_y$ in the $S_z$ basis by inserting completeness relations into the brakets. (The answer is already on the Spins Reference Sheet, but I want you do demonstrate the calculation.)

• group Wavefunctions on a Quantum Ring

group Small Group Activity

30 min.

##### Wavefunctions on a Quantum Ring
Central Forces 2023 (2 years)
• assignment Working with Representations on the Ring

assignment Homework

##### Working with Representations on the Ring
Central Forces 2023 (3 years)

The following are 3 different representations for the $\textbf{same}$ state on a quantum ring for $r_0=1$ $$\left|{\Phi_a}\right\rangle = i\sqrt{\frac{ 2}{12}}\left|{3}\right\rangle - \sqrt{\frac{ 1}{12}}\left|{1}\right\rangle +\sqrt{\frac{ 3}{12}}e^{i\frac{\pi}{4}}\left|{0}\right\rangle -i\sqrt{\frac{ 2}{ 12}}\left|{-1}\right\rangle +\sqrt{\frac{ 4}{12}}\left|{-3}\right\rangle$$ $$\left| \Phi_b\right\rangle \doteq \left( \begin{matrix} \vdots \\ i\sqrt{\frac{ 2}{12}}\\ 0 \\ -\sqrt{\frac{ 1}{12}} \\ \sqrt{\frac{ 3}{12}}e^{i\frac{\pi}{4}} \\ -i\sqrt{\frac{ 2}{12}}\\ 0 \\ \sqrt{\frac{4}{12} }\\ \vdots \end{matrix}\right) \begin{matrix} \leftarrow m=0 \end{matrix}$$ $$\Phi_c(\phi) \doteq \sqrt{\frac{1}{24 \pi}} \left( i\sqrt{2}e^{i 3 \phi} -e^{i\phi} +\sqrt{3}e^{i\frac{\pi}{4}} -i \sqrt{2} e^{-i\phi} + \sqrt{4}e^{-i 3 \phi} \right)$$

1. With each representation of the state given above, explicitly calculate the probability that $L_z=-1\hbar$. Then, calculate all other non-zero probabilities for values of $L_z$ with a method/representation of your choice.
2. Explain how you could be sure you calculated all of the non-zero probabilities.
3. If you measured the $z$-component of angular momentum to be $3\hbar$, what would the state of the particle be immediately after the measurement is made?
4. With each representation of the state given above, explicitly calculate the probability that $E=\frac{9}{2}\frac{\hbar^2}{I}$. Then, calculate all other non-zero probabilities for values of $E$ with a method of your choice.
5. If you measured the energy of the state to be $\frac{9}{2}\frac{\hbar^2}{I}$, what would the state of the particle be immediately after the measurement is made?

• assignment Frequency

assignment Homework

##### Frequency
Quantum Mechanics Time Evolution Spin Precession Expectation Value Bohr Frequency Quantum Fundamentals 2022 (2 years) Consider a two-state quantum system with a Hamiltonian $$\hat{H}\doteq \begin{pmatrix} E_1&0\\ 0&E_2 \end{pmatrix}$$ Another physical observable $M$ is described by the operator $$\hat{M}\doteq \begin{pmatrix} 0&c\\ c&0 \end{pmatrix}$$ where $c$ is real and positive. Let the initial state of the system be $\left|{\psi(0)}\right\rangle =\left|{m_1}\right\rangle$, where $\left|{m_1}\right\rangle$ is the eigenstate corresponding to the larger of the two possible eigenvalues of $\hat{M}$. What is the frequency of oscillation of the expectation value of $M$? This frequency is the Bohr frequency.

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