m16.mws

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;

L := 2

H := 3

A := 4

Characteristic equation:

>    w(x):=x*cos(x*L)+H*sin(x*L);

w(x) := x*cos(2*x)+3*sin(2*x)

>    plot(w(x),x=0..10);

[Maple Plot]

Eigenvalues:

>    lambda:=array(1..50);

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;

1.358229874

2.768911636

4.235147453

5.738636645

7.264403196

8.803594038

>    N:=n-1;

N := 32

>    n:='n':i:='i':

Eigenfunctions:

>    X[n]:=sin(lambda[n]*x);

X[n] := sin(lambda[n]*x)

Squared-norm:

>    NX[n]:=int(X[n]^2,x=0..L);

NX[n] := 1/2*(-cos(2*lambda[n])*sin(2*lambda[n])+2*lambda[n])/lambda[n]

GENERALIZED FOURIER SERIES

Function (initial condition):

>    u0(x):=x*(L-x)+1;

u0(x) := x*(2-x)+1

Fourier coefficients:

>    a[n]:=simplify(int(u0(x)*X[n],x=0..L)/NX[n]);

a[n] := -2*(2*lambda[n]*sin(2*lambda[n])+lambda[n]^2*cos(2*lambda[n])+2*cos(2*lambda[n])-2-lambda[n]^2)/lambda[n]^2/(-cos(2*lambda[n])*sin(2*lambda[n])+2*lambda[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);

[Maple Plot]

>    animate({u0(x),u(x,t)},x=0..L,t=0..50,frames=200,axes=boxed);

[Maple Plot]

>    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);

[Maple Plot]

>