(*     Module #15:  Wave Addition     *)

(*    Sum of Two Cosine Waves with same amplitude but
       quite different frequency                      *)
       
      Plot[3.*Cos[10.*t]+3.*Cos[100.*t],{t,0,2.},
      PlotRange->{-6,6},
      AxesLabel->{"t","f[t]"}]

(*     Addition of two waves in phase     *)

angle = 0.;   (*  The phase angle of the 2nd wave  *)

Plot[3.*Cos[10.*t]+3.*Cos[(10.*t+angle)],{t,0,1.},
      PlotRange->{-6,6},
      AxesLabel->{"t","f[t]"}]

(*     Addition of two waves 180 degrees out of phase     *)

angle = N[Pi];   (* Phase Angle of 2nd wave is Pi         *)
Plot[3.*Cos[10.*t]+3.*Cos[(10.*t+angle)],{t,0,1.},
      PlotRange->{-6,6},AxesLabel->{"t","f[t]"}]

(*     Fourier Series of a Triangle Wave     *)

g[t_] := 1/2.- (4./(Pi^2))*(Cos[t]+(1/9.)*Cos[3*t]);
Plot[g[t],{t,0.,2 Pi},AxesLabel->{"x","f[x]"}]

(*     Fourier Series of a Triangle Wave-more terms *)

g[t_] := 1/2.- (4./(Pi^2))*(Cos[t]+(1/9.)*Cos[3*t]+
                 (1/25.)*Cos[5*t]);
Plot[g[t],{t,0.,2 Pi},AxesLabel->{"x","f[x]"}]

(*     A Traveling Wave at the point x=0             *)

A=1.; k=1;omega=2;
h[x_,t_] := A*Cos[k*x-omega*t];

Plot[h[x=0,t],{t,0.,2 Pi},AxesLabel->{"t","h[x=0,t]"}]

(*     A Traveling Wave at time t=0                  *)
Plot[h[x,t=0],{x,0.,2 Pi},AxesLabel->{"x","h[x,t=0]"}]

(*     Graph of the Traveling Wave at a later time t=Pi/4    *)
Plot[h[x,t=Pi/4.],{x,0.,2 Pi},AxesLabel->{"x","h[x,t=Pi/4]"}]

(*   Generate a sequence of graphs of the Traveling
     Wave at successive times                      *)
Do[Plot[h[x,t],{x,0.,2 Pi}],{t,0,Pi,Pi/10}]

(*    Graph of two cosine waves of equal amplitude
      and slightly different frequency     *)
      
      Plot[3.*Cos[16.*t]+3.*Cos[18.*t],{t,0,2.},
      PlotRange->{-6,6},
      AxesLabel->{"t","f[t]"}]

(*     Graph of two Cosine Waves of Different Amplitude  *)
Plot[3.*Cos[10.*t]+30.*Cos[100.*t],{t,0,1.5},
      PlotRange->{-40,40},
      AxesLabel->{"t","f[t]"}]