Heat.mw

> with(plots);

Here is an animation for the first heat equation example in Ch10PartIV: both end points are held at 0 degrees while the metal rod is initially a uniform 10 degrees.

> animate(sum(40/(2*n-1)/Pi*sin((2*n-1)*Pi*x)*exp(-(2*n-1)^2*Pi^2*t) ,n=1..50), x=0..1,t=0..0.5,numpoints=1000,frames=100);

[Plot]

Here is a crazy example. The initial temp is the function below defined using the piecewise command.

> f := x -> piecewise(x<.2, 0, x>=.2 and x<=.4 , -500*(x-0.2)*(x-0.4), x>0.4 and x<0.6, 0, x>=0.6 and x<=0.8, 4, x>0.8, 0);

f := proc (x) options operator, arrow; piecewise(x < .2, 0, .2 <= x and x <= .4, -500*(x-.2)*(x-.4), .4 < x and x < .6, 0, .6 <= x and x <= .8, 4, .8 < x, 0) end proc

> plot(f(x),x=0..1);

[Plot]

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

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

> plot( sum( c(n)*sin(n*Pi*x), n=1..50 ) ,x=-1..1);

[Plot]

> animate(sum( c(n)*sin((n)*Pi*x)*exp(-(n^2*Pi^2*t)) ,n=1..50), x=0..1,t=0..0.2,numpoints=1000,frames=100);

[Plot]

>

>

>