0% found this document useful (0 votes)
21 views14 pages

Tutorial Letter 20322012

This tutorial letter provides essential information for students preparing for the Numerical Analysis II examination, including solutions to a previous exam paper and guidelines for study. Key topics include various numerical methods such as the Taylor Method, Runge-Kutta Methods, and the Shooting Method, along with their applications. Students are advised to familiarize themselves with the course syllabus and specific iteration formulae to enhance their exam readiness.

Uploaded by

Wikus Sanders
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views14 pages

Tutorial Letter 20322012

This tutorial letter provides essential information for students preparing for the Numerical Analysis II examination, including solutions to a previous exam paper and guidelines for study. Key topics include various numerical methods such as the Taylor Method, Runge-Kutta Methods, and the Shooting Method, along with their applications. Students are advised to familiarize themselves with the course syllabus and specific iteration formulae to enhance their exam readiness.

Uploaded by

Wikus Sanders
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

APM3711/203/2/2012

Tutorial Letter 203/2/2012


Numerical Analysis II
APM3711
Semester 2

Department of Mathematical Sciences

IMPORTANT INFORMATION:
This tutorial letter contains important
information about your module.

Learn without limits. university


of south africa
Dear Student,

This tutorial letter intends to help you prepare for the examination. It contains the following infor-
mation:

1. Solutions to a previous examination paper - Semester 1.

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.

Fourth and …fth order Runge–Kutta


Adams
Milne
The Chebyshev polynomials

(c) Make sure that you study the following methods.

1) The Taylor Method


2) The Runge–Kutta–Methods
3) The Milne & Adams–Moulton–Methods
4) The Euler Method
5) The Shooting–Method
6) The A.D.I.–Method
7) Chebyshev–series
8) Power Method

2. SOLUTIONS TO A PREVIOUS EXAMINATION PAPER

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)

(b) Euler’s method is used to solve a …rst-order di¤erential equation

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:

(i) halving the step size at the end of each interval;


(ii) using two Runge-Kutta methods with di¤erent orders.

Which method is more e¢ cient? Why? (8)

(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

n = 1 t1 = 0:0 y1 = 0:95 f1 = 0:95


n = 2 t2 = 0:2 y2 = 0:68 f2 = 0:88
n = 3 t3 = 0:4 y3 = 0:55 f3 = 0:95
n = 4 t4 = 0:6 y4 = 0:30 f4 = 0:9

At t = 0:8; the predictor is


0:2
y5 = y4 + (55f4 59f3 + 37f2 9f1 )
24
0:2
= 0:3 + (55 (0:9) 59 (0:95) + 37 (0:88) 9 (0:95))
24

= 0:4455; f5 = 1:2455

and the corrector is


h
y5 = y4 + (9f5 + 19f4 5f3 + f2 )
24
0:2
= y4 + (9 (1:2455) + 19 (0:9) 5 (0:95) + 0:88)
24

= 0:5037; f5 = 1:3037:

At t = 1:0; the predictor is:


0:2
y6 = y5 + (55f5 59f4 + 37f3 9f2 )
24
0:2
= 0:5037 + (55 (1:3037) 59 (0:9) + 37 (0:95) 9 (0:881))
24

= 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

(a) Consider the boundary value problem

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

(a) The boundary value problem is

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

y (2) = y(1) + 1 z(1) = 1 + 0 = 1


z (2) = z(1) + 1 (y(1) + 1) = 0 + (1 + 1) = 2

y (3) = y(2) + 1 z(2) = 1 + 2 = 3

[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

y (2) = 1 0:5 = 0:5


z (2) = 0:5 + (1 + 1) = 1:5

y (3) = 0:5 + 1:5 = 2

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:

[Typical mistakes made were:


Using the modi…ed Euler method rather than the Euler method.
Using the Euler method incorrectly, for instance by trying to apply it directly to the
equation y 00 = y + x.
Trying to use direct mathematical methods to change the second–order equation y 00 =
y + x into a …rst–order one, for instance by trying to integrate the right hand side. A
word of warning about this kind of approach: Don’t do it! This is a numerical analysis
course, and none of the methods require us to do mathematical manipulation of the
equations to solve them halfway before applying the numerical methods. (The only
exception of a sort is the Taylor method where you may need to do some di¤erentiation
to …nd the higher derivatives.) So when you see a second or higher order di¤erential
equation, rather convert it to a …rst–order one by the standard method of introducing
new variables for the derivatives of the original variable. This standard approach has
the bene…t that it works every time and does not depend on the di¤erential equation
being particularly nice so that direct mathematical methods can be applied. It is true that
sometimes mathematical tricks can be used to simplify the calculations in the numerical
method, but you should only attempt this if you are absolutely sure that you know what
you are doing.]
(b)
shooting method …nite di¤erences method

+ certain to give a solution, less computational e¤ort


even in the non–linear (especially for higher–order
case systems)

more computational e¤or t may not converge (if the equation


is non–linear, and the initial estimate
is not good)

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)

(b) The matrix


2 2
A=
1 1
has an eigenvalue near 2:5 and another one near +1: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

The eigenvalue is approximately = 37 :


[I have done the calculations with fractions, but you are welcome to do the calculations
with decimal numbers instead. The end result with decimals is = 2:33:]
(ii) In shifting, we consider the matrix B = A sI where s is a suitably chosen number.
Then then eigenvalues of B are 1 s and 2 s if 1 and 2 were the eigenvalues of
matrix A: The power method requires fewer iterations if the magnitude of the largest
eigenvalue is not too close to the magnitude of the second–largest one. The values
j2:5j and j1:5j are fairly close to each other. To accelerate convergence, we could for
instance shift by the value s = 2: The eigenvalues of B would then be

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

(b) The equation


@2u @2u
+ =0
@x2 @y 2
is to be solved in a rectangular region. The grid (with x = y = 1), the boundary values and
the numbering of the node points are indicated in the sketch below.

(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

[Remember to replace x; y and z also by xi ; yj and zk ! The di¤erence equation always


approximates the di¤erential equation at some grid point (xi ; yj ; zk ) ; so all terms must
be consistently evaluated at that same point! ]
(ii)

(k+1) 1 (k) (k) (k) (k) (k) (k)


ui;j;k = ui+1;j;k + ui 1;j;k + ui;j+1;k + ui;j 1;k + ui;j;k+1 + ui;j;k 1 + h2 xi yj zk
6 h2
or
(k+1) 1 (k) (k) (k) (k) (k) (k)
ui;j;k = ui+1;j;k + ui 1;j;k + ui;j+1;k + ui;j 1;k + ui;j;k+1 + ui;j;k 1 + h2 xi yj zk + h2 ui;j;k
6
[This is the Gauss–Seidel type approach; the alternative is to use a Jacobi method where
on the right hand side, updated information is used when necessary, so that for instance
(k+1) (k+1) (k+1) (k) (k) (k)
we might use ui 1;j;k ; ui;j 1;k and ui;j;k 1 instead of ui 1;j;k ; ui;j 1;k and ui;j;k 1 . Either
one will give you full marks.]

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)

(b) Given the power series


f (x) = 1 x 2x3 4x4

12
APM3711/203

and the Chebyshev polynomials

T0 (x) = 1
T1 (x) = x
T2 (x) = 2x2 1
T3 (x) = 4x3 + 3x
T4 (x) = 8x4 8x2 + 1;

economize the power series f (x) twice. (6)


(c) Find the Padé approximation R3(x); with numerator of degree 2 and denominator of degree 1,
to the function f (x) = x2 + x3 : (7)

[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

Hence the Padé approximation is

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

You might also like