Information Technology Reference
In-Depth Information
r N
r 0
Tabl e 3. 2
The table shows t , the number of time steps N , and the “ error”
r 0
r N
r 0
t
N
r 0
10 1
10 2
10 16
2:6682
10 2
10 3
1:59986 10 17
10 3
10 4
10 17
3:97982
10 4
10 5
10 15
7:06021
for all n 0.InTable 3.2 we display the relative error defined by
r N
r 0
r 0
:
(3.68)
We observe that the errors listed in Table 3.2 are much smaller than those in
Tab le 3.1 . Hence, we conclude that the Crank-Nicolson scheme generates better
solutions than that of the explicit scheme. In fact, it can be shown that the Crank-
Nicolson scheme produces the exact solution in this case. The errors in Table 3.2
are therefore due to round-off errors in the computations.
3.5
Exercises
Exercise 3.1. Consider the system
F 0
D
.2 S/F; F.0/ D F 0 ;
(3.69)
S 0
D
.F 1/S; S.0/ D S 0 ;
and the numerical scheme
F nC1
D
F n C t.2 S n /F n ;
(3.70)
S nC1
D
S n C t.F n 1/S n :
(a) Write a computer program that implements the scheme ( 3.70 ). The program
should:
Accept S 0 , F 0 ,andt as input.
Compute the numerical solution for t ranging from 0 to 10.
Plot the numerical solution both as a function of t and in the state space (the
F -S coordinate system).
(b) Use your program to determine a value of t such that if you reduce t , you
will not see any difference on your screen. In these computations you may use
F 0 D 1:9, S 0 D 0:1.
 
Search WWH ::




Custom Search