Transcript
Page 1: CSC336 Midterm 1 Fall 2011

CSC 336 Midterm Test 22 October 2010.

This is a closed-book test: no books, no notes, no calculators, no phones allowed.

Duration of the test: 50 minutes (11:10 AM to noon).

1. [5 marks]

Consider a floating-point number system with parameters β = 10, p = 3, L = −10 andU = +10 that uses the round-to-nearest rounding rule and allows gradual underflowwith subnormal numbers. That is, the numbers in the system include zero and nonzeronumbers of the form ±d1.d2d3 · 10n where di ∈ {0, 1, 2, . . . , 9} for i = 1, 2, 3 andn ∈ {−10,−9,−8, . . . , 10}. For normalized nonzero numbers, d1 6= 0. For subnormalnonzero numbers, n = −10, d1 = 0 and di 6= 0 for i = 2 or 3. Like the IEEE floating-point number system, this number system also has the two special numbers +Inftyand −Infty which stand for numbers that are too large in magnitude (either positiveor negative, respectively) to represent in this floating-point number system.

In the floating-point number system described above, what is the result of each of thefollowing floating-point arithmetic expressions? Write your answer as a normalizednumber in this floating-point system, if possible, or as a subnormal number in thisfloating-point system in the case of gradual underflow, or as +Infty or −Infty in thecase of overflow.

(a) 6.03 · 107 + 5.04 · 107

(b) 6.21 · 10−3 − 4.12 · 10−1

(c) 3.05 · 106 × 2.03 · 10−1

(d) −4.01 · 105 × 2.03 · 106

(e) 5.08 · 10−5 × 4.04 · 10−7

2. [5 marks]

Consider the functionf(x) = 1 + (sin(x))2

Is this function well-conditioned in a relative sense for x ∈ [−π, π]?

Justify your answer.

(Note: f ′(x) = 2 sin(x) cos(x).)

Page 1 of 3 pages.

Page 2: CSC336 Midterm 1 Fall 2011

3. [10 marks: 5 marks for each part]

Consider the MatLab program segments

a = 0.1; a = 1.1;while a <= 0.5, while a <= 1.5,

a = a + 0.1; a = a + 0.1;end enda a

If you run these two MatLab program segments on the CDF system, then the one onthe left will print “a = 0.6000” and the one on the right will print “a = 1.5000”.

(a) What values would these two program segments print if you ran them on a com-puter that used correctly rounded decimal arithmetic?

Justify your answer.

(b) Why is the result produced on the CDF system for one of these two MatLabprogram segments so different than what you would get if you ran it on a computerthat used correctly rounded decimal arithmetic?

Justify your answer.

[Note: this example illustrates why it is very bad programming practice to use floating-point variables as loop counters as we have done above.]

4. [5 marks]

Use the matrix infinity norm to compute the condition number of the matrix

A =

(

5 12 3

)

Show all your computations.

Page 2 of 3 pages.

Page 3: CSC336 Midterm 1 Fall 2011

5. [5 marks]

Consider the system of linear equations Ax = b, where

A =

3.01 1 11 2.99 11 1 3.01

and b =

111

.

It’s easy to see that an approximate solution to this system is

x̃ =

0.20.20.2

in the sense that the associated residual

r = b − Ax̃ =

−0.0020.002

−0.002

is small. The condition number of A in the infinity-norm is approximately 3.014.

Can you conclude from this that x̃ is close to the true solution x of Ax = b? (By close,I mean that the relative difference between x and x̃ in the infinity norm is less than10−2.)

Justify your answer.

Page 3 of 3 pages.


Top Related