16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

226 CHAPTER 5. LINEAR PDE MODELS. PART 1<br />

The complete series solution is T = P1 n=1 Tn, withtheformofAnto be determined<br />

from the initial condition. At t = 0, one must have<br />

1X<br />

T (x; 0) = An sin(n¼x)=100x (1 ¡ x):<br />

n=1<br />

If T (x; 0) is multiplied by sin(m¼x) and integrated from x =0tox = L =1,<br />

the lhs will integrate to zero for every term in the series except for the term<br />

corresponding to m = n. This is a result of the independence, or orthogonality,<br />

of the sine terms in the series. The resulting equation can then be solved for<br />

An. Russell will now apply this approach. He evaluates Tn at t =0,andenters<br />

the initial temperature pro¯le, T0 .<br />

> X:=eval(T[n],t=0); T0:=100*x*(1-x);<br />

X := An sin(n¼x) T0 := 100 x (1 ¡ x)<br />

Since only the nth term in the series survives, Russell forms T0 ¡ X, multiplies<br />

this by sin(n¼x), and integrates from x =0to1ineq.Theneq is set equal to<br />

zero and solved for An.<br />

> eq:=int((T0-X)*sin(n*Pi*x),x=0..1);<br />

> A[n]:=solve(eq=0,A[n]);<br />

200 (¡2+n¼sin(n¼)+2cos(n¼))<br />

An := ¡<br />

n2 ¼2 (n¼¡ sin(n¼)cos(n¼))<br />

Assuming that n is an integer, the nth Fourier term Tn is simpli¯ed, An having<br />

been automatically substituted. The double colon in assuming is a \type<br />

match" command.<br />

> T[n]:=simplify(T[n]) assuming n::integer;<br />

Tn := ¡ 400 (¡1+(¡1)n ) e (¡n2 ¼ 2 t) sin(n¼x)<br />

n3 ¼3 Thus, the temperature distribution in the rod satisfying the boundary and<br />

initial conditions is given by the following in¯nite Fourier series:<br />

> Temp:=Sum(T[n],n=1..infinity);<br />

1X<br />

Ã<br />

Temp := ¡ 400 (¡1+(¡1)n ) e (¡n2 ¼ 2 t) sin(n¼x)<br />

n3 ¼3 !<br />

n=1<br />

The sum of the ¯rst ¯ve terms gives a good approximation to T (x; t), because<br />

the contribution of higher-order terms drops very rapidly with increasing time.<br />

> TT:=sum(T[n],n=1..5);<br />

TT := 800 e(¡¼2 t) sin(¼x)<br />

¼3 + 800 e<br />

27<br />

(¡9 ¼2 t) sin(3 ¼x)<br />

¼3 + 32 e<br />

5<br />

(¡25 ¼2 t) sin(5 ¼x)<br />

¼3 Then TT is animated so its spatial and temporal evolution can be clearly seen.<br />

> animate(plot,[TT,x=0..1],t=0..1,frames=50);<br />

Russell is feeling sleepy, so is going back to bed. If you wish to see how the<br />

initial parabolic temperature pro¯le decays to zero everywhere inside the rod,<br />

execute the work sheet, click on the plot, and then on the play arrow.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!