AnimationTriwave.mw

Vibrating String Examples with Animations

> restart:

> with(plots):

This is the example done in class. Below is the formula we found for c_n.

> c:= n -> 8*sin(n*Pi/2)/(n^\2*Pi^2);

c := proc (n) options operator, arrow; 8*sin(1/2*n*Pi)/(n^2*Pi^2) end proc

> N:=100:   # Number of terms to use.

> animate({sum((c(n)*sin(n*Pi*x/2)*cos(n*Pi*t/2)), n=1..N)}, x=0..2, t=0..4, frames=100, thickness=2);

[Plot]

Another example.The function is given below.

> f := x -> piecewise(x<=1, x, (-1/2)*x+3/2);

f := proc (x) options operator, arrow; piecewise(x <= 1, x, -1/2*x+3/2) end proc

> plot(f(x), x=0..3, thickness=2);

[Plot]

We will just leave the c_n as an integral.

> c := n -> (2/3)*int(f(x)*sin(n*Pi*x/3)  , x=0..3);

c := proc (n) options operator, arrow; 2/3*int(f(x)*sin(1/3*n*Pi*x), x = 0 .. 3) end proc

> N:=20:

> animate({sum((c(n)*sin(n*Pi*x/3)*cos(n*Pi*t/3)), n=1..N)}, x=0..3, t=0..6, frames=100, thickness=2);

[Plot]

Another Example.

> f := x -> piecewise(x<1,0,x<2,x-1,x<3,-x+3,0);

f := proc (x) options operator, arrow; piecewise(x < 1, 0, x < 2, x-1, x < 3, -x+3, 0) end proc

> plot(f(x),x=0..4,thickness=2);

[Plot]

> c := n -> (2/4)*int(f(x)*sin(n*Pi*x/4)  , x=0..4);

c := proc (n) options operator, arrow; 1/2*int(f(x)*sin(1/4*n*Pi*x), x = 0 .. 4) end proc

> N:=40:

> animate({sum((c(n)*sin(n*Pi*x/4)*cos(n*Pi*t/4)), n=1..N)}, x=0..4, t=0..8, frames=100, thickness=2);

[Plot]

>