Winter 2017
Office hours
 David Roundy: TTh 1:00, 401B Weniger (or 412 Weniger)
A 2x2 matrix
Consider the following matrix

Pick any vector
$v$ , and plot$v$ as well as$Mv$ and$M^2v$ . Keep plotting until you find a pattern. 
Repeat the plotting process above, but with a different starting vector. What difference does it make?

Try doing your plots again, but this time normalize each vector before plotting.

Construct a second vector which is orthogonal to the interesting vector you have already found. What happens when you mulitply
$M$ by this vector? 
Now try the same process with the following matrix.
$$ \begin{align} M &= \left[ \begin{array}{rr} 1.5895 & 1.3917 \\ 1.3917 & 3.1965 \end{array} \right] \end{align} $$ How does this matrix differ from the first? Can you cause it to behave more like the first matrix?
 Extra fun
 Construct a matrix of your own that will (when repeatedly
multiplied) take any vector and output a vector in the
$\cos(.2)\hat{x}  \sin(.2)\hat{y}$ direction.
A big Hermitian matrix
Suppose we have a Hamiltonian matrix, which is a moderately large square matrix (anywhere between 10x10 and 100x100 will be fine). This matrix is all zero except that it has a value of 1 on the diagonal, and 0.1 on either side of the diagonal.

Write code to construct this matrix.

Write code to generate a random vector of an appropriate size and normalize it.

Create a plot to visualize your random vector.

Solve for the eigenvector corresponding to the largest eigenvalue (in magnitude). You can do this by mulitplying repeatedly by the Hamiltonian and normalizing, just like we did last week with a smaller matrix.

Plot this eigenvector, and find the corresponding eigenvalue.
Next eigenstate

Create a new random vector, and orthogonalize this vector to the eigenvector you have already found

Normalize your new random orthogonal vector. Plot it and compare with the eigenstate.

Solve for second eigenvector using the fact that different eigenvectors are always orthogonal.
 Extra fun
 Get more eigenstates. The fun never ends! (Actually, technically it
ends after you find eigenvector
$N$ ...)
Energy eigenvalue equation
Today we will solve for the eigenstates of a particle confined to a onedimensional box with an arbitrary potential within the box. To do this, we will solve the energy eigenvalue equation:
There are an infinite number of solutions (infinite fun!!!), so we'll
need to take some care to specify which solution we're looking for.
The conventional approach is to define
I should note here that the solution to Schroedinger's eigenvalue equation may be taken to be real for any bound state, provided there are no magnetic fields involved.
Shooting
If we already knew the energy
We can now take this equation, and if we know
The first of these is easy: the wave function must go to zero at the
boundaries of the box. The second one is slightly more subtle, but
turns out to be just as easy: we can pick any nonzero value for the
value of
So we can write the second derivative in Schroedinger's eigenvalue
equation as a finite difference, and solve for

Write a function that does this, storing
$\psi(x)$ as an array representing its value at points separated by$\Delta x$ . 
Plot
$\psi(x)$ for$V(x)=0$ and some energy (just pick something). 
Try to find an eigenvalue of the Hamiltonian by tweaking the energy.

Now plot
$\psi(x)$ for some interesting potential and a few different energies. Tweak the energy until it is an eigenvalue of the Hamiltonian. 
Visualize the energy as well as the potential
$V(x)$ . 
Solve for several eigenvalues, and visualize both the eigenvalues and the wave functions.
Aiming
When you first looked at the solution for
So while you've solved the differential equation, you hadn't yet
solved the eigenvalue equation. Eigenvalue equations are funny that
way. Fortunately, given the above function, it isn't too hard to find
the eigenvalue. Before you program anything, spend a little time
running your function for different energies and try to find a few
eigenvalues of the energy. You can distinguish eigenstates according
to the number

Pick a new potential
$V(x)$ . 
Look for eigenstates corresponding to
$n = 3$ ,$n=4$ , and$n = 5$ 
Once you've gotten the hang of finding eigenenergies by hand, write a function that solves for a particular specified eigenvalue and eigenfunction.
 Hint
 You will likely want to write a function to change the energy based on the wave function at the edge of the box. Instead you should change the energy based on the number of nodes, keeping in mind that the energy is never correct and the number of nodes will tell you if it is too high or too low.
Systems with barriers
Try creating a potential within your box such that there are multiple wells.
Simple harmonic oscillator
Try creating a simple harmonic oscillator potential within your box, and see what the energy eigenvalues are. Try finding a very high energy state (many nodes), and see where such a particle is likely to be found. Is it more likely to be found in a state with low potential energy, or high potential energy? Why? How does this relate to the classical limit, which we expect to show up at large quantum numbers, according to the Correspondence Principle?
Waves on a string
We will be modeling waves on a string under tension, as in a
guitar. This system is accurately described by the nondispersive
onedimensional wave equation.
We will solve this partial differential equation using a
finitedifference approach, in which we treat both time and space in
terms of finite differences
This is a formula which you can implement. Note that in order to
solve for the future value of
Normal modes

Write code to solve for the motion of a string, given its initial position at two subsquent time steps.

Try to find a normal mode of the system (which has a repeating pattern). What is the period (and frequency) of this normal mode?

Create a static visualization of the timedependent data you are animating. (There are several effective ways to do this!)
Creating animations
Once you've written the above algorithm, you'll want to see what is going on. To do so, write code to animate the string's motion. You could google for matplotlib animation, but to save you some time (and because the documentation that is out there is a bit hard to understand), you can use the following example:
import matplotlib.pyplot as plt
import numpy as np
plt.ion() # this turns on interactionneeded for animation
x = np.arange(0,7,0.5) # xarray
omega = 2 # radian/second
k = 1 # radian/meter
for t in np.arange(0,2*np.pi/omega,0.1): # run for one period
plt.cla() # erase the existing plot to start over
plt.plot(x, np.sin(k*xomega*t), 'o') # plot the data
plt.xlabel('x') # label the axes
plt.ylabel('$\psi(x)$')
plt.draw() # redraw the canvas
Creating a wave packet
So far we have been working with normal modes. They are nice, but sometimes are less than helpful, if we want to understand how pulses propogate. Even looking at reflection and transmission, while possible using plane waves, can be inconvenient.
Travelling waves can also lead to interesting insights. Travelling
waves are solutions of the wave equation that have the form:
For this task you will implement initial conditions for a "wave
packet", which is a travelling wave that is localized in space,
i.e. it

Try to implement the initial conditions for such a wave packet, and watch it move using your code that solves the wave equation. This sort of a system is called a wave packet. Note that your wave packet should start somewhere in the center of your string, not right next to the wall.

As before, create a static visualization of your wave packet. Note that to be effective your static visualization should use time was one of its two axes, so that you can clearly see the packet moving over time.
Reflection and transmission
Now imagine that you wrap wire around a portion of the string (think
guitar string), increasing its mass density
 Extra fun
 Adjust your code to handle this case where part of the string is heavier than the rest. See how your wave packet behaves when it hits this region. You should see both transmission and reflection, and should be able to see (especially in your static visualization) that the speed is different in that region.
Numerical stability
An algorithm is numerically unstable if small errors grow
exponentially. In the particular case of our finite difference
integration of the wave equation, our numerical stability is
determined by the relationship between the resolution in space and
time,
In this case, it is useful to ask how quickly the
Consider the case where
Balls attached by springs (under tension)
We will next study a set of balls attached by springs under tension. This is similar to the waves you have been working on, but differs in that the discrete masses are no longer an approximation.
We will consider transverse oscillations, in which the balls move in
the
You will want to experiment with different sinewave initial
conditions, with different wavelengths, and try to find a relationship
between wavelength and the frequency of oscillation. It will be most
helpful to plot the frequency versus the wave vector given by

Please implement this algorithm, to model a system of a number of balls attached by springs under tension. This should be a small change from the waves code you have worked on.

Write code to initialize the balls in any normal mode, recognizing that the normal modes are sinusoidal.

Find the frequency of a normal mode.

Plot the frequency as a function of
$k$ . This is called the dispersion relation. 
Seek an analytic function for the dispersion relation. Test it by plotting it versus your computed relationship.
 extra fun
 Construct a wave packet out of your set of balls. You may need to
increase
$N$ for this to be convenient. Try making a narrow wave packet. You may want to try creating a gaussian wave packet such as$$ y(x,t) = \sin(kx\omega t)e^{\frac{(xvtx_0)^2}{2\sigma^2}} $$ where you will want to play with the$k$ ,$\omega$ ,$v$ and$\sigma$ parameters to make this work.