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 position 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 tries to get the best
accuracy possible with it.
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 it was 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 Simple Pendulum

A simple pendulum consists of a massive bob attached by a string or light rod to a fixed pivot point, whereas a physical pendulum can be any rigid body attached to a fixed pivot. The equation of motion for a physical pendulum involves its moment of inertia about the pivot and the distance from the pivot to its centre of mass, but the form of the equation is the same as that for the simple pendulum, as are all features of the motion. For both, the restoring force is proportional to the sine of the angular displacement from equilibrium. For small angles, the sine of an angle is equal to angle itself (in radians), and the restoring force is proportional to the displacement (as it was for the spring). This is the condition for Simple Harmonic Motion - motion where the frequency of oscillation is independent of the amplitude.

In the example we study here, the pendulum bob of a simple pendulum is connected to the pivot by a light rod rather than a string so it can reach large amplitudes. The bob starts from the equilibrium point with an initial velocity that gives it an angular amplitude of 90 degrees (it rises to the same elevation as the pivot). This velocity is found directly using conservation of energy.

The important thing to realize about this example is that we have been able to solve a problem that has no easy analytic solution, and we did it using a program no more complicated than the one we used for the spring. The value found for Smax agrees with the predicted L*PI/2 to within one in the sixth decimal place.

The time it takes to reach Smax can be found by an alternate method that does
not use Newton's Law. The definition of velocity can be transposed to give *dt=ds/v*,
and energy conservation gives *v* as a function of *s*. It is then a simple matter to divide
the range of *s* into *n* divisions and sum the times to cross them. The Newton's Law
calculation used something over 500 time steps, so 500 appears to be an appropriate number of
divisions for the range. The program reads so easily that no further comment is necessary.
It is remarkable that the two totally different calculations of the time differ only by one
in the seventh decimal place.

So far we have concentrate on introducing numerical techniques and demonstrating their accuracy. From this point onward our focus will be on making optimal use of the computer's capability to display results of our calculations. BBC BASIC simplifies animation by giving the user control of the Windows refresh, but demonstrating this requires running the program, not merely looking at the screen images presented here.

The Driven Oscillator

The Feynman Algorithm needs no modification to deal with forces that depend on time as well as on position. Consider the example of a mass attached to a spring and subjected to an external force that varies sinusoidally at the resonant frequency of the mass-spring system. The analytic solution of this problem is beyond the level of introductory physics texts, but the numerical solution requires only direct application of the Feynman Algorithm. The parameters of the problem are given in the program listings, and the output is a plot of the driving force (in blue) and the response of the mass (in black at the resonant frequency and in red at higher and lower frequencies). At the resonant frequency, the amplitude of the response appears to increase linearly with time, and the phase appears lag the force by 90 degrees. When the driving frequency is 90% of the resonant frequency, the oscillation builds up until it is in phase with the driving force, then decreases. At 110% of the resonant frequency, the maximum response occurs when the response is 180 degrees out of phase with the driving force.