Consider the problem:
> restart;eqn := diff(U(x,t),t)=2*diff(U(x,t),x,x);
> BC := {convert(D[1](U)(0,t),diff)=0,U(Pi,t)=0};IC:={U(x,0)=f(x)};
This problem has the LH side at 0 and the RH side at Pi INSULATED.
> alias(u=Heaviside);
> f(x):=x*(u(x)-u(x-Pi/2))+(Pi-x)*(u(x-Pi/2)-u(x-Pi));
> plot(f(x),x=0..Pi);
Our problem needs a new set of eigenfunctions in x. They must satisfy:
> ODE:=diff(X[n](x),x,x)+k[n]*X[n](x)=0;
> BC:={X[n](0)=0,`X'`[n](Pi)=0};
Such functions will be given by sin((2n-1)/2*x) as we can see by plotting a few...
> plot([seq(sin((2*n-1)/2*x),n=1..6)],x=0..Pi);
Notice that all the sins have value 0 at x = 0 BUT have slopes =0 at x=Pi. Such functions will staisfy the BC.
> b[n] := 2/Pi*(Int(x*sin((2*n-1)/2*x),x=0..Pi/2)+Int((Pi-x)*sin((2*n-1)/2*x),x=Pi/2..Pi));
> b[n] := value(%);
> for p from 1 to 5 do B[p]:=subs(n=p,b[n])=eval(subs(n=p,b[n])) od;
> U(x,t) := Sum(exp(-2*((2*n-1)/2)^2*t)*b[n]*sin((2*n-1)/2*x),n=1..10);
> plots[animate]({f(x),U(x,t)},x=0..Pi,t=0..10,color=black);
New Problem with different IC, same BC and equation...IC=u(x,0)=f(x) given by...
> f(x):=-(u(x)-u(x-Pi/3))+(u(x-2*Pi/3)-u(x-Pi));
> plot(f(x),x=0..Pi);
> b[n] :=
> 2/Pi*(Int(-1*sin((2*n-1)/2*x),x=0..Pi/3)+Int(sin((2*n-1)/2*x),x=2*Pi/3..Pi));
> b[n] := value(%);
> for p from 1 to 5 do B[p]:=subs(n=p,b[n])=eval(subs(n=p,b[n])) od;
> U(x,t) := Sum(exp(-2*((2*n-1)/2)^2*t)*b[n]*sin((2*n-1)/2*x),n=1..20);
> plots[animate]({f(x),U(x,t)},x=0..Pi,t=0..20,frames=20,color=black);
Notice that the heat will leave thru the end at x=0, since x=Pi is insulated. It will take longer for the temp to go to zero than if the RH end condition was 0 as well. Eventually it will however go to zero.