Example 8.2.mw

Example 8.2 

> restart:with(inttrans):with(plots):
 

>
 

> eq:=diff(u(x,t),t)+diff(u(x,t),x);
 

`+`(diff(u(x, t), t), diff(u(x, t), x)) (1)
 

> u(x,0):=1-exp(-x);
 

`+`(1, `-`(exp(`+`(`-`(x))))) (2)
 

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

u(0, t) = 0 (3)
 

The solution obtained in the Laplace domain is: 

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

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

`+`(`*`(s, `*`(U(x))), `-`(1), exp(`+`(`-`(x))), diff(U(x), x)) (4)
 

> bc1:=laplace(bc1,t,s):
 

> bc1:=subs(laplace(u(0,t),t,s)=U(0),bc1);
 

U(0) = 0 (5)
 

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

`+`(`/`(`*`(exp(`+`(`-`(`*`(s, `*`(x)))))), `*`(s, `*`(`+`(s, `-`(1))))), `-`(`/`(`*`(`+`(`-`(s), 1, `*`(exp(`+`(`-`(x))), `*`(s)))), `*`(s, `*`(`+`(s, `-`(1))))))) (6)
 

The solution obtained in the time domain is obtained as: 

> u:=invlaplace(U(x),s,t);
 

`+`(`-`(invlaplace(`/`(`*`(exp(`+`(`-`(`*`(s, `*`(x)))))), `*`(s)), s, t)), invlaplace(`/`(`*`(exp(`+`(`-`(`*`(s, `*`(x)))))), `*`(`+`(s, `-`(1)))), s, t), 1, `-`(exp(`+`(`-`(x), t)))) (7)
 

> plot3d(u,x=1e-6..1,t=0..1,axes=boxed,title="Figure Exp. 8.3.",labels=[x,t,"u"],orientation=[120,60]);
 

Plot
 

> plot([subs(t=0.1,u),subs(t=0.25,u),subs(t=0.5,u),subs(t=1,u)],x=0..1,axes=boxed,title="Figure Exp. 8.4.",thickness=5,labels=[x,"u"]);
 

Plot_2d
 

>