Author: Jack Ord
301-4 Willow Street
Waterloo, ON, Canada, N2J 4S2
Host: Information Gateway Services
Jack's Page was launched in 1995 when the Internet and Java were both young, and all computers were able and willing to run Java Applets. Its aim was to introduce simple numerical methods for dealing with problems in physics. Its target audience was high-school seniors and university undergraduates with an interest in writing their own programs, but it was hoped that a wider audience might enjoy running the Applets. There have been many changes to Java and web browsers since Jack's Page was introduced, and although some have been good, others have not. I decided to retire Jack's Page in the Spring of 2015 at the end of its 20-year run. At that time it consisted of 90 Applets with source code and corresponding programs written in BASIC. Jack's Mini-Page acts as its epitaph. It assumes that most viewers cannot run Applets (and so has only three) and relies more on screen images. Equations appear in the Java source code (identified by comments) in a form that can be understood by a machine that can only do basic arithmetic (in addition to evaluating sines and cosines).
The three Applets take us from Newton's Law through to the Schrodinger Equation with help along the way from Richard Feynman. We begin with a mass oscillating on a spring and move on to beads oscillating on a clamped string. From there we jump to the Schrodinger Equation and the quantum version of a clamped string, the infinite square well. We close with the quantum harmonic oscillator, the quantum version of the mass on a spring we started with.
Newton's Law and the Feynman Algorithm
In his 1963 Preface to The Feynman Lectures on Physics Richard Feynman expressed pessimism about the effect the lectures had on freshman and sophomore students at Caltech. I cannot speak to that, but I can attest to the tremendous impact the publication of The Feynman Lectures had on young assistant professors starting their careers at the time. Feynman took a digital approach to analyzing what Newton's Law means for a mass attached to a spring. He suggested making a table with the inital values of the time, position, and velocity in the first row. Newton's law enables us to calculate the initial acceleration and put it in a fourth column. The definitions of velocity and acceleration then enable us to fill in values for the position and velocity a short time later, and this process can be continued to generate a table of the position of the mass as a function of time. Anyone using a 1960-era calculator (as Feynman was) to generate the table rapidly concludes that the time interval should be reasonably large, and looks for a way to get the best accuracy possible with that size of interval. Feynman's method uses the initial velocity and acceleration to calculate the velocity a half-step forward in time. Each time through the loop this minor change enables average velocity to be used when calculating the change in position, and average acceleration to be used when calculating the change in velocity. The resulting increase in the accuracy of the calculation is as useful with modern computers as with older calculators. A simple BASIC program illustrates this clearly. The program finds where and when a mass attached to a compressed spring will first come to rest after it is released.
A program written in BASIC reads very much like ordinary English except for the meaning of the equals sign. For example, "t=t+dt" takes the current values of the symbols on the right, adds them together, and assigns the result to the symbol on the left. Comments appear in green, and the keywords in yellow have their usual English meanings. The WHILE loop continues until the mass changes direction. At that point we expect the displacement to be +1, and, with the values assigned to the constants, the time to be pi (3.14159 is the number I carry around in my head for pi). There are two corrections made to the time. The first takes account of fact that the velocity is a half-step ahead, and the second takes account of the fact that the velocity crossed zero somewhere in the middle of the previous time interval (No mid-interval correction is needed for the displacement because the velocity is passing through zero). The accuracy that can be obtained with a time iterval of 0.01 is truly remarkable
The Classical String
Feynman went on from the motion of a mass on a spring to the motion of a planet about the sun, but since we are trying to get to a wave equation, we will turn to the motion of beads spaced evenly along a clamped string. We will restrict our attention to small transverse vibrations, and by small I mean small enough that the sine of the angle the string makes with the horizontal can be replaced by its tangent. Once that aproximation is made, we can use any convenient scale to display the transverse motion.
At this point what you see on the screen immediately above depends on whether or not your browser is able and willing to run Java Applets. If it is, you will see largely empty box with three buttons, a way of choosing the number of beads, and a checkbox with FFSS beside it. If it is able but unwilling, the box will have a nasty security message of some kind in it. If no box appears above (the most likely case), your browser is unable to run Java Applets, and the five screen images below are here for your benefit. The buttons that appear on the screen images are just pictures. The buttons on the Applet run the Java program using the options you have chosen and display the motion at a rate that is easy to follow.
The motion begins with the beads on the central quarter of the string given a displacement that traces out a pulse of the form (1-cos(theta))/2 as theta goes from 0 to 360 degrees. The image above was produced by selecting n=32 line segments (from choices ranging from 16 to 256) and clicking on "Pulse S" (Pulse S starts all the beads from rest). There will be no net force on a bead unless the slope of the string changes at that point. It is curvature that produces acceleration: this is the classical wave equation expressed in words rather than in terms of second derivatives. It is a straightforward matter to set up a Feynman algorithm to plot the motion of the (n-1) oscillating beads. The image below shows the position of the beads after 96 of 768 frames.
The initially stationary pulse has broken into two pulses moving in opposite directions. This is not surprising because the central bead initially has a strong downward acceleration, and the pattern has no choice but to remain symmetrical. As time goes on the two pulses invert and reverse direction on reflection from the clamped ends. We get a clearer picture of the motion if we change the initial conditions to generate a single pulse moving to the right. For that to happen the beads on the right side of the pulse (where the slope of the string is negative) must start with an upward velocity, and those on the left must have a negative velocity. Since the pulse was defined in terms of a trig function, we can generate appropriate initial velocities by differentiating it and changing the sign. This is what was done to generate Pulse T. The screen image below shows what happens when "Pulse T" it is chosen and the motion continues for the full 768 frames:
After two reflections the pulse is moving to the right across the screen for the second time. It now has progressively smaller and narrower satellite pulses trailing it. This is a good point to say something about the "FFSS" Checkbox. It introduces the idea of normal modes and completely changes the way the calculation is done. Newton's law is used to find the frequencies of the normal modes, but there is no step-by-step use of the Feynman Algorithm. FFSS stands for Finite Fourier Sine Series, a special case of the Finite Fourier Transform applicable to systems with zero boundary conditions such as our clamped string. It states that the displacements of our (n-1) beads can be represented exactly by the sum of sinusoidal displacements with from 1 to (n-1) loops between the fixed ends of the string. It also tells us how to calculate the amplitudes of the displacements appearing in the sum. All we have to do is use Newton's law to demonstrate that the (n-1) sinusoids are normal modes and find their frequencies. That involves some trigonometry ("the sum of sines is twice the sine of half the sum times the cosine of half the difference"). I do not show equations here, but everything appears in the Java source code in a form simple enough for the computer to understand. The results can be summarized neatly on a plot of the dispersion relation. The screen image below is for Pulse S with n=16 and "FFSS" checked.
The beads trace out a symmetric pattern (as expected) with a broad central maximum and wings on each side. Exactly the same pattern would be produced after 768 frames without FFSS being checked. What is new is the dispersion plot in the lower right corner. The horizontal axis runs from 0 to 16 and shows the mode number. Two things are shown vertically: the square of the FFSS coefficient as a red bar, and the frequency as a blue sine curve. Only modes with odd numbers of loops will contribute to a symmetric pattern. Contributions from modes 1, 3, 5, 7, 9, and 11 get progressively smaller, and contributions from modes 13 and 15 do not register on the plotting scale. The blue curve comes from Newton's law and contains the physics of the motion. Wave velocity is the product of frequency and wavelength, and wavelength is inversely proportional to mode number, so the downward curvature of the blue curve means that wave velocity decreases as frequency increases. This provides an explanation for why shorter wavelength pulses trail the main pulse in the previous screen image.We will explore this further in the next screen image. If we choose "Pulse T" we need a second FFSS fitted to the initial velocities, and this series will only have contributions from even numbered modes because the initial velocities are anti-symmetric about the centre of the pulse. This will fill in the "gaps" in the dispersion plot as the screen image below demonstrates.
"Pulse T" was chosen with n=64 and "FFSS" checked. After 768 frames the pulse is moving across the screen to the right. The dispersion relation uses the same 0 to 16 mode scale as in the image above, and the mode distribution is essentially the same with the gaps filled in. Although there are now 63 normal modes, none of the ones with shorter wavelength are needed to fit our pulse. The big difference is in the blue curve. It appears to be a straight line, but it is actually the first 22.5 degrees of a sine curve, and has downward curvarure. If you can run the Applet with n=128 and 256, you can watch as the beads tend toward a continuous string. This completes our work on the Classical String, but one final point needs to be made. The Applet is designed to show the motion of wave pulses. If we simply wished to see the positions of the beads after a specified time, we could put that time into the FFSS - there would be no need to go through the steps involved with the Feynman Algorithm. Now it is time to move on to the Quantum String.
The Quantum String
The one-dimensional infinite square well is the quantum equivalent of a classical string clamped at both ends. The well is a region in which potential energy is zero, and infinite energy is needed to penetrate the well boundaries. Such barriers are not really consistent with quantum mechanics, but the infinite well is convenient for introducing the Schrodinger equation. The wavefunction (or probability amplitude) in quantum mechanics takes the place of transverse displacement in a classical string. Just as the curvature of the string drives the motion of a classical wave, so the curvature of the wavefunction drives a quantum wave. In Newton's law, curvature enters as a force that produces acceleration, a second time derivative. In the Schrodinger equation curvature enters as kinetic energy and changes the wavefunction through a first time derivative. This means we cannot use the Feynman algorithm, but we can use a similar half-step look ahead procedure. The most surprising feature of the equation is the presence of i, the square root of -1, multiplying the time derivative. This gives the wave function real and imaginary parts, and the curvature of one drives changes in the other. If we take the pulse from the classical string as an initial real wavefunction, it rapidly becomes complex but remains symmetric and produces a standing wave pattern. To get the pulse to start moving to the right, we multiply the real pulse by a complex exponential with a phase change of two pi across the width of the pulse. (The Applet allows this phase change to be multiplied by four).
The Schrodinger equation also involves unfamiliar parameters such as Planck's constant and the mass of the quantum particle. When we studied the motion of a mass on a spring we simply put in numbers for m and k, but we would have done better to note that their ratio has the dimensions of time squared, and introduced a time constant to act as a unit for dimensionless time. In the case of the Schrodinger equation, the time constant that cleans up the equation for numerical solution is the period of oscillation of the ground state, the lowest energy stationary state (quantum normal mode). The FFSS gives the stationary states of the infinite square well, and when substituted into the Schrodinger equation gives the dispersion relation. "Finite" here only means the functions are defined digitally, and a limited number of terms are needed to fit the pulse.
We are now equipped to run the Applet, and if you cannot do that there are five screen images to give you an idea of what you would see if you could. You have three choices to make before you start. The first concerns the type of solution you want (direct numeric or series). Next you choose what you want to see, the real and imaginary parts of the wavefunction separately or he sum of their squares (the probability density). Finally you choose whether or not you wish to increase the initial phase change. Then you click on "Pulse" and see what you get. Finally you click on "Motion".
The screen image above shows the initial probability density pulse. The same image appears when "Series" is checked, and the only change when "nk=4" is checked is to the energy printed in the upper right corner. The pulse is initially moving to the right.
The second image shows what happens to the probability density when "Motion" is clicked and the Applet is allowed to run for 320 frames (1/8 of the ground-state period). I like to watch this motion with "YrYi" checked, realizing that between each frame 3000 curvature calculations at 384 points on each curve generate the time-dependence of the other curve. I find it truly remarkable that the plot in the final frame agrees well with the plot that can be obtained in a single step with a 60-term FFSS.
The third image shows what happens when both "Series" and "nk=4" are checked and the Applet runs for 320 frames (1/128 of the ground-state period when "nk=4" is checked). Checking "Series" does not change the probability density plot significantly, but it does add a plot of the dispersion relation in the upper right corner. The pulse has reflected from the right boundary and is moving to the left. It has spread considerably, but at this point it is still recognizable as a pulse. The dispersion relation is a parabola, and the mode distribution has a peak about half-way along the 0 to 60 scale. The remaining two images also have "nk=4" checked but not "Series" (to avoid repeating the dispersion plot). They both have "YrYi" checked and compare initial (moving right) and final (moving left) views of the pulse. The shorter wavelength oscillations on the leading edge have clearly travelled farther and faster than the longer wavelength ones on the trailing edge.
The Quantum Oscillator
We now come back to the harmonic oscillator, but this time in its quantum form. In order to keep our feet firmly on the ground, we include a Feynman algorithm plot of a mass oscillating on a spring along with the quantum plot. (The Feynman algorithm also reappears with different variables when we find the stationary states of the quantum oscillator and say good-bye to the FFSS). The Schrodinger equation picks up a potential energy term in addition to the familiar kinetic energy (curvature) term we used above. This does not cause a serious problem, but we now have to deal with boundary conditions that extend to infinity. For the direct solution we simply put everything at the middle of an infinite square well that is wide enough to avoid reflections coming back to the centre. For the series solution we need to find states which tend smoothly to zero when they enter a region where their curvature is away from the axis (i.e. the kinetic energy is negative). As the source code shows in the "states()" routine, it is relatively easy to set up a trial and error procedure for doing this. Our familiar pulse is started out moving to the right at the centre of the harmonic potential well. The width of the pulse is made equal to the distance between the ground-state turning points (48 pixels on the scale used in the plot). The Applet appears directly below (for those who can run Java Applets) followed by the first screen image.
The first image shows the initial probability density pulse superimposed on a potential energy plot in the upper portion, and the classical mass on a spring in the lower portion. Both are initially moving to the right. The ground-state and pulse energies are shown on the plot, and the intersections with the potential energy curve give their respective turning points. The pulse energy calculated using the Schrodinger equation is about 13.2 times the ground-state energy.
The second image shows the screen after a full 320 frames when "Series" is checked. The pulse and the mass are both moving to the right and have returned to their initial positions. The display in the lower right corner shows the contributions from the first 30 modes in the series. "S40" shows that 99.9 % accuracy can be achieved with a 40-term series. The mode frequency is seen to be proportional to mode number, and from the series viewpoint this accounts for the lack of dispersion. The pulse energy calculated from the series is also about 13.2 times the ground-state energy. If you like calculus you can try showing that an analytic calculation gives 13.240.
The third image shows the screen after 40 frames when "YrYi" is checked. This is 1/8 of the way through the cycle, and motion is to the right.
The fourth image shows the screen after 80 frames with both the probability density and the mass at rest at the turning point. It is clear from the plot that the probability of finding the quantum particle beyond the classical turning point, although less than 50 %, is quite substantial. This is one aspect of quantum behaviour that could not be seen in the infinite well.
The Java Applet had to be modified to enable the final screen image to be produced. Although the "states()" routine in the source code details how stationary-state energies and normalized wavefunctions can be calculated, there was no image showing what they look like. I decided to fit one in at the beginning when "Series" and "YrYi" are both checked. The image shows the first 5 stationary states plotted in green underneath the usual starting screen and holds the display for 5 seconds. Even if you can run the Java Applet, it is better to view the result on the screen image above. Modes 1, 3, and 5 have a peak at the centre, whereas modes 2 and 4 pass through zero there. For each, the turning points are where the curvature changes from toward the axis to away from it.
The final Applet brings Jack's Mini-Page to a close. It uses the Feynman Algorithm in both its classical form for a mass on a spring and its quantum form for finding stationary states. Although a different algorithm generates the time dependence in the Schrodinger Equation, it uses a similar half-step procedure.
Jack's Mini-Page is not a substitute for Jack's Page, but I consider it a suitable epitaph.