Example 8.7shorttime.mw

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

diff(u(x, t), t) = diff(diff(u(x, t), x), x) (1)
 

> u(x,0):=0;
 

0 (2)
 

> bc1:=diff(u(x,t),x)=0;
 

diff(u(x, t), x) = 0 (3)
 

> bc2:=u(x,t)=1;
 

u(x, t) = 1 (4)
 

> eqs:=laplace(eq,t,s):
 

> eqs:=subs(laplace(u(x,t),t,s)=U(x),eqs);
 

`*`(s, `*`(U(x))) = diff(diff(U(x), x), x) (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);
 

(D(U))(0) = 0 (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);
 

U(1) = `/`(1, `*`(s)) (7)
 

> U(x):=rhs(dsolve({eqs,bc1,bc2},U(x)));
 

`+`(`/`(`*`(exp(`*`(`^`(s, `/`(1, 2)), `*`(x)))), `*`(s, `*`(`+`(exp(`*`(`^`(s, `/`(1, 2)))), exp(`+`(`-`(`*`(`^`(s, `/`(1, 2)))))))))), `/`(`*`(exp(`+`(`-`(`*`(`^`(s, `/`(1, 2)), `*`(x)))))), `*`(s, ... (8)
 

> U1s:=exp(s^(1/2))/s/(exp(s^(1/2))^2+1)*exp(s^(1/2)*x);
 

`/`(`*`(exp(`*`(`^`(s, `/`(1, 2)))), `*`(exp(`*`(`^`(s, `/`(1, 2)), `*`(x))))), `*`(s, `*`(`+`(`*`(`^`(exp(`*`(`^`(s, `/`(1, 2)))), 2)), 1)))) (9)
 

> U2s:=exp(s^(1/2))/s/(exp(s^(1/2))^2+1)*exp(-s^(1/2)*x);
 

`/`(`*`(exp(`*`(`^`(s, `/`(1, 2)))), `*`(exp(`+`(`-`(`*`(`^`(s, `/`(1, 2)), `*`(x))))))), `*`(s, `*`(`+`(`*`(`^`(exp(`*`(`^`(s, `/`(1, 2)))), 2)), 1)))) (10)
 

> U1S:=series(subs(exp(s^(1/2))=1/S,U1s),S):
 

> U1S:=subs(S=exp(-s^(1/2)),U1S):
 

> simplify(U1S);
 

`/`(`*`(`+`(exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(1))))), `-`(exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(3)))))), exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(5))))), `*`(O(exp(`+`(`-`(`*`(7, `*`(`^`(... (11)
 

> U1S:=Sum((-1)^(n-1)*exp(s^(1/2)*(x-2*n+1))/s,n=1..infinity);
 

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;
 

`/`(`*`(`^`(-1, `+`(n, `-`(1))), `*`(exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(`*`(2, `*`(n))), 1)))))), `*`(s)) (13)
 

> u1t:=invlaplace(u1s,s,t);
 

`*`(`^`(-1, `+`(1, n)), `*`(invlaplace(`/`(`*`(exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(`*`(2, `*`(n))), 1))))), `*`(s)), s, t))) (14)
 

> U1t:=Sum(u1t,n=1..infinity);
 

Sum(`*`(`^`(-1, `+`(1, n)), `*`(invlaplace(`/`(`*`(exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(`*`(2, `*`(n))), 1))))), `*`(s)), s, t))), 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);
 

`/`(`*`(`+`(exp(`+`(`-`(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, 1)))))), `-`(exp(`+`(`-`(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, 3))))))), exp(`+`(`-`(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, 5)))))), `*`(O(exp(`+`(`-`(... (16)
 

> U2S:=Sum((-1)^(n-1)*exp(-s^(1/2)*(x+2*n-1))/s,n=1..infinity);
 

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

`*`(`^`(-1, `+`(1, n)), `*`(invlaplace(`/`(`*`(exp(`*`(`+`(`-`(x), `-`(`*`(2, `*`(n))), 1), `*`(`^`(s, `/`(1, 2)))))), `*`(s)), s, t))) (18)
 

> U2t:=Sum(u2t,n=1..infinity);
 

Sum(`*`(`^`(-1, `+`(1, n)), `*`(invlaplace(`/`(`*`(exp(`*`(`+`(`-`(x), `-`(`*`(2, `*`(n))), 1), `*`(`^`(s, `/`(1, 2)))))), `*`(s)), s, t))), 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;
 

`+`(Sum(`*`(`^`(-1, `+`(1, n)), `*`(invlaplace(`/`(`*`(exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(`*`(2, `*`(n))), 1))))), `*`(s)), s, t))), n = 1 .. infinity), Sum(`*`(`^`(-1, `+`(1, n)), `*`(invlapla... (20)
 

> u:=subs(infinity=N,Ut):
 

> u:=subs(N=50,u);
 

`+`(Sum(`*`(`^`(-1, `+`(1, n)), `*`(invlaplace(`/`(`*`(exp(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(`*`(2, `*`(n))), 1))))), `*`(s)), s, t))), n = 1 .. 50), Sum(`*`(`^`(-1, `+`(1, n)), `*`(invlaplace(`/`... (21)
 

> plot3d(u,x=1e-6..1,t=1e-6..0.2,axes=boxed,labels=[x,t,"u"],orientation=[-150,60]);
 

Plot
 

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

Plot_2d
 

>