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(1);c(2);c(21); |
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. |
| > | 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]](images/heateqex_6.gif)
Next I'll use m=25 to use the first 25 nonzero terms.
| > | 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]](images/heateqex_8.gif)
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]](images/heateqex_9.gif)
| > | 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]](images/heateqex_10.gif)
| > | 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]](images/heateqex_11.gif)
| > | 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]](images/heateqex_12.gif)
| > |