Computer Science Across the Curriculum

8. Waves and Quantum Mechanics

Wave phenomena are of tremendous importance in the physical world. Most familiar, perhaps, are waves in water, particularly obvious at the seaside. Sound consists of waves in the air, repeated patterns of compression and rarefaction (i.e. high and low pressure) as the air molecules oscillate backwards and forwards, transferring the wave’s energy from the sound source outwards. If you fix a rope at one end, then shaking the other end will produce a wave as the oscillations up and down move along the rope’s length. Light consists of electromagnetic waves, and in fact our most fundamental theory of matter – quantum mechanics – crucially depends on understanding “particles” (such as electrons and photons) as wave-like, and this understanding is crucial to making sense of chemistry also.

8.1 Different Kinds of Waves {#8-1-different-kinds-of-waves}

There are important differences between these cases. For example, waves in the rope are obviously transverse waves – with the relevant rope particles moving roughly sideways relative to the direction of the wave – whereas sound waves are longitudinal, since the patterns of high and low pressure move along the direction of the wave’s travel. Water waves involve a combination of transverse and longitudinal movement, since the individual molecules’ motion is roughly circular. Light waves are transverse, since the relevant oscillations are oriented perpendicular to the wave’s motion, but unlike rope and sound waves, these oscillations are not in some material substance (but instead in the strength of the magnetic and electric fields), and so light can travel through empty space. There are also more subtle differences: light, for example, can be accurately represented in terms of a sine wave – a wave whose shape is sinusoidal (taking the same form as the sine function) – though there are complications we’ll come to later. Water waves, however, are more accurately represented as trochoid in shape, which looks rather like a flattened sine curve. Sound waves do not have a shape as such, but if we plot the variation in air pressure at any point as the sound passes, we will find that we have a curve which can be analysed into sinusoidal components, as we shall see later. It will turn out that despite their differences, these various wave phenomena can for many purposes be treated as similar, and analysed by common methods. The sections that follow aim to provide some computer-assisted insight into these methods.

8.2 Interference {#8-2-interference}

Suppose a small stone is dropped into the middle of a still pond. It will cause a circular pattern of waves to spread out from the point of impact, and these waves will consist of crests (where the water is highest) and troughs (where the water is lowest), with intermediate heights in between. Suppose that instead two similar stones are simultaneously dropped into the still pond, a short distance apart. This time, circular patterns of waves will start spreading out from each of the two points of impact, much as before, but when the two patterns of waves start to overlap with each other, they will interfere, to produce a new pattern which is a combination of the two. Where the crests of both waves coincide, they will combine to create a crest of double the height, and likewise two troughs will combine to create a trough of double the depth (this augmentation is called constructive interference). But where a crest of one wave meets a trough of the other, the two will cancel each other out (this mutual cancelling is called destructive interference).

8.3 Superposition and Fourier Decomposition {#8-3-superposition-and-fourier-decomposition}

Hugh Wallis’s “WaveSuperposer” program is very different from the other example programs, in being over 1000 lines long (so you will find that it takes some time to compile), and it is provided more as an illustration of what is possible in Turtle, and as a teaching and learning aid, rather than as a model for students to follow. Here we see the initial setup when the program starts, with two sine waves at the top – one whose wavelength is the full width of the x-axis, and the other half that – and below, the wave that results from combining them. Though often called “interference” between the two waves, this is better considered as involving their addition or superposition – at each point along the x-axis, the height of the superposed wave (whether positive or negative) is simply the sum of the heights of the two component waves. To get a feel for this, you could try changing the “Amplitude” (i.e. the maximum height) or the “Phase” (i.e. the horizontal position) of the two waves, using the controls at the top (use “Select Wave” to choose the wave you want to change). As you do so, you will see the superposed wave changing accordingly.

Now click on “Initialise all waves”, the wide green button near the top left, and then the red “10” button just above it. The canvas will show you what results from the superposition of 10 different sine waves – all starting from 0 at the left end of the x-axis, and with successively fractional wavelengths (e.g. the 6th wave has 6 wavelengths along the x-axis). If you now click on “Odds” (green button near the middle top), you will see the result of superposing waves 1, 3, 5, 7, and 9 (and then clicking on “60” will superpose the 30 waves 1, 3, 5, … 57, 59). All this shows how a wide variety of wave patterns can be built up using combinations of sine waves. To see examples of specific shapes and how they are generated, click on “Menu” at the top right (the “Sawtooth” example is shown here).

The technique of analysing any given wave form as a combination of sine waves is known as Fourier decomposition, after the French mathematician Joseph Fourier. It is extremely useful in many practical contexts, especially for analysing sound, pictures, radio and other signals (e.g. seismic or sonar), identifying their main components, and thus enabling further processing (e.g. for amplification, purification, or transformation, including such applications as crystallography, mass spectroscopy, and medical imaging). One important consequence of Fourier’s principle – that almost any periodic function can be decomposed in this way – is that if we discover laws governing sine waves, and if these laws apply also to superpositions of sine waves, then they will automatically apply also to most other periodic functions. So even if sound waves, say, are rarely purely sinusoidal, nevertheless Fourier decomposition often allows us to treat them as though they were.

8.4 Sine Waves and Circular Motion {#8-4-sine-waves-and-circular-motion}

Suppose that a cement mixing lorry – with a large tubular tank lying horizontally from front to back – is moving forward at a constant speed, with its tank (circular cross-section, radius 1 metre) rotating as it goes. Suppose that a prominent coloured handle sticks out backwards from point P on the rear edge of the curved surface of this tank, and consider this from the point of view of someone standing behind the lorry (and with all distances in metres):

If is the angle between the horizontal and line OP – where O is the centre of the tank – then the height of P above O will be sin _. As the tank rotates, goes repeatedly round the circle, so the height of _P will describe a repeated sine curve over time. What this shows is that a sine wave can be thought of as a projection of circular motion, in which we ignore one of the circular dimensions (in this case, the horizontal) and plot the other (here, the vertical) against time. (If we imagine the lorry moving forward, and viewed from the point of view of someone standing well to the side as it passes – who sees the forward motion of the lorry, and the up-down motion of the handle attached at point P, but not the rotation as such – then we get a sine curve through space as well as time, by plotting the height of P against the distance travelled along the road.)

8.5 Rotating Arrows of Light, and Superposed Vectors {#8-5-rotating-arrows-of-light-and-superposed-vectors}

In his well-known book QED: The Strange Theory of Light and Matter, Richard Feynman, one of the main developers of quantum electrodynamics (“QED” for short) provides a brilliant exposition in which he treats photons of light as arrows that revolve over time (around the axis of the direction of motion) – this corresponds to the synchronised oscillations of the electric and magnetic fields as light travels (at a speed of roughly 300 million metres per second). The wavelength of any photon is the distance it travels while its arrow makes one full rotation; hence slower rotation will imply a longer wavelength. The direction of the arrow at any point accordingly determines the phase of the photon – how far it is through each wavelength (e.g. a turn of 90° corresponds to a quarter wavelength). Treating photons of light in this way as rotating arrows – and thus as “waves” in two dimensions – makes it possible to model faithfully how they interact (whereas treating them as waves that move only in one dimension, e.g. up and down, would be inadequate).

To clarify how superposition works in the rotating arrows model, run the example program “Interference”, which initially shows at the top a representation of two component waves of equal amplitude, with wavelengths 300 (red) and 420 (skyblue) respectively. The 16 “clocks” underneath each wave show its phase (i.e. arrow direction) at equally spaced intervals – and the height of the end of the clock hand (which represents the rotating “arrow”) corresponds to the height of the wave at that point, with a wavelength corresponding to a full turn of the relevant clock.

Below is the wave that results from adding or superposing the two top waves – again there are 16 clocks, but since they are larger (to accommodate the addition), they are in two rows rather than one. Here in each case the big clock shows the red “hand” extending from the centre, with exactly the same length and direction as the hand for the first component wave, but then the blue “hand” starts from where the red hand ends, likewise having the same length and direction as the hand for the second component wave. By this means, the second clock “arrow” is added to the first clock “arrow”, yielding a resultant arrow that is drawn in indigo as the clock hand – this is an example of how vector addition works (where a vector is a magnitude in a given direction, representable by an arrow). The height of the end of this hand determines the height of the resultant wave at that point. (To make sure that you understand what’s happening here, try generating more examples by pressing the “R” key, which will randomly choose two different wavelengths between 200 and 500.)

When you are ready to move on, press the “2” key, which keeps the wavelengths the same, but replaces the previous “1-dimensional” superposition display – in which the graphed curves track only the height indicated by the relevant arrows at each point – with a “2dimensional” superposition display that aims to represent both their amplitude and direction. Amplitude is shown by brightness, while direction (i.e. phase) is shown by spectral colour; thus the waves at the top rotate through the colours as the arrows rotate, from violet, through blue, cyan, lime green, yellow, orange, red, and back to violet again. The resultant wave is coloured in the same sort of way, so an arrow pointing “north” is violet, and one pointing “south” is green (shading into yellow). But when a resultant arrow is very short (i.e. there is severe destructive interference), the relevant colour is mixed with black, and therefore appears much darker. Thus the diagram attempts to show both the phase of the resultant wave and its strength. To familiarise yourself with what’s going on, it might be helpful to press “1” and “2” to alternate the two kinds of display, and remember that pressing “R” at any point will choose a new random pair of wavelengths.

8.6 Young’s Two-Slit Experiment {#8-6-young-s-two-slit-experiment}

We can now use these techniques to help explain Thomas Young’s famous two-slit experiment, presented to the Royal Society in 1803, which was key to demonstrating the wave nature of light. Imagine, then, that we have a single source of pure light of some particular wavelength, which shines onto a screen containing two thin vertical slits. If the slits are thin enough, then the light diffracts as it passes through each of them, and spreads out on the other side of the screen as though the slit itself was a light source (diffraction is well explained in chapter 2 of Feynman’s QED). As a result, we end up with two coordinated light sources, spreading light in expanding semicircles that overlap, much like ripples in a pond. The “TwoSlits” example program then constructs the resulting interference pattern, using the “2-dimensional” representation described above (with colour representing the phase of the resultant wave, and brightness its amplitude – remember that we are dealing with a pure source of light of one colour, so the apparatus will not actually appear multi-coloured). The result, with the default settings, is shown here, and helps to explain why bands of light appear at the back of the apparatus, corresponding to areas where there is constructive (rather than destructive) interference. The program enables the wavelength of the light to be specified, and also the position of the two slits – you will see that changing these settings gives a different interference pattern.