traveling waves

A function f[x] defined on an interval such as [0, L] 
can be made to "travel" via f[x + a t] or f[x - a t].


notebook created by T. Shelton, Southwestern University

An example

Clear[f,L];
L = 30;
f[x_] := (3/L)x /; 0 ≤ x < L/3.
f[x_] := (3/(2 L))(L-x)/; L/3. ≤ x <L

Print[" "];Print["Set the velocity parameter, then change t (slide or play)."];Print["While t is playing, change the velocity parameter."];Manipulate[    Plot[{f[x],f[x - a*t]},
{x,-L/2., 5L},
PlotRange->{{0,200},{0,1.2}}, 
PlotStyle->{{Red,Thick},{Blue ,Dashed,Thick}},
AxesLabel->{" x "},  PlotRange->{-0.25, 1.25},PlotLabel->"Original f is red; right-moving wave f[x - a*t] is blue, dashed"],
{{a,.5,"velocity"},.5,4,.5},
{{t,.5,"t"},0,50,.5}]

Print[" "];Print["Set the velocity parameter, then change t (slide or play)."];Print["While t is playing, change the velocity parameter."];
Manipulate[
Plot[{f[x],f[x + a*t]},{x,-5L, 1.25L},
PlotRange->{{-50,50},{0,1.2}}, 
PlotStyle->{{Red,Thick},{Blue ,Dashed,Thick}},
AxesLabel->{" x "},  PlotRange->{-0.25, 1.25}, PlotLabel->"Original f is red; left-moving wave f[x + a*t] is blue, dashed"],
{{a,.5,"velocity"},.5,4,.5},
{{t,.5,"t"},0,50,.5}]

Try others

You may change the function definition f  and the graphing parameters.

Try some of these:

Example 2
L = 2π;
f[x_] = Sin[x]
PlotRange -> {-1.25, 1.25}

Example 3
L = 2π;
f[x_] = Sin[x] - 0.5 Cos[3 x]
PlotRange -> {-1.5, 1.5}

Example 4
L = 2;
f[x_] =Log[1 + x]
PlotRange -> {-0.25, 1.5}

Example 5
L = 35;
f[x_] := 0 /; 0.0 ≤ x < 9.0;
f[x_] := 10 /; 9.0 ≤ x < 19.0;
f[x_] := 0 /; 19.0 ≤ x ≤ 35.0;
PlotRange -> {-0.25, 10.5}

The highlighting below guides which portions to change; similar changes are needed in the other 'Manipulate' command.

Clear[f,L];
L = 30;
f[x_] := (3/L)x /; 0 ≤ x < L/3.
f[x_] := (3/(2 L))(L-x)/; L/3. ≤ x <L

Manipulate[
 Plot[{f[x], f[x + a*t]}, {x, -5 L, 1.25 L}, 
  PlotStyle -> {{Red, Thick}, {Blue , Dashed, Thick}},
  AxesLabel -> {" x "},  PlotRange -> {-0.25, 1.25}, 
  PlotLabel -> 
   "Original f is red; left-moving wave f[x + a*t] is blue, dashed"],
 {{a, .5, "velocity"}, .5, 4, .5},
 {{t, .5, "t"}, 0, 50, .5}]