# 3.6, Example 1, Bar with insulated ends # Heat equation on a bar , f(x)=100, zero at ends F:=(m,x)->(400/Pi)*(1/(2*m+1))*sin(2*m*x+x); S:=(N,x)->sum(F(m,x),m=0..N): opts:=axes=boxed,thickness=2: n:=2:plot(S(n,x),x=-Pi..Pi,opts);S(n,x); # Snapshot plots u:=(x,t,N)->sum(F(m,x)*exp(-(2*m+1)^2*t),m=0..N): plot(u(x,0,6),x=0..Pi,opts); plot(u(x,1.5,6),x=0..Pi,opts); plot(u(x,2.5,6),x=0..Pi,opts); with(plots): animate( plot, [u(x,t,6),x=0..Pi,opts], t=0..3, trace=5, frames=20 );