## Activity: Sinusoidal basis set

Computational Physics Lab II 2023 (2 years)
Students compute inner products to expand a wave function in a sinusoidal basis set. This activity introduces the inner product for wave functions, and the idea of approximating a wave function using a finite set of basis functions.

### Essential goals for this week

1. The coefficients $C_n$ are a representation of a quantum state.
2. An expansion in a basis can be approximated by summing over only a few basis states, with the approximation getting better as we sum over more.

### Learning goals for this week

1. For wave functions, the inner product is an integral.
2. The coefficients in an expansion in a basis are inner products $C_n = \langle n|\psi\rangle$.
3. An expansion in a basis requires summing over all possible basis states ($n=1\rightarrow \infty$ in our case).

### Possibly delayed goals, which depend on $\psi(x)$

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.

## Basis sets and basis functions

A basis set is a choice of orthonormal vectors to use as a representation. The basis set you're probably most familiar with is the cartesian basis in three dimensions, consisting of $\hat x$, $\hat y$, and $\hat z$. The basis allows us, for instance, to represent states as a column vector: \begin{align} \vec v &= v_x \hat x + v_y \hat y + v_z \hat z \\ &\,\dot= \begin{pmatrix}v_x\\v_y\\v_z\end{pmatrix} &\text{where }v_x &= \hat x\cdot \vec v\text{ etc.} \end{align} We can express same concept in bra-ket notation a bit more generally \begin{align} |v\rangle &= \sum_n v_n|n\rangle &\text{where }v_n &= \langle n | v\rangle\text{ etc.} \end{align} where the sum runs over all possible basis vectors.

In the same way that we express a vector as a linear combination of basis vectors, we can use a linear combination of basis functions to describe the state of a particle in space. When we use Dirac notation, the math in fact looks identical to what you will be doing with spins: \begin{align} |\psi\rangle &= \sum_n C_n |n\rangle & C_n &= \langle n|\psi\rangle \end{align} where $\left|{n}\right\rangle$ represents a basis state. To compute these expansion coefficients, you will need to know how to compute the inner product between wavefunctions.

## Inner product

The inner product between wave functions in one dimension is given by \begin{align} \langle \phi|\psi\rangle &= \int \phi(x)^*\psi(x) dx \end{align} where $\phi(x)$ is the wavefunction representation of $\left|{\phi}\right\rangle$, and $\psi(x)$ is the wavefunction representation of $\left|{\psi}\right\rangle$. The integral goes over the domain of the problem (in our case from $0\rightarrow L$). This inner product is similar to the inner product you are accustomed to in spin systems, with the summation turned into an integration due to the fact that there are an infinite number of positions possible.

## Our basis set

The basis set we will use is a sinusoidal basis set, defined by \begin{align} |n\rangle \,\,\dot=\,\, \phi_n(x) = \sqrt{\frac{2}{L}}\sin(n\pi x/L) \end{align} where $n$ is a positive integer. Note that when we use “integer-sounding” variables in a ket (like $\left|{n}\right\rangle$ or $\left|{m}\right\rangle$), we mean basis states, and their wavefunction representation is denoted by $\phi_n(x)$ or $\phi_m(x)$.

Over time you'll get to discover some fun and interesting properties of this basis, and you'll also be using it a lot for classical physics in Oscillations and Waves next quarter.

## Expansion in a basis

One way that we frequently represent states in quantum mechanics is as a sum of basis states. This hearkens back to classical mechanics (and Static Fields) where you learned to write a vector in terms of basis vectors \begin{align} \vec r &= x\hat x + y \hat y + z\hat z \end{align} where you may recall that $x = \vec r\cdot\hat x$, etc. In bra-ket language, we can write this relationship as \begin{align} |\psi\rangle &= \langle 1|\psi\rangle\, |1\rangle + \langle 2|\psi\rangle\, |2\rangle + \langle 3|\psi\rangle\, |3\rangle + \cdots \\ &= \sum_{n=1}^{\infty} \langle n|\psi\rangle\, |n\rangle \\ &= \sum_{n=1}^{\infty} C_n |n\rangle \end{align} Now this infinite sum doesn't look so convenient. Fortunately, we can approximate the sum by summing over a finite number of basis functions, and check that we are approaching the limit by seeing how our result changes when we increase the number of terms retained in the sum.

You will be given one of the following wave functions: \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) &= \frac{\left(e^{x/L}-1\right)\left(e^{(x-L)/L}-1\right)}{0.1937570896322709\sqrt{L}} \\ \psi_5(x) &= \frac{\sqrt{495}}{L^5\sqrt{L}}x(x-L)^4 \end{align}

1. Write a python function that returns $\psi(x)$ for your given wavefunction.
2. Plot $\psi(x)$ as well as a few of the sinusoidal basis functions.
I want students to learn to plot things "automatically" as part of checking whether their code is even working, but for now I still ask them to do so, since I expect that with this being quantum mechanics they might have more trouble activating their usual sense-making skills.
3. Write another python function that given $n$ returns $C_n = \langle n|\psi\rangle$.
4. Compute the first eight $C_n$ as well as $|C_n|^2$. What patterns do you see in their values, if any? Can you explain them based on the properties of your wavefunction? Raise your hand or ask for help!
We have commonly seen students making $x$ an input to their function to compute $C_n$. They aren't yet clear on what an inner product is, and it can help to remind them of the definition of the inner product.
5. Compute and plot the following approximation for your wavefunction: \begin{align} \psi_{\text{approx}}(x) &= \sum_{n=1}^{4} C_n\phi_n(x) \end{align} On the same plot show $\psi(x)$. How well do the two curves agree? How does the agreement change if you change the number of terms in the sum?
Extra fun
Repeat the above with one of the other wavefunctions.
Crazy fun
Try expanding one or more of the following functions in our sinusoidal basis: \begin{align} \psi_A(x) &= \sqrt{\frac{3}{L}}\left(1-\left|\frac{2x}{L}-1\right|\right) \\ \psi_B(x) &= \frac{4\sqrt{3}}{L^2\sqrt{L}}x(L-x)\left(1 - \frac{\Theta(x/L-\tfrac12)}{2}\right) \end{align} where $\Theta$ is the Heaviside step function. How does the number of coefficients you need to include in order to get a good match to the wave function differ for these less smooth functions?

There is commented out here another version of this activity that we tried after students attempted the above.

Davide Lazzati in Winter 2023 added the following to keep advanced groups busy while working with those still learning the main part of the activity

Challenging Fun
The process you worked on, decomposing an arbiraty function that has value 0 at the extremes has important implications for music. The vibration of a string is made by the superposition of the vibration of "modes", i.e., the elements of the sinusoidal basis that you have used. Each mode has a set vibration frequency, and the temporal evolution of the string position is given by (I simplified things a bit here, ask me if you want to know how and why): \begin{equation} \psi(x,t)=\sum_{n=1}^\infty C_n |n\rangle \cos(\omega_n t) \end{equation} where $\omega_n \propto n$. Your task is to produce an animation of the moving string. I suggest, as a starting point: $L=2$, $\psi(x,0)=\psi_3$, $\omega_n=n$, $\Delta t=0.01$.
A guide on how to animate in jupyter can be found at (e.g.)
https://towardsdatascience.com/matplotlib-animations-in-jupyter-notebook-4422e4f0e389

• keyboard Position operator

keyboard Computational Activity

120 min.

##### 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.
• face Compare \& Contrast Kets \& Wavefunctions

face Lecture

30 min.

##### Compare & Contrast Kets & Wavefunctions

Completeness Relations

In this lecture, the instructor guides a discussion about translating between bra-ket notation and wavefunction notation for quantum systems.
• assignment Completeness Relation Change of Basis

assignment Homework

##### Completeness Relation Change of Basis
change of basis spin half completeness relation dirac notation

Completeness Relations

Quantum Fundamentals 2023 (3 years)
1. Given the polar basis kets written as a superposition of Cartesian kets \begin{eqnarray*} \left|{\hat{s}}\right\rangle &=& \cos\phi \left|{\hat{x}}\right\rangle + \sin\phi \left|{\hat{y}}\right\rangle \\ \left|{\hat{\phi}}\right\rangle &=& -\sin\phi \left|{\hat{x}}\right\rangle + \cos\phi \left|{\hat{y}}\right\rangle \end{eqnarray*}

Find the following quantities: $\left\langle {\hat{x}}\middle|{\hat{s}}\right\rangle ,\quad \left\langle {\hat{y}}\middle|{{\hat{s}}}\right\rangle ,\quad \left\langle {\hat{x}}\middle|{\hat{\phi}}\right\rangle ,\quad \left\langle {\hat{y}}\middle|{\hat{\phi}}\right\rangle$

2. Given a vector written in the polar basis $\left|{\vec{v}}\right\rangle = a\left|{\hat{s}}\right\rangle + b\left|{\hat{\phi}}\right\rangle$ where $a$ and $b$ are known. Find coefficients $c$ and $d$ such that $\left|{\vec{v}}\right\rangle = c\left|{\hat{x}}\right\rangle + d\left|{\hat{y}}\right\rangle$ Do this by using the completeness relation: $\left|{\hat{x}}\right\rangle \left\langle {\hat{x}}\right| + \left|{\hat{y}}\right\rangle \left\langle {\hat{y}}\right| = 1$
3. Using a completeness relation, change the basis of the spin-1/2 state $\left|{\Psi}\right\rangle = g\left|{+}\right\rangle + h\left|{-}\right\rangle$ into the $S_y$ basis. In otherwords, find $j$ and $k$ such that $\left|{\Psi}\right\rangle = j\left|{+}\right\rangle _y + k\left|{-}\right\rangle _y$
• accessibility_new Spin 1/2 with Arms

accessibility_new Kinesthetic

10 min.

##### Spin 1/2 with Arms
Quantum Fundamentals 2023 (2 years)

Arms Sequence for Complex Numbers and Quantum States

Students, working in pairs, use their left arms to represent each component in a two-state quantum spin 1/2 system. Reinforces the idea that quantum states are complex valued vectors. Students make connections between Dirac, matrix, and Arms representation.
• 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 Calculating Coefficients for a Power Series

group Small Group Activity

30 min.

##### Calculating Coefficients for a Power Series
Theoretical Mechanics (8 years)

Power Series Sequence (E&M)

This activity starts with a brief lecture introduction to power series and a short derivation of the formula for calculating the power series coefficients.

$c_n={1\over n!}\, f^{(n)}(z_0)$

Students use this formula to compute the power series coefficients for a $\sin\theta$ (around both the origin and (if time allows) $\frac{\pi}{6}$). The meaning of these coefficients and the convergence behavior for each approximation is discussed in the whole-class wrap-up and in the follow-up activity: Visualization of Power Series Approximations.

• assignment Matrix Elements and Completeness Relations

assignment Homework

##### Matrix Elements and Completeness Relations

Completeness Relations

Quantum Fundamentals 2023 (3 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.)

• face Time Evolution Refresher (Mini-Lecture)

face Lecture

30 min.

##### Time Evolution Refresher (Mini-Lecture)
Central Forces 2023 (3 years)

Quantum Ring Sequence

The instructor gives a brief lecture about time dependence of energy eigenstates (e.g. McIntyre, 3.1). Notes for the students are attached.
• accessibility_new Curvilinear Basis Vectors

accessibility_new Kinesthetic

10 min.

##### Curvilinear Basis Vectors
Static Fields 2023 (10 years)

Curvilinear Coordinate Sequence

Students use their arms to depict (sequentially) the different cylindrical and spherical basis vectors at the location of their shoulder (seen in relation to a specified origin of coordinates: either a set of axes hung from the ceiling of the room or perhaps a piece of furniture or a particular corner of the room).
• group Going from Spin States to Wavefunctions

group Small Group Activity

60 min.

##### Going from Spin States to Wavefunctions
Quantum Fundamentals 2023 (2 years)

Arms Sequence for Complex Numbers and Quantum States

Completeness Relations

Students review using the Arms representation to represent states for discrete quantum systems and connecting the Arms representation to histogram and matrix representation. The student then extend the Arms representation to begin exploring the continuous position basis.

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