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.

6.3. NUMERICAL SIMULATION OF PDES 279<br />

ical algorithm for the KGE then is<br />

(Ãi+1;j ¡ 2 Ãi;j + Ãi¡1;j)<br />

h 2<br />

¡ (Ãi;j+1 ¡ 2 Ãi;j + Ã i;j¡1)<br />

k 2 = aÃi;j; (6.22)<br />

or, setting r ´ k 2 =h 2 and c ´ 2 ¡ 2 r ¡ k 2 a, and rearranging,<br />

Ãi;j+1 = rÃi¡1;j + cÃi;j + rÃi+1;j ¡ Ãi;j¡1; (6.23)<br />

with j = 1; 2; 3; :::: The mesh points involved in this explicit scheme are<br />

schematically depicted in Figure 6.3.<br />

ψ i,j+1<br />

ψ ψ ψ<br />

i−1,j i,j i+1,j<br />

ψ i,j−1<br />

Figure 6.3: Relevant mesh points for numerically solving the KGE.<br />

In this algorithm, the unknown à value on time step (j +1) depends on<br />

its values on the previous two time steps, j and (j ¡ 1). The second time<br />

row, corresponding to taking j = 1, will be the ¯rst to be calculated. The Ã<br />

values are known along the zeroth time row from the initial condition Ã(xi; 0) =<br />

f(xi). To apply the scheme, the à values along the ¯rst time row must also be<br />

known. These may be determined from the initial transverse velocity. Using<br />

the forward-di®erence approximation, the condition _ Ã(x; 0) = g(x) yields 6<br />

Ãi;1 ¡ Ãi;0<br />

= g(xi);<br />

k<br />

or Ãi;1 ´ G = Ãi;0 + kg(xi): (6.24)<br />

Now Russell programs the explicit scheme (6.23), ¯rst loading the Linear-<br />

<strong>Algebra</strong> package so a matrix approach can be used again.<br />

> restart: with(Linear<strong>Algebra</strong>): begin:=time():<br />

6 In the problem set, Russell will show us a better approximation than this one.

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

Saved successfully!

Ooh no, something went wrong!