Visualizing the single-spin experiments from Leonard Susskind’s Quantum Mechanics course

Pankaj Bhambhani
9 min readJun 26, 2023
Preview of a visualization that you’ll see in this post

I am a huge advocate of adult learning, and I like to keep myself abreast with different things I find interesting. Science has been a key part of that. A while back I came across The Theoretical Minimum, which is a series of courses taught by Professor Leonard Susskind at Stanford. Lenny is a great science communicator and educator. His ability to break down difficult concepts into easy-to-understand things is something I appreciate and aspire to develop in me.

Geordi Drake meme for Lenny Kravitz vs Leonard “Lenny” Susskind

A good example of this is his course on Quantum Mechanics (QM). It is very different from what you see in undergraduate studies — there is no mention of the Hydrogen atom at all, for instance. He uses the idea of a single spin and a measurement device to illustrate how quantum mechanics is fundamentally different from classical mechanics.

The Anatomy of a Single-Spin Experiment

The experimental setup he describes involves a single spin which can be in either an “up” or a “down” state. We also have a detector — a measuring device that gives a measurement of “+1” if it detected the spin in the up state, or “-1” if it detected the spin in the down state.

In the simplest scenario, we start with the spin in the up state and we do a measurement. In this case, we will always get a measurement of +1. Similarly, if we start with the spin in the down state, we will always get a measurement of -1.

We can extend the experiment by allowing both the spin and the detector to be in different directions in space (as opposed to being only up and down), while still only having two states for simplicity (up and down for the spin, +1 and -1 for the detector). The simplest scenario of this extension is when the detector is pointed in the opposite direction to the direction of spin. In this case, we will get a measurement of -1 every time. In this sense, what the detector is measuring is whether the spin is along the direction of measurement (+1) or opposite to the direction of measurement (-1).

Both the above scenarios produce deterministic results — no matter how many times you repeat the experiment — assuming you always start with the spin in the up state (or any fixed state)— you will always get the same measurement. Things become interesting when you point the detector at an angle to the spin vector. The detector cannot measure the angle, it can only produce a +1 or a -1. When you run this experiment multiple times — again, assuming you always start with the spin in the up state— you will find that you get a +1 sometimes and a -1 at other times. Once you do a measurement though, you will find that the spin vector is now parallel to the detector — along the measurement direction if you measured +1, and opposite to the direction if you measured a -1. So any subsequent measurements you do will always give the same answer. If you reset your experimental setup and start again with the spin in the up state, you will find a random answer again.

If this setup feels contrived to you, that’s because it is. It is a simple analogy meant to emulate quantum mechanics for a single particle with two states. The spin aligning parallel to the detector after measurement is equivalent to the collapse of the wave function that you may have come across before. To be able to come up with a simple analogy to explain this complex concept is why I have a huge respect for Lenny as a science communicator.

If you can visualize it, you can truly understand it

While the experiment itself is quite simple, and he does a good job of explaining things by drawing on the board, I still found myself struggling to visualize things. In addition, I remember him mentioning at one point during the course how it would be nice if someone had the time to create a computer program for this. I looked around and found none, that motivated me to create a set of visualizations to explain the experiment. Which is what this blog post is about.

Below I show visualizations for three different versions of the experiment. They should load as interactive widgets on your browser, but if they don’t then please visit the URL given in the corresponding caption to load the visualization in a new webpage. Please note that these are designed to be viewed on a desktop. I am not a UI expert and didn’t have the time to make things mobile-friendly. Also, although these visualizations are reasonably tested, they may still have bugs. If you have the time to improve these, please file an issue or submit a pull request to this repository on GitHub.

Experiment #1

In each of the three experiments, we start with the spin in the up state, more specifically along the +Z direction in a cartesian coordinate system. The first experiment allows you to orient the detector in any direction and do a measurement. For simplicity, both the spin and the measurement vectors are assumed to be unit vectors. I find that an intuitive way to specify a direction in 3 dimensions is to provide two angles — for instance, one from X-axis towards Y-axis and another from Y-axis towards Z-axis. The interface allows you to specify these two angles in degrees. To set a measurement direction, use the “Set Direction” button. The “Reset Direction” button allows you to set the measurement direction to its default value, which is along the +X axis in this case. When you perform a measurement using the “Do Measurement” button, you will get a +1 or a -1 result, and the spin will be respectively aligned along or opposite to the measurement direction. The “Reset Measurement” allows you to set the spin direction back to along the +Z axis.

Experiment #1 allows you to take a spin in the up state and perform a measurement in any direction. If the measurement vector is at an angle to the spin vector, you will notice that you sometimes get a +1 or -1 (assuming you press “Reset Measurement” after each turn). If you use the default measurement direction of the +X-axis, you will notice that you get a +1 about half the time and -1 the other half time. NOTE: If the above visualization does not load, you can see it at https://pcb-astro.github.io/qm/view1.html

In the above experiment, if you do multiple measurements along the same direction — assuming you press “Reset Measurement” after each turn, you will get results like I previously described. You will always get a +1 if your measurement is parallel to the spin vector (i.e. along the +Z-axis in this case), and similarly, a -1 if opposite to the spin vector (along -Z-axis in this case). If your measurement vector is along any other direction, you will sometimes get a +1 and sometimes a -1. If you use the default measurement direction of the +X-axis, you will find that you get a +1 roughly half the time and -1 roughly half the time.

Why is that the case? The way the experiment is designed, if you take the seemingly random measurements (with fixed measurement and spin directions) and compute the average, the result will be approximately the cosine of the angle between the two directions. This is the equivalent of quantum operators having randomness but their expectation values being deterministic. Quantum mechanics reduces to classical mechanics when we look at things in an average sense.

The next experiment is meant to show exactly this.

Experiment #2

This experiment looks similar to the previous one, except there is no option to do a measurement. Instead, there is an option called “Run Experiment”, which does measurements multiple times (resetting the spin after each measurement). By default, 100 measurements are done, but you can change this number in the “Number of simulations to run” input.

Experiment #2 allows you to take multiple measurements in any direction. It shows you the number of +1 and -1 measurements. It also shows you both the expected and the actual average value obtained from the experiment. The experimental value will approach the theoretical value as you increase the number of simulation steps. NOTE: If the above visualization does not load, you can see it at https://pcb-astro.github.io/qm/view2.html

When you run this experiment, you will notice a histogram that shows the number of times a +1 or -1 was measured. You also see the average, both theoretical (computed from the cosine of the angle between the spin and measurement directions) and the experimental average (literally the average of all the +1s and -1s measured). The experimental value will approach the theoretical value as you increase the number of simulation steps. A value of 100 steps usually works well, but feel free to try 1000 or 10k, or even higher.

Experiment #3

The idea of quantum mechanics reducing to classical mechanics in an average sense is true not only for a static system but also for a system changing with time. To illustrate this, Lenny puts the spin in a magnetic field. To keep things simple, the magnetic field is taken to be uniform (not changing with time) and pointing in the +z direction. Lenny also introduces the concept of “components” of the spin, which we obtain by measuring the spin along the x, y, and z axes. If we do repeated measurements, we can calculate the average along each of the three directions à la Experiment #2. We can think of these averages as components of the “average spin” vector.

The next and final experiment is to see how this average spin vector changes with time when placed in a uniform magnetic field. Unlike the other two experiments, the spin vector here is not aligned in the +z direction by default, since that would make it parallel to the magnetic field and hence there would be no change in spin. Once you set a spin direction, the “Run Evolution” button allows you to see how the (average) spin evolves with time. The time step controls the speed at which the simulation runs, smaller values mean slower speed. To simulate at a faster rate or with a different spin direction, you would need to stop the current simulation and start a new one.

Experiment #3 shows how the spin vector and its measurements behave in a time-varying system. In this case, we have a uniform magnetic field pointing in the +z-direction. The spin vector precesses around the magnetic field axis but in an average sense — if you calculate the average measurement (à la Experiment #2 but along each of the x, y, and z directions) at each instant and plot it against time, you will see that it moves in a circular orbit around the axis of the magnetic field. This is analogous to the precession of a gyroscope in classical mechanics. Also shown are the variations in the x and y components (the z-component is not shown because it is along the magnetic field direction and therefore does not change) and the radius of the precession orbit. The orbital radius changes (when measured experimentally) because we use discrete time steps; smaller time steps mean the experimental value is closer to the theoretical value. NOTE: If the above visualization does not load, you can see it at https://pcb-astro.github.io/qm/view3.html

Once you press “Run Evolution”, you see a bunch of things. A yellow circle appears at the tip of the spin vector, and a blue point-like object moves around on this circle. This blue point is representing the average value of spin at any time. The coordinates of this point are the average spin components measured along the x, y, and z directions. When measured along the z-axis, the resulting spin will always be along +z or -z direction and hence will be parallel to the magnetic field. The average z-component of the spin, therefore, does not change with time, and hence the blue point always remains at the same “z” height wrt the x-y plane. The average x and y components change with time and are shown in the left of the two plots towards the bottom of the visualization.

The second plot shows the radius of the circular orbit. Theoretically, the radius will remain the same, but in simulations like this, the radius value fluctuates because we have to use a discrete time step value that is bigger than an infinitesimal. As you use smaller and smaller time-step values, you will notice that the fluctuations will reduce. Conversely, large time step values will cause the orbit to wobble a lot more. In these simulations, I found that using a time step greater than 0.1 seconds causes the orbits to become unstable. The time step also controls the speed at which the blue point moves on the circle, with smaller values meaning slower speeds.

I want to stress again that it is the average value of the spin that moves in a circular orbit, and individual spin measurements may deviate from this. I have tried to illustrate this by keeping the average spin (the blue point) as a separate visual element from an individual spin (the blue vector).

Thus we see that when placed in a uniform magnetic field, the spin vector precesses around the magnetic field axis, but in an average sense. This is similar to how a gyroscope precesses when placed in a uniform magnetic field. The claim of quantum mechanics reducing to classical mechanics in an average sense is therefore also true in systems that change with time.

That’s it. I hope these visualizations are of help to you if you have been watching the course. Or maybe you were just passing by, in which case I hope to have ignited some curiosity in you for the day. I have made these visualizations as accurately as I can based on my understanding of what Lenny was trying to convey. If you feel there’s something not quite right, feel free to comment below.

These visualizations were made possible thanks to the Manim.js library, which in turn is based on the manim math animation python library by 3blue1brown.

The code for these visualizations is available here. Feel free to share and modify these as much as you wish. If you would like to share the changes you make, feel free to create an issue on the GitHub page. You can also use the same link to report any bugs you find or any other problems you run into.

Adios!

--

--