# Sept. 26, 2002 # # The following lines construct, using Fourier series, an approximate # solution to the heat equation, zero boundary conditions at x = 0, and # at x = 1, and u(x,0) equals the function f defined below. # > f:=piecewise(x<0.5,x,x<1,1-x,0); > N:=50; > for i from 1 to N do b[i]:=evalf(2*Int(f*sin(i*Pi*x),x=0..1)); > od:i:='i': > u:=sum(b[k]*sin(k*Pi*x)*exp(-k^2*Pi^2*t),k=1..N): > plot([f,subs(t=0.1,u),subs(t=0.5,u),subs(t=10,u)],x=0..1,color=[red,bl > ue,green,black]); >