Visualizing wavefunctions is essential in quantum mechanics (or wave physics, in general).

For starters, let’s start with the eigenmode of the wave produced by the transverse displacement of a string of length (like that of a guitar) with fixed endpoints. The modes of these vibrations is given by , where is the maximum displacement, is the position, is the mode number, and is the mode frequency. Shown below is wavefunction for plotted as a single image for different snapshots in time.

Plotting this is straightforward since it is a real-valued function. The time evolution changes the absolute value of the wavefunction. This true in most cases in classical mechanics.

In quantum mechanics, however, we cannot get away with complex values. For eigenfunctions, like the one shown above, the time evolution doesn’t change the absolute value, it only changes the phase. This makes the plot similar above to be insufficient.

Consider the energy eigenfunctions of the quantum version system above, a particle in an infinite box with length which is given by . Here, is the normalization constant. At time , these are real-valued wavefunctions and plotting them is straightforward. However, time evolution will unavoidably make them complex-valued. Time evolution of an energy eigenfunction will not change most observables, but, once a state is a linear combination, we need to consider plotting in complex space.

A naive, at least in Quantum Mechanics, way to plot wavefunctions is to deal with the real and imaginary parts separately. This is shown below for equal superposition of the first 2 excited states at some instant in time of the form .

Plotting either of them does not give much intuition on the possible observables like position. A better way is to plot two direct observables from the wavefunction, i.e. probability density and the phase . This is shown below.

This gives us directly the probability density and the phase which are essential physical quantities, unlike the real and imaginary parts. If we let this wavefunction evolve, we will see the beauty of these oscillations in the density.

Having two curves in a single plot is not ideal. Good news is we can incorporate the phase in the density plot by using a colormap. This method was used in the book Visual Quantum Mechanics by Bernd Thaller. The trick is to map the phase to hue (or commonly called color) which is also cyclic, e.g. 0 is mapped to red, 2π/3 to green, π to cyan, 4π/3 to blue, and so on. We then use it color the fill under the probability density curve as shown below for the same wavefunction.

To do this plot in Python, I first created the colored image, i.e. plot (imshow) an image (2D array) which has intensity values equal to the phase of the wavefunction using the ‘hsv’ colormap. The second step is to plot a filled function (fill_between) with a white background to cover the upper part of the curve.

There you have it. A plot of a complex-valued wavefunction which shows both the probability density and phase. This can be also extended to 2D wavefunctions. Have fun!

## 1 thought on “Visualizing 1D complex-valued wavefunctions”