Example 8.8.mw

Example 8.8 Diffusion with Reaction 

Equation  (8.1.18) is solved in Maple below: 

 

> restart; -1; with(inttrans); -1; with(plots); -1
 

> eq:=diff(u(x,t),t)=diff(u(x,t),x$2)-Phi^2*u(x,t);
 

diff(u(x, t), t) = `+`(diff(diff(u(x, t), x), x), `-`(`*`(`^`(Phi, 2), `*`(u(x, t))))) (1)
 

> u(x,0):=0;
 

0 (2)
 

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

u(x, t) = 1 (3)
 

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

diff(u(x, t), x) = 0 (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), `-`(`*`(`^`(Phi, 2), `*`(U(x))))) (5)
 

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

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

U(x) = `/`(1, `*`(s)) (6)
 

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

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

diff(U(x), x) = 0 (7)
 

> dsolve(eqs,U(x));
 

U(x) = `+`(`*`(_C1, `*`(sin(`*`(`^`(`+`(`-`(s), `-`(`*`(`^`(Phi, 2)))), `/`(1, 2)), `*`(x))))), `*`(_C2, `*`(cos(`*`(`^`(`+`(`-`(s), `-`(`*`(`^`(Phi, 2)))), `/`(1, 2)), `*`(x)))))) (8)
 

> U(x):=c[1]*cosh((s+Phi^2)^(1/2)*x)+c[2]*sinh((s+Phi^2)^(1/2)*x);
 

`+`(`*`(c[1], `*`(cosh(`*`(`^`(`+`(s, `*`(`^`(Phi, 2))), `/`(1, 2)), `*`(x))))), `*`(c[2], `*`(sinh(`*`(`^`(`+`(s, `*`(`^`(Phi, 2))), `/`(1, 2)), `*`(x)))))) (9)
 

> eq0:=eval(subs(x=0,bc1)):
 

> eq1:=eval(subs(x=1,bc2)):
 

> con:=solve({eq0,eq1},{c[1],c[2]}):
 

> U(x):=subs(con,U(x));
 

`+`(`/`(`*`(cosh(`*`(`^`(`+`(s, `*`(`^`(Phi, 2))), `/`(1, 2)), `*`(x)))), `*`(s)), `-`(`/`(`*`(sinh(`*`(`^`(`+`(s, `*`(`^`(Phi, 2))), `/`(1, 2)))), `*`(sinh(`*`(`^`(`+`(s, `*`(`^`(Phi, 2))), `/`(1, 2)... (10)
 

> U(x):=combine(simplify(U(x))):
 

The shifting theorem is used to find the inverse Laplace transform(1) as: L-1F(s)=exp(-Φ2t)L=1F(s-Φ2). 

> U(x):=factor(U(x));
 

`/`(`*`(cosh(`*`(`^`(`+`(s, `*`(`^`(Phi, 2))), `/`(1, 2)), `*`(`+`(x, `-`(1)))))), `*`(cosh(`*`(`^`(`+`(s, `*`(`^`(Phi, 2))), `/`(1, 2)))), `*`(s))) (11)
 

> U1(x):=subs(s=s-Phi^2,U(x));
 

`/`(`*`(cosh(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(1)))))), `*`(cosh(`*`(`^`(s, `/`(1, 2)))), `*`(`+`(s, `-`(`*`(`^`(Phi, 2))))))) (12)
 

> P(s):=numer(U1(x));
 

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

> Q(s):=denom(U1(x));
 

`*`(cosh(`*`(`^`(s, `/`(1, 2)))), `*`(`+`(`-`(s), `*`(`^`(Phi, 2))))) (14)
 

> A(s):=P(s)/diff(Q(s),s);
 

`+`(`-`(`/`(`*`(cosh(`*`(`^`(s, `/`(1, 2)), `*`(`+`(x, `-`(1)))))), `*`(`+`(`/`(`*`(`/`(1, 2), `*`(sinh(`*`(`^`(s, `/`(1, 2)))), `*`(`+`(`-`(s), `*`(`^`(Phi, 2)))))), `*`(`^`(s, `/`(1, 2)))), `-`(cosh... (15)
 

> solve(Q(s),s);
 

`+`(`-`(`*`(`/`(1, 4), `*`(`^`(Pi, 2))))), `*`(`^`(Phi, 2)) (16)
 

> _EnvAllSolutions := true:
 

> solve(Q(s),s):
 

The roots are: 

> Phi^2,-((2*n-1)*Pi/2)^2;
 

`*`(`^`(Phi, 2)), `+`(`-`(`*`(`/`(1, 4), `*`(`^`(`+`(`*`(2, `*`(n)), `-`(1)), 2), `*`(`^`(Pi, 2)))))) (17)
 

> A[n]:=simplify(subs(s=mu,A(s)));
 

`+`(`-`(`/`(`*`(2, `*`(cosh(`*`(`^`(mu, `/`(1, 2)), `*`(`+`(x, `-`(1))))), `*`(`^`(mu, `/`(1, 2))))), `*`(`+`(`-`(`*`(sinh(`*`(`^`(mu, `/`(1, 2)))), `*`(mu))), `*`(sinh(`*`(`^`(mu, `/`(1, 2)))), `*`(`... (18)
 

> A[0]:=subs(mu^(1/2)=Phi,mu=Phi^2,A[n]):
 

> A[0]:=simplify(A[0]);
 

`/`(`*`(cosh(`*`(Phi, `*`(`+`(x, `-`(1)))))), `*`(cosh(Phi))) (19)
 

> A[n]:=simplify(subs(mu^(1/2)=I*(2*n-1)/2*Pi,mu=-((2*n-1)*Pi/2)^2,A[n])):
 

> vars:={cos(1/2*(2*n-1)*Pi)=0,sin(1/2*(2*n-1)*Pi)=(-1)^(n-1)}:
 

> A[n]:=simplify(subs(vars,A[n]));
 

`+`(`/`(`*`(4, `*`(`^`(-1, `+`(`-`(n))), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(cos(`+`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(`+`(x, `-`(1))))))))))))), `*`(`+`(`*`(4, `*`(... (20)
 

> u0s:=A[0]*subs(mu=Phi^2,1/(s-mu));
 

`/`(`*`(cosh(`*`(Phi, `*`(`+`(x, `-`(1)))))), `*`(cosh(Phi), `*`(`+`(s, `-`(`*`(`^`(Phi, 2))))))) (21)
 

> u0t:=invlaplace(u0s,s,t);
 

`/`(`*`(cosh(`*`(Phi, `*`(`+`(x, `-`(1))))), `*`(exp(`*`(`^`(Phi, 2), `*`(t))))), `*`(cosh(Phi))) (22)
 

> uns:=A[n]/(s-mu);
 

`+`(`/`(`*`(4, `*`(`^`(-1, `+`(`-`(n))), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(cos(`+`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(`+`(x, `-`(1))))))))))))), `*`(`+`(`*`(4, `*`(... (23)
 

> unt:=invlaplace(uns,s,t);
 

`+`(`/`(`*`(4, `*`(`^`(-1, `+`(`-`(n))), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(cos(`+`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(`+`(x, `-`(1)))))))), `*`(exp(`*`(mu, `*`(t)))... (24)
 

> unt:=subs(mu=-((2*n-1)/2*Pi)^2,unt);
 

`+`(`/`(`*`(4, `*`(`^`(-1, `+`(`-`(n))), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(cos(`+`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(`+`(x, `-`(1)))))))), `*`(exp(`+`(`-`(`*`(`/`(... (25)
 

The time domain solution is obtained by multiplying the inverse Laplace transform of U1(x) by exp(-Φ2t): 

> U:=simplify(u0t*exp(-Phi^2*t))+Sum(unt,n=1..infinity)*exp(-Phi^2*t);
 

`+`(`/`(`*`(cosh(`*`(Phi, `*`(`+`(x, `-`(1)))))), `*`(cosh(Phi))), `*`(Sum(`+`(`/`(`*`(4, `*`(`^`(-1, `+`(`-`(n))), `*`(`+`(`*`(2, `*`(n)), `-`(1)), `*`(Pi, `*`(cos(`+`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `... (26)
 

> u:=piecewise(t=0,0,t>0,subs(infinity=20,U)):
 

The following plots are obtained: 

> plot3d(subs(Phi=1,u),x=1..0,t=0.5..0,axes=boxed,title="Figure Exp. 8.15.",labels=[x,t,"u"],orientation=[-45,60]);
 

Plot
 

>
 

The solution obtained matches the separation of variables solution obtained in example 7.8.