Computational Activity: Mean position

Computational Physics Lab II 2022
Students compute probabilities and averages given a probability density in one dimension. This activity serves as a soft introduction to the particle in a box, introducing all the concepts that are needed.
What students learn

1. Probability density is the norm square of the wave function
2. An average is a weighted sum

Possible extra learning goals:
1. Normalizing wave functions, normalizing probability density.

Probabilities and probability densities

Much of quantum mechanics is probabilistic. The most that we can predict is the probability of any given outcome of a measurement. Thus you will be spending a lot of time in the next five weeks talking about probabilities. Before we get to writing any code, we're going to spend some time talking about probabilities and probability densities.

As an example, let's consider the disribution of student residences in Corvallis. We are going to begin by collecting some data from which we can draw conclusions about probabilities.

I'll start by creating a table to find out how common different commutes are. I'd like you to figure out (or make up) the distance from where you sleep to Weniger Hall. I'll call out distances and ask you to raise your hand if your home is closer to Weniger than that distance (and you haven't yet raised your hand).

We will now discuss this distribution and how to represent it.

 commute number of people 0.25 miles 1 0.5 miles 4

Will someone volunteer to come forward and create on the whiteboard a visualization of this data?

What are the units of this visualization? The vertical axis is "number of people in this room with a commute in that range."

There are a couple of problems with this histogram that I'd like to draw out of students. If I want to tell people the probability distribution of commutes, in what way is this representation suboptimal? It might help to imagine that we have a whole lot more data.

1. The answer depends on the total number of people in the room. We can address this by dividing each value by that number.

2. The answer depends on how we chose to round our commutes. This would make it hard to compare our results e.g. with a survey that someone else did using metric, or rounding to the nearest sixteenth of an inch. We can address this by dividing each number by one inch.
Taken together, these changes result in a curve that looks identical, but now has dimensions of inverse distance. This is what we call a probability density. Just as a charge density is the amount of charge per unit something else, a probability density is the amount of probability per something else.

How could we find the average commute?

There are three different approaches we could use here. One is to just add up all the commutes. Another is to add up commutes times probabilities. The final is to *integrate* the probability density times the commute. But I'm not sure we want to do this now...

Particle in a box

Consider a particle that is located in a box with width $L$. An interesting question to ask is where the particle is likely to be, but this is complicated by the fact that there are an infinite number of positions the particle could have.

We will be working today with probability densities for a particle in one dimension. This is a linear probability density, which means that it is the probability per unit distance. You can think of the probability density $P(x)$ as being defined by \begin{align} \text{probability it's between $x_0$ and $x_0+\Delta x$} = \int_{x_0}^{x_0+\Delta x} P(x)dx \end{align} So if you imagine $\Delta x$ becoming small, then the probability density $P(x_0)$ is the meaningful answer to the (ill-posed) question, "How likely am I to find the particle at position $x_0$?"

What are the dimensions of $P(x)$?

The probability density of an electron being found at position $x$ is given by $|\psi(x)|^2$, where $\psi(x)$ is a complex-valued function called the wave function. You will learn more about wave functions in the coming weeks, but for today it is the function that you take the norm squared of to find the probability density.

What are the dimensions of $\psi(x)$?

Today you will be computing an average position of the electron, given $\psi(x)$. The electrons will be confined to a region $0<x<L$, so your function is invalid outside of that domain, and you don't have to worry about the electron escaping.

You will be given two wave functions from the following list: \begin{align} \psi_1(x) &= \frac{\sqrt{30}}{L^2\sqrt{L}}x(x-L) & \psi_2(x) &= \frac{x^6\sin(\pi x/L)}{0.07931977085 L^6\sqrt{L}} \\ \psi_3(x) &= \frac{\sqrt{105}}{L^3\sqrt{L}}x^2(x-L) & \psi_4(x) &= \sqrt{\frac{2}{L}}\sin(\pi x/L) \\ \psi_5(x) &= \frac{\sqrt{495}}{L^5\sqrt{L}}x(x-L)^4 & \psi_6(x) &= \sqrt{\frac{2}{L}}\sin(2\pi x/L) \end{align} Using your two wave functions:

1. Write python functions that given $x$ returns the value $\psi(x)$ for each of your $\psi_i(x)$.
2. Plot the wavefunctions, and then plot the corresponding probability density.

There are a couple of issues to look for here.
1. Many students will plot both $\psi(x)$ and $|\psi(x)|^2$ on the same plot (with the same axis). This is a problem because those two quantities have different dimensions, so they can't be compared with each other. I.e. it is a meaningless question to ask which is greater of the two. Students should put them on separate plots. It can be useful to put them on subplots, one over the other, so that you can easily compare the same $x$ values.
2. Many students will plot over some wide range of $x$, e.g. from $-10<x<10$. This is wrong, and there are two different ways to talk about how/why it is wrong. Both stem from the fact that we defined our particle to be in a box ranging from $x=0$ to $x=L$.

One explanation (preferred by Corinne) would be to say that the domain of $\psi(x)$ is from $0$ to $L$, so plotting the wavefunction outside of that range is meaningless.

The other explanation (preferred by Roundy) is to ask the probability that the particle is outside the box. Students will answer that it is zero. Then ask what the probability density is outside the box. Again, it is zero. Thus the wavefunction must be zero outside the box. The function we gave them is actually only valid inside the box, and it is implied by the statement that the particle is in the box.

3. Check that the total probability (i.e. the probability of the particle being anywhere at all) is 1 for each wavefunction.
4. Based on your plots, guess what the average value of $x$ will be, and plot this guess as a vertical line on your probability density plots. Do this step before the following step!

Each pair of wavefunctions (a row above) has one that is symmetric and one that is asymmetric, so students should have an easy guess ($L/2$) and a harder one.

5. Write a program to find the average value of $x$ that would be measured, and then plot this average $x$ as a vertical line on the same plot with the probability density (and the other vertical line). Does it look correct? Does it match what you guessed?

I fully expect students to struggle at this stage. We've got two class periods, so we can let them grapple for a while. Then we will talk them through the idea of a weighted average. At some point I'll need to talk with the whole class about this, but I want to do this *after* everyone has at least discussed with their partner how the could compute the average of an "independent variable."

Extra fun
Find the probability that your particle will be found to be in the right half of the box. Do the same for the left half. Check that the two numbers add up to one.
Mean fun
Find the probability that the particle is to the left of the vertical line giving the average value of $x$.
Other fun

Find the probability that your particle will be found to be in the center half of the box. Do the same for the outside half. Check that the two numbers add up to one.

Complex fun : Try using the following complex wave function: \begin{align} \psi_A(x) &= \sqrt{\frac{2}{L}}\sin(\pi x/L)e^{ikx} \end{align} where $k$ is a number you may choose with dimensions of inverse distance and as usual $i=\sqrt{-1}$. Make sure to visualize the complex wave function as well as the probability density. Try playing with the value of $k$ to see how it affects $\psi(x)$ and $P(x)$.

Crazy fun
Try using the following wave function: \begin{align} \psi_B(x) &= \frac{\left(1-e^{(1-10i)x/L}\right)\left(e^{(1+7i)(x-L)/L}-1\right)}{2.1335722875015692\sqrt{L}} \end{align} If you can sketch in advance what this wave function function looks like (or its corresponding probability density), I will be very surprised. I could not do that.

Keywords
probability density particle in a box wave function quantum mechanics
Learning Outcomes