Application Center - Maplesoft

App Preview:

Heat Equation, Infinite domain and the Fourier Transform

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

K11.6-Heatnew.mws

>   

>    restart;assume(n,integer):with(plots):with(inttrans):
setoptions(thickness=2): #set the tickness of the lines in the plots

Warning, the name changecoords has been redefined

Introduction

In this worksheet, I use Maple to illustrate Section 11.6 of Kreyszig 's book: Advanced Engineering Mathematics.

Section 1: The Fourier transform

>    alias(u=u(x,t),U=U(k,t)):

>    Eq:=diff(u,t) - c^2*diff(u,`$`(x,2));

Eq := diff(u,t)-c^2*diff(u,`$`(x,2))

Take the Fourier transform in space (that is w.r.t the variable x   ( U = Fourier(u) )

>    Eq2:=subs(fourier(u,x,k)=U,fourier(Eq,x,k));

Eq2 := c^2*k^2*U+diff(U,t)

>    SU:=subs(_F1(k)=F(k),(dsolve(subs(Eq2),U)));

SU := U = F(k)*exp(-c^2*k^2*t)

where F(k) is the fourier transform of the initial profile f(x)

So, the solution is the inverse Fourier transform of U:

>    Su:= u=invfourier(subs(SU,U),k,x);

Su := u = invfourier(F(k)*exp(-c^2*k^2*t),k,x)

With a little computation, we can further simplify this expression to

>    Su:=u=1/sqrt(Pi)*int(f(x+2*c*sqrt(t)*z)*exp(-z^2),z=-infinity..infinity);

Su := u = 1/Pi^(1/2)*int(f(x+2*c*t^(1/2)*z)*exp(-z^2),z = -infinity .. infinity)

This expression gives directly the solution in trems of the original profile. The other solution required the knowledge of F(k), obtained from a Fourier transform and then required an extra inverse Fourier transform.

Let us see some example now:

Section 2: The Gaussian profile: Animation

In this case, we are lucky. We can do the integral exactly!

>    f1:=y->exp(-y^2);assume(t,positive);assume(c,positive);

f1 := proc (y) options operator, arrow; exp(-y^2) end proc

>    plot(f1(y),y=-3..3,thickness=3,color=blue);

[Maple Plot]

>    Su1:=simplify(subs(f=f1,Su));

Su1 := u(x,t) = exp(-x^2/(4*c^2*t+1))/(4*c^2*t+1)^(1/2)

Let us plot and animate this profile (take c = 1/2 )

>    Sol_u:=(x,t)->subs(subs(c=1/2,simplify(Su1)),u);

Sol_u := proc (x, t) options operator, arrow; subs(subs(c = 1/2,simplify(Su1)),u(x,t)) end proc

>    animate(Sol_u(x,t),x=-3..3,t=0..20,color=red,thickness=3,numpoints=60,title="Evolution of a Gaussian profile");

[Maple Plot]

>   

Section 3: A rectangular distribution: Animation

Take a profile equals to one between -1 and 1.

>    f2:=y->Heaviside(y+1)-Heaviside(y-1);

f2 := proc (y) options operator, arrow; Heaviside(y+1)-Heaviside(y-1) end proc

>    plot(f2(y),y=-3..3,thickness=3,color=blue);

[Maple Plot]

>    Sol_u:=subs(c=1/2,simplify(subs(f=f2,c=1/2,Su)),u);

Sol_u := 1/2*erf(x+1)-1/2*erf(x-1)

>    p1:=seq(plot(subs(t=i,Sol_u),x=-10..10,color=black,thickness=2),i=0.001..12):
p2:=seq(plot(subs(t=6*i,Sol_u),x=-40..40,color=black,thickness=2),i=10..20):

>    display([p1],title="Rectangular profile (t=0..12)");
display([p2],title="Rectangular profile (t=60..120)");

[Maple Plot]

[Maple Plot]

>    animate(Sol_u,x=-4..4,t=0.001..2,color=red,thickness=3,numpoints=60,title="Evolution of a rectangular profile");

[Maple Plot]

We observe that the diffusion acts rapidly and smoothes the edge of the rectangle and the profiles evolves very rapidly to a Gaussian profile

Section 4: The triangular profile: Animation

Take a triangular asymmetric profile .

>    f2:=y->(1-y)*(Heaviside(y)-Heaviside(y-1));

f2 := proc (y) options operator, arrow; (1-y)*(Heaviside(y)-Heaviside(y-1)) end proc

>    plot(f2(y),y=-1..1.5,thickness=3);

[Maple Plot]

The exact solution is pretty intricate and we are lucky we have a software to compute it (Give it a try!!)

>    Sol_u:=subs(c=1/2,simplify(subs(f=f2,c=1/2,Su)),u);

Sol_u := -1/2*(x*Pi^(1/2)*erf(x)*exp(x^2)+Pi^(1/2)*erf(x-1)*exp(x^2)-x*Pi^(1/2)*erf(x-1)*exp(x^2)+t^(1/2)-t^(1/2)*exp(2*x-1)-Pi^(1/2)*erf(x)*exp(x^2))/Pi^(1/2)*exp(-x^2)

>    p1:=seq(plot(subs(t=i,Sol_u),x=-10..10,color=black,thickness=2),i=0.001..12):
p2:=seq(plot(subs(t=6*i,Sol_u),x=-40..40,color=black,thickness=2),i=10..20):

>    display([p1],title="Rectangular profile (t=0..12)");
display([p2],title="Rectangular profile (t=60..120)");

[Maple Plot]

[Maple Plot]

>    animate(Sol_u,x=-1..2,t=0.0000000001..2,color=red,thickness=3,numpoints=60,title="Evolution of a asymetric profile");

[Maple Plot]

Here again, observe the rapid smoothing provided by the exp(-z^2)  term in the integral. Rapidly, the solution tends to a Gaussian profile centered around an average value.

 References

E. Kreyszig : Advanced Engineering Mathematics (8th Edition) John Wiley  New York (1999)

Disclaimer:  While every effort has been made to validate the solutions in this worksheet, Waterloo Maple Inc. and the contributors are not responsible for any errors contained and are not liable for any damages resulting from the use of this material.