Untitled

Heat Equation Example from Class

> restart:with(plots):

Warning, the name changecoords has been redefined

> c:=proc(k) #This procedure computes the coeffients.
 40/((2*k-1)*Pi)

end;

c := proc (k) 40/((2*k-1)*Pi) end proc

> c(1);c(2);c(21);

40/Pi

40/3/Pi

40/41/Pi

First we just use 10 nonzero tems. Remember f(x) = 10 is the initial temp distrabution. I did t=0 to 1 unit with 50 frames.

> m:=10; # Set number of terms to use.

m := 10

> animate((sum((c(k)*sin((2*k-1)*Pi*x)*exp(-(2*k-1)^2*Pi^2*t) ),k=1..m)),
x=0..1, t=0..1,frames=50, color=green);

[Plot]

Next I'll use m=25 to use the first 25 nonzero terms.

> m:=25;

m := 25

> animate((sum((c(k)*sin((2*k-1)*Pi*x)*exp(-(2*k-1)^2*Pi^2*t) ),k=1..m)),
x=0..1, t=0..1,frames=50, color=green);

[Plot]

The result is not really  much better. Next I'll display some indiviual frames for the m=10 case.

> m:=10: t:=0:

> plot(sum(  c(k)*sin((2*k-1)*Pi*x)*exp(-(2*k-1)^2*Pi^2*t)   ,k=1..m),
x=0..1);

[Plot]

> t:=0.01:

> plot(sum(  c(k)*sin((2*k-1)*Pi*x)*exp(-(2*k-1)^2*Pi^2*t)   ,k=1..m),
x=0..1,yview=0..10.5);

[Plot]

> t:=0.05:

> plot(sum(  c(k)*sin((2*k-1)*Pi*x)*exp(-(2*k-1)^2*Pi^2*t)   ,k=1..m),
x=0..1,yview=0..10.5);

[Plot]

> t:=0.1:

> plot(sum(  c(k)*sin((2*k-1)*Pi*x)*exp(-(2*k-1)^2*Pi^2*t)   ,k=1..m),
x=0..1,yview=0..10.5);

[Plot]

>