Information Technology Reference
In-Depth Information
7.7.3
Analyzing Discrete Solutions
We consider the problem solved by Algorithm 7.1 . One can show 20 that the fol-
lowing discrete function is an exact analytical solution of the computations in
Algorithm 7.1 :
D A 1 4t
x 2
` sin .k.i 1/x/ :
kx
2
u i
sin 2
(7.150)
The parameters A and k are constants that can be freely chosen.
(a) Insert the expression (7.150) in the finite difference scheme in Algorithm 7.1
and show that it fulfills this discrete equation. Check also that the bound-
ary conditions u 1 D u n D 0 are fulfilled. What is the corresponding initial
condition?
The present diffusion problem, where we have a mathematical expression for
the numerical solution, is ideal for testing the correctness of a program imple-
menting Algorithm 7.1 : We write out u i
and check that it coincides with the
solution (7.150) to machine precision, regardless of what x is (but recall that
˛ 0:5).
(b) We have exact mathematical solutions of the PDE and the finite difference
scheme given by the expressions (7.148)and(7.150), respectively. Comparing
these two solutions, we see that both are of the form
u .x i ;t ` / D A ` sin.k.i 1/x/;
with
D PDE e 2 k 2 t
in the PDE case and
D 1 4t
x 2
kx
2
sin 2
in the discrete case. The error in the numerical solution is therefore contained in
the difference e D PDE :
e.k; x; t/ D e 2 k 2 t 1 C 4t
x 2
kx
2
sin 2
:
Find Taylor series expansions of the functions e y and sin 2 y, and use these
power expansions in the expressions for e. Explain that the largest (so-called
20 The derivation is, in principle, quite simple. Both the PDE and the finite difference scheme
allow solutions of the form u .x; t /
A ` sin.kx/,where` counts time levels, and A, ,andk are
parameters to be adjusted by inserting the expression in the PDE or the finite difference scheme.
D
 
Search WWH ::




Custom Search