Example shown for short time solution. See equation 20. Whole file not used.
| > | restart:with(inttrans):with(plots): |
| > | eq:=diff(u(x,t),t)=diff(u(x,t),x$2); |
| (1) |
| > | u(x,0):=0; |
| (2) |
| > | bc1:=diff(u(x,t),x)=0; |
| (3) |
| > | bc2:=u(x,t)=1; |
| (4) |
| > | eqs:=laplace(eq,t,s): |
| > | eqs:=subs(laplace(u(x,t),t,s)=U(x),eqs); |
| (5) |
| > | bc1:=laplace(bc1,t,s): |
| > | bc1:=subs(diff(laplace(u(x,t),t,s),x)=D(U)(0),laplace(u(x,t),t,s)=U(0),bc1); |
| (6) |
| > | bc2:=laplace(bc2,t,s): |
| > | bc2:=subs(diff(laplace(u(x,t),t,s),x)=D(U)(1),laplace(u(x,t),t,s)=U(1),bc2); |
| (7) |
| > | U(x):=rhs(dsolve({eqs,bc1,bc2},U(x))); |
| (8) |
| > | U1s:=exp(s^(1/2))/s/(exp(s^(1/2))^2+1)*exp(s^(1/2)*x); |
| (9) |
| > | U2s:=exp(s^(1/2))/s/(exp(s^(1/2))^2+1)*exp(-s^(1/2)*x); |
| (10) |
| > | U1S:=series(subs(exp(s^(1/2))=1/S,U1s),S): |
| > | U1S:=subs(S=exp(-s^(1/2)),U1S): |
| > | simplify(U1S); |
| (11) |
| > | U1S:=Sum((-1)^(n-1)*exp(s^(1/2)*(x-2*n+1))/s,n=1..infinity); |
| (12) |
| > | u1s:=(-1)^(n-1)*exp(s^(1/2)*(x-2*n+1))/s; |
| (13) |
| > | u1t:=invlaplace(u1s,s,t); |
| (14) |
| > | U1t:=Sum(u1t,n=1..infinity); |
| (15) |
| > | U2S:=series(subs(exp(s^(1/2))=1/S,U2s),S): |
| > | U2S:=subs(S=exp(-s^(1/2)),U2S): |
| > | simplify(U2S); |
| (16) |
| > | U2S:=Sum((-1)^(n-1)*exp(-s^(1/2)*(x+2*n-1))/s,n=1..infinity); |
| (17) |
| > | u2s:=(-1)^(n-1)*exp(-s^(1/2)*(x+2*n-1))/s: |
| > | u2t:=invlaplace(u2s,s,t); |
| (18) |
| > | U2t:=Sum(u2t,n=1..infinity); |
| (19) |
The short time solution for the same problem can be otained using the methodology described in seciton 8.1.4 (examples 8.5 and 8.6) as:
| > | Ut:=U1t+U2t; |
| (20) |
| > | u:=subs(infinity=N,Ut): |
| > | u:=subs(N=50,u); |
| (21) |
| > | plot3d(u,x=1e-6..1,t=1e-6..0.2,axes=boxed,labels=[x,t,"u"],orientation=[-150,60]); |
![]() |
| > | plot([subs(t=1e-6,u),subs(t=1e-2,u),subs(t=0.05,u),subs(t=0.2,u)],x=0..1,axes=boxed,thickness=5,labels=[x,"u"]); |
![]() |
| > |