Вы находитесь на странице: 1из 5

CS4MN3 April 2002

Page 1

Name

Student Number

Instructor: S. Qiao

COMP SCI 4MN3

Day Class Duration of examination: Two hours McMaster University Final Examination

April 2002

This examination paper includes 5 pages and 7 questions. You are responsible for ensuring that your copy of the paper is complete. Bring any discrepancy to the attention of your invigilator.

SPECIAL INSTRUCTIONS: This paper must be returned with your answers. Use of any calculator is allowed.

1. (2 marks) What is the unit of roundoff in a computer number system where β = 10, p = 5,

e min = 48, e max = 49?

0.5 × 10 4 .

(4 = p 1)

2. (3 marks) Rewrite the following row version of an upper triangular solver (backward substitu-

tion) into a column version.

% an

Given

upper

triangular

matrix

U

and

a

right

hand

side

b,

% program

this

solves

the

upper

triangular

system

U*x

=

b

and

% overwrites

b

with

the

solution

x.

n

=

length(b);

 

for

j=n:-1:2

 
 

b(j)

=

b(j)/U(j,j);

 

b(j-1)

=

b(j-1)

-

U(j-1,j:n)*b(j:n);

end

 

b(1)

=

b(1)/U(1,1);

 

n

=

length(b);

 

for

j=n:-1:2

 
 

b(j)

=

b(j)/U(j,j);

 

b(1:j-1)

=

b(1:j-1)

-

b(j)*U(1:j-1,j);

end

 

b(1)

=

b(1)/U(1,1);

 

(continued on page 2)

CS4MN3 April 2002

Page 2

3. (8 marks) Given the matrix

A =

3

10

5

2

7

1

6

0

5

,

compute vector p and matrices L and U in the LU decomposition of A using Gaussian elimination with partial pivoting, where p is the permutation vector, L is an elementary lower triangular matrix, and U is an upper triangular matrix. Matrix A should be overwritten by L and U . Assume the base β = 10 and the precision p = 4. Show the steps.

Step 1

pivot row:

2, after updating

Step 2

pivot row:

3, after updating

The permutation matrix


10

0.3

0.5

10

0.5

0.3

P

=

7

0.1

2.5

7

2.5

0.04

0

0

1

1

0

0

0

6

5


0

5

6.2

0

1

0

(continued on page 3)

CS4MN3 April 2002

Page 3

4. (5 marks) Consider the initial value problem

y = y

for t 0, with initial values y(0) = 1 and y (0) = 2.

(a) Express this second-order ODE as an equivalent system of two first-order ODEs.

Let u 1 (t) = y(t) and u 2 (t) = y (t), then we get a system of first order ODEs

u 1 (t)

=

u 2 (t)

u 2 (t)

=

u 1 (t)

(b) What are the corresponding initial conditions for the system of ODEs in part a?

The initial values:

u 1 (0)

=

1

u 2 (0)

=

2

(c) Perform one step of Euler’s method for this ODE system using a stepsize of h = 0.5.

One step of Euler’s method with h = 0.5

u(0.5) =

1

2

+ 0.5

2

1

=

2

2.5

(continued on page 4)

CS4MN3 April 2002

Page 4

5. (2 marks) Suppose you want to annihilate the second component of a vector

a =

a

a


1

2

using a Givens rotation, but a 1 is already zero. Is it still possible to annihilate a 2 with a Givens rotation? If so, specify an appropriate Givens rotation; if not explain why.

Yes, the Given rotation is:

G =

0

1

1

0

.

6. (3 marks) Suppose you want to find a zero of a nonlinear function of one variable: f (x) = 0.

For each convergence rate given, name a method that normally has that convergence rate for this problem:

(a)

Linear but not superlinear

(b)

Superlinear but not quadratic

(c)

Quadratic

(a)

Bisection

(b)

Secant

(c)

Newton’s

(continued on page 5)

CS4MN3 April 2002

Page 5

7. (4 marks) On a computer with no functional unit for floating-point division, one might instead use multiplication by the reciprocal of the divisor. Apply Newton’s method to produce an iterative scheme for approximating the reciprocal of a number a > 0. Considering the intended application,

your solution should not contain any divisions except divisions by 2. (Hint: Apply the idea behind the Newton’s method for computing square root.)

(a)

Develop an iterative scheme using Newton’s method.

(b)

Find an intial x 0 .

(a) Construct a function f (x) such that f (1/a) = 0: f (x) = 1/x a. Then f (x) = 1/x 2 . The

Newton’s iteration:

x + = x

f(x)

(x) = x(2 ax)

f

(b) First, a is scaled so that 1.0 a < 2.0. Linearly interpolate (a, 1/a) at points (1.0, 1.0) and

(2.0, 0.5), we get the initial guess

x 0 = (3 a)/2

END!