Tutorial Letter 20322012
Tutorial Letter 20322012
IMPORTANT INFORMATION:
This tutorial letter contains important
information about your module.
This tutorial letter intends to help you prepare for the examination. It contains the following infor-
mation:
We give here a few guidelines which may be helpful in your preparation for the Oct/Nov 2012 exam-
ination.
This semester’s examination will again have 6 questions.
(a) Use your tutorial letter 101 and the course outline that was put on myUnisa to make sure that
you know what does the syllabus cover.
(b) It is necessary to know the iteration formulae of the following methods.
In the following, we will give …rst the question in the form it appeared in the examination paper, and
then the solution to it. My comments appear in square brackets, in italics; they do not form a part
of the solution.
QUESTION 1
(a) Use the second-order Taylor method to …nd y(1:1) when y is the solution to the di¤erential
equation
dy
= xy + 1; y(1) = 2:
dx
2
APM3711/203
(6)
dy
= f (y; x)
dx
from x = 0 to x = 4:
(i) If the step length is h = x = 0:1; we get an error of 0:12 for y(4): What step length should
we use to reduce the error for y(4) to 0:01?
(ii) How would this change in the step size in‡uence the local error? (8)
(c) Explain brie‡y why the modi…ed Euler method is more accurate than the Euler method. (2)
[16]
SOLUTION
(a) We have
dy
y0 = = f (x; y) = xy + 1; y (1) = 2;
dx
@
y 00 = f (x; y) = y + xy 0
@x
So y 0 (1) = 1 2 + 1 = 3; y 00 (1) = 2 + 1 3 = 5 and therefore the Taylor method gives
1
y (1:1) y (1) + (0:1) y 0 (1) + (0:1)2 y 00 (1)
2
1
= 2 + (0:1) 3 + (0:01) 5
2
= 2:325:
(b) (i) With h1 = 0:1; we got as global error of y (4) the value E1 = 0:12: What should h2 be
for us to get the global error E2 = 0:01?
Since Euler’s method is a …rst–order method, then the global error E when using a
step size h is given by
jEj = K h:
This means that the equation
jE1 j h1
=
jE2 j h2
must hold for the errors E1 ; E2 when using two di¤erent step sizes h1 and h2 : Thus,
we should select h2 as
E2 0:01
h2 = h1 = (0:1) = 0:0083:
E1 0:12
3
(ii) The local error in the Euler method is of the order O (h2 ) ; so since the new step size is
0:12
= 12
0:01
times smaller, we expect the one–step error to be (12)2 = 144 times smaller.
(c) Euler method uses only the slope at the initial point of the interval, whereas the modi…ed
Euler method attempts to use the slope values at the initial and …nal points.
[Note that it really is not enough here to reply ”Because Euler method is …rst–order and
modi…ed Euler method is second–order method”!]
QUESTION 2
(a) (i) Why is a Runge-Kutta method usually preferred to a Taylor series method of the same
order?
(ii) Is there an upper limit to the order of a Runge-Kutta method? Justify your answer! (4)
(b) Explain brie‡y how the accuracy of a Runge-Kutta method can be determined by:
(c) The predictor and corrector formulas of the Adams-Moulton method are:
h 251 5 (5)
yn+1 = yn + (55fn 59fn 1 + 37fn 2 9fn 3 ) + h y ( 1)
24 720
h 19 5 (5)
yn+1 = yn + (9fn+1 + 19fn 5fn 1 + fn 2 ) h y ( 2 ):
24 720
Apply the Adams-Moulton method to calculate the approximate value of y(0:8) and y(1:0) from
the di¤erential equation
y0 = t + y
and the starting values
t y(t)
0:0 0:95
0:2 0:68
0:4 0:55
0:6 0:30
Use 3 decimal digits with rounding at each step. (8)
[20]
4
APM3711/203
SOLUTION
(a) (i) One does not have to …nd the derivatives. [It is not true that the Runge–Kutta methods
are more accurate.]
(ii) No. An n–th order Runge–Kutta method is equivalent to an n–th order Taylor series
method, and the value of n can be arbitrarily large in the Taylor series.
(b) (i) We can recompute the solution value at the end of the interval with two steps of half
the step length, and compare the results.
(ii) We can do the calculations using two di¤erent methods (e.g. a 4th and 5th order one)
and compare the end results.
Method (ii) is more e¢ cient by since by selecting the methods suitably, we can use the
same k–values in both methods, and therefore need less function evaluations.
(c) y 0 = t + y = f (t:y): The given starting values are
= 0:4455; f5 = 1:2455
= 0:5037; f5 = 1:3037:
= 0:8856; f6 = 1:8856
5
and the corrector is:
h
y6 = y5 + (9f6 + 19f5 5f4 + f3 )
24
0:2
y6 = 0:5037 + (9 (1:8856) + 19 (1:3037) 5 (0:9) + 0:95)
24
= 0:822:
QUESTION 3
y 00 = y + x
y(1) = 1; y(3) = 2:
Solve this system over the interval 1 x 3 by using the shooting method. Use the Euler
method with x = 1: (8)
(b) Compare brie‡y the shooting method and the method of …nite di¤erences in solving boundary
value problems, by stating the main advantages and the main disadvantages of each method.(4)
[12]
SOLUTION
y 00 = y + x
y (1) = 1; y (3) = 2
We must …rst convert the second–order di¤erential equation into a system of two …rst–order
equations, by introducing a new variable, z = y 0 : This gives us the system
y0 = z y (1) = 1 y (3) = 2
(1)
z0 = y + x z (1) =?
[The reason for this conversion is that the Euler method is a method for solving …rst–order
di¤erential equation, or systems of …rst–order di¤erential equations. It can not be used
directly to solve a second–order di¤erential equation!]
To apply the Euler method, we need the value of z (1) : Since this value is not known, we
will make a guess at its value and see how close the obtained y (3)–value is to the required
value D = 2:
6
APM3711/203
Let us take as the …rst guess G1 = 0 and solve the system (1) with z (1) = G1 = 0: The
calculations are:
y (1) = 1
z (1) = 0
[Note the order of calculations: we need to …nd both y (2) and z (2) before we can calculate
y (3)! We don’t need to …nd z (3) :]
The value obtained for y (3) was R1 = 3; which is not equal to the required value D = 2:
Therefore, we must make another guess; let us take G2 = 1: With z (1) = G2 = 1; the
calculations are
y (1) = 1
z (1) = 1
y (2) = 1 1 = 0
z (2) = 1 + (1 + 1) = 1
y (3) = 0 + 1 = 1
Here we obtained a value R2 = 1 for y (3), but again it is not equal to D = 2; and therefore
we need another guess. This time, since we have available for us the results of two guesses
we use the technique of interpolation to make a better guess. The interpolation formula is
G3 G1 G2 G1
=
D R1 R2 R1
where G3 is the next guess; we therefore get
G2 G1
G3 = G1 + (D R1)
R2 R1
so the value of the next guess is
1 0
G3 = 0 + (2 3) = 0:5:
1 3
7
With z (1) = G3 = 0:5; the calculations are
y (1) = 1
z (1) = 0:5
We see that the third guess leads to the correct value of y (3) :
[The di¤erential equation here is linear, so we know that only one interpolation is needed!
For a non–linear equation, we might need to keep interpolating and making new guesses
until y (3) is within a given tolerance of the correct value 2:]
The approximate solution to the boundary value problem is therefore
y (1) = 1; y (2) = 0:5; y (3) = 2:
8
APM3711/203
QUESTION 4
(a) Explain why the numerical solution of a characteristic value problem of the type
u00 + f (x)u0 + k 2 u = 0; u(0) = 0; u(1) = 0
by the method of …nite di¤erences, leads to an eigenvalue problem. Here, f (x) is an arbitrary
function of x: (5)
(i) Use the power method to …nd the eigenvalue near 2:5: Do three iterations, starting with
the vector (1; 0)> .
(ii) Explain how you can use suitable shifting with the power method to …nd the eigenvalue
near 2:5 with fewer iterations, without having to …nd the inverse of any matrix. (9)
[14]
SOLUTION
(a) Characteristic value problem:
u00 + f (x) u0 + k 2 u = 0; u (0) = 0; u (1) = 0:
[This problem has the trivial solution u 0: For certain values of w; called characteristic
values, it may also have non–trivial solutions. “Solving” the characteristic value problem
consists of …nding these characteristic values, and usually …nding the corresponding solu-
tions as well.]
Let us assume that the grid points are ti and let ui be the approximation for u (ti ) : Sub-
stituting …nite di¤erence approximations for the derivatives u00 and u0 leads to a linear set
of equations for the ui : This set of equations can be written in the matrix equation form
A bk 2 I u = 0
for some matrix A and a real number b 2 R; where u is the vector of the ui –values.
[Here the di¤erence equation will be
h h
1 + f (xi ) ui+1 + h2 k 2 2 ui + 1 f (xi ) u0i 1 =0
2 2
so in fact b = h2 :]
Finding the values of k 2 such that a non–trivial solution vector u exists is therefore equiv-
alent to the problem of …nding the eigenvalues of A; with the corresponding eigenvectors
giving the non–trivial approximate solutions.
[It is not true that we are “using the eigenvalues to solve the equations”! Please do also
use mathematically correct language: It is incorrect to say that “we solve the matrix” or
that “the set of equations can be written as a matrix”!]
9
(b) Matrix
2 2
A= ;
1 1
with one eigenvalue near 2:5; another one near +1:5:
(i) The eigenvalue near 2:5 has the largest magnitude, so we can …nd it by applying the
power method to the matrix A:
2 2 1 2 1
= = 2 1
1 1 0 1 2
2 2 1 3 1
1 = 1 = 3 1
1 1 2 2 6
7 7
2 2 1 5
1
1 = 5 = 5 :
1 1 6 6 3 14
2:5 2= 4:5
and
1:5 2= 0:5;
and in this case the larger one is much larger than the smaller one and therefore
convergence will be faster.
QUESTION 5
(a) (i) Write down the …nite di¤erence equation corresponding to the three-dimensional partial
di¤erential equation
@2u @2u @2u
+ + + u + xyz = 0
@x2 @y 2 @z 2
at the grid point (xi ; yj ; zk ) of a rectangular mesh with x = y = z = h: Denote
u(xi ; yj ; zk ) by ui;j;k : (6)
(ii) Re-write the di¤erence equation in (i) into an iteration formula appropriate for Liebmann’s
method. Use the superscripts uk ; uk+1 to show how new values are computed from previous
ones. (7)
10
APM3711/203
(i) Set up the two sets of equations for solving the values of u at the four node points by the
ADI method. Use the notation of the sketch, with function values denoted by ui in rowwise
traverse and by vi in columnwise traverse.
(ii) Explain how you would proceed to solve the problem by using the ADI method. (14)
[21]
SOLUTION
(a) (i)
ui+1;j;k 2ui;j:k + ui 1;j;k ui;j+1;k 2ui;j;k + ui;j 1;k ui;j;k+1 2ui;j;k + ui;j;k 1
+ +
h2 h2 h2
+xi yj zk + uijk = 0
11
(b) (i) Row–wise: We apply the equation
uL 2u0 + uR = vA + 2v0 vB
at the nodes u1 ; u2 ; u3 ; u4 :
8
>
> 1 2u1 + u2 = 1 + 2v1 v2
<
u1 2u2 + 3 = 1 + 2v3 v4
>
> 1 2u3 + u4 = v1 + 2v2 = 0
:
u3 2u4 + 3 = v3 + 2v4 0
0 10 1 0 1
2 1 0 0 u1 2v1 v2 2
B 1 2 0 0 C B u2 C B 2v3 v4 4 C
)B
@
CB C=B C (*)
0 0 2 1 A @ u3 A @ v1 + 2v2 1 A
0 0 1 2 u4 v3 + 2v4 3
Column–wise: We apply the equation
vA 2v0 + vB = uL + 2u0 uR
at the nodes v1 ; v2 ; v3 ; v4 :
8
>
> 1 2v1 + v2 = 1 + 2u1 u2
<
v1 2v2 + 0 = 1 + 2u3 u4
>
> 1 2v3 + v4 = u1 + 2u2 3
:
v3 2u4 + 0 = u3 + 2u4 3
0 10 1 0 1
2 1 0 0 v1 2u1 u2 2
B 1 2 0 C B
0 C B v2 C B 2u3 u4 1 C
)B
@
C=B C (**)
0 0 2 1 A @ v3 A @ u1 + 2u2 4 A
0 0 1 2 v4 u3 + 2u4 3
(ii) –Start with a …rst guess at v = v 0 (the vector (v10 ; v20 ; v30 ; v40 ))
–Repeat:
1) solve ui from (*) using v i 1 on right–hand side
2) solve v i from (**) using ui on right–hand side
until the change v i v i 1 is less than some given tolerance.
[Note that in (b)(i), you must write down the equation for this particular problem! It
is not enough to just state the general equations.]
QUESTION 6
(a) The function ex is to be approximated by a …fth-order polynomial over the interval [ 1; +1]:
Why is a Chebyshev series a better choice than a Taylor (or Maclaurin) expansion? (4)
12
APM3711/203
T0 (x) = 1
T1 (x) = x
T2 (x) = 2x2 1
T3 (x) = 4x3 + 3x
T4 (x) = 8x4 8x2 + 1;
[17]
SOLUTION
(a) The maximum error over the whole interval is smaller. The Taylor series has zero error at
x = 0; but the error can be quite large at x = 1:
(b)
f (x) = 1 x 2x3 4x4
Economize once: we add/subtract T4 suitably scaled, such that the x4 –term disappears.
Here, we must add 12 T4 = 4x4 4x2 + 21 ; and will get the economized series
1
f (x) = f (x) + T4
2
3
= x 4x2 2x3 :
2
Economize again: Add T3 suitably scaled, such that the x3 –term disappears. We must add
1 3
T3 (x) = 2x3 + x;
2 2
and will get
1
f (x) = f (x) + T3 (x)
2
3 5
= x 4x2 :
2 2
(c) The Padé approximation is
a0 + a1 x + a2 x 2
R (x) = :
1 + b1 x
This gives
a0 + a1 x + a2 x 2
R3 (x) f (x) = x2 + x3
1 + b1 x
which simpli…es to:
a0 + a1 x + a2 x 2 (1 b1 x) x2 + x3
= a0 + a1 x + (a2 1) x2 (1 + b1 ) x3 b1 x4 :
13
To …nd the four unknown values a0 ; a1 ; a3 ; b1 ; we must set the coe¢ cients of x0 ; x1 ; x2 ; x3
in the numerator to zero. This give us the equation
8 8
>
> a 0 = 0 >
> a0 = 0
< <
a1 = 0 a1 = 0
)
>
> a2 1 = 0 >
> a2 = 1
: :
1 + b1 = 0 b1 = 1
x2
R3 (x) = :
1 x
[Remarks:
Note that we should not also set the coe¢ cient of x4 . to zero! To …nd the four coe¢ cients,
we need 4 equations. To add one more equation would either be unnecessary or else lead to
a contradiction.
Please make sure that you can write down the general form of a Padé approximation Rn (x)
with the numerator and/or the denominator of a given degree! Remember that if the numer-
ator (above the line) is of degree n (i.e. a polynomial of degree n) and if the denominator
(below the line) is of degree m; then the Padé approximation is denoted by RN where
N = m + n: The constant term of the denominator (the \b0 " term) is always taken to be
equal to 1; to ensure that RN (0) is well de…ned. The number of constants to be determined
is then equal to N + 1 in the Padé approximation RN (x) : To uniquely determine those
N + 1 constants, we need N + 1 equations which are obtained by setting the coe¢ cients of
the powers of x; of orders 0 to N; to be equal to zero in the numerator of f (x) RN (x) :]
14