File name:  neworigin.nb

Code written by James Flaten, Luther College, Decorah, IA			flatja01@luther.edu
reference:  "Pendulum waves:  A lesson in aliasing," James A. Flaten and Kevin A. Parendo, Am. J. Phys. 69 (7), July 2001, pp. 778 – 782

This code was used to generate Figure 4 in the paper mentioned above.  This simulation does not show the "pendula," just the two fits.  The "y-function" below, derived in the paper, has the origin shifted to correspond to an infinitely-long pendulum so it is fixed at the point y=0 and contracts like an accordian as time goes by.  The original "g-function" used to fit the actual pendula in our apparatus, superimposed in bold, is in fact just the "y-function" from 20 to 34.  After the full set of images has been generated, they may be animated by selecting them all then pressing Apple-y (on a Mac at least).  This was written in Mathematica 4 -- I'm not sure whether or not it will run with older versions of Mathematica.  Once the images are generated, the file may either be saved with them (in which case they may be animated immediately upon loading) though this makes the file much larger.  Enjoy!

y[a_, t_] := A*Cos[((2*Pi*a*t)/(T*d))]

\(Here\ are\ the\ parameters\ used\ in\ the\ simulation . 
		"A"\ is\ the\ amplitude . 
		"T"\ is\ the\ total\ cycling\ time, \ 
      called\ capital - 
        gamma\ in\ the\ paper . 
		"NN"\ is\ the\ number\ of\ oscillations\ of\ the\ left - 
        most\ dot\ in\ time\ T . 
		"d"\ is\ the\ spacing\ between\ \(\(dots\)\(.\)\)\)

A := 1
T := 20
NN := 20
d := 1

Only 41 frames (one quarter of one full cycle), is shown since jaggies crop up after that.  Since the pendula themselves are not shown, these functions do not cycle in time, so it does not make much differece what fraction of a cycle is animated.

\(For[p = 0, 
      p < 41, \(p++\), 
{plot1 = 
          Plot[y[a, p*T/160], {a, 0, 40}, PlotRange -> {\(-1.1\), 1.1}, 
            Frame -> True, Background -> GrayLevel[0.9], 
            DisplayFunction -> Identity], 
plot2 = 
          Plot[y[a, p*T/160], {a, 20, 34}, PlotRange -> {\(-1.1\), 1.1}, 
            Frame -> True, Background -> GrayLevel[0.9], 
            PlotStyle -> {Thickness[0.015]}, 
            DisplayFunction -> Identity], 
Show[plot1, 
          plot2, DisplayFunction -> $DisplayFunction]}
]\)