m16.mws 018 4.6.3 3) heat4-1a.mws Heat Equation (Dirichlet-Robin)
> | restart; |
> | with(plots): |
Warning, the name changecoords has been redefined
> | L:=2;H:=3;A:=4; |
Characteristic equation:
> | w(x):=x*cos(x*L)+H*sin(x*L); |
> | plot(w(x),x=0..10); |
Eigenvalues:
> | lambda:=array(1..50); |
> | n:=1: for m from 1 to 500 do z:=fsolve(w(x)=0,x=m/10..(m+1)/10): if type(z,float) then lambda[n]:=z: n:=n+1 fi od: |
> | for i to 6 do lambda[i] od; |
> | N:=n-1; |
> | n:='n':i:='i': |
Eigenfunctions:
> | X[n]:=sin(lambda[n]*x); |
Squared-norm:
> | NX[n]:=int(X[n]^2,x=0..L); |
GENERALIZED FOURIER SERIES
Function (initial condition):
> | u0(x):=x*(L-x)+1; |
Fourier coefficients:
> | a[n]:=simplify(int(u0(x)*X[n],x=0..L)/NX[n]); |
Generalized Fourier series:
> | u(x,t):=sum(a[n]*X[n]*exp(-lambda[n]^2*t/A^2),n=1..N): |
> | plot3d(u(x,t),x=0..L,t=0..30,axes=boxed,projection=0.9,color=black,style=wireframe); |
> | animate({u0(x),u(x,t)},x=0..L,t=0..50,frames=200,axes=boxed); |
> | u(x,0):=subs(t=0,u(x,t)): |
> | u(x,1):=subs(t=1,u(x,t)): |
> | u(x,5):=subs(t=5,u(x,t)): |
> | u(x,10):=subs(t=10,u(x,t)): |
> | u(x,20):=subs(t=20,u(x,t)): |
> | plot({u0(x),u(x,0),u(x,1),u(x,5),u(x,10),u(x,20)},x=0..L,axes=boxed,color=black); |
> |