CSC336 Midterm 1 Fall 2011

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

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 oating-point number system with parameters = 10, p = 3, L = 10 and U = +10 that uses the round-to-nearest rounding rule and allows gradual underow with subnormal numbers. That is, the numbers in the system include zero and nonzero numbers of the form d1 .d2 d3 10n where di {0, 1, 2, . . . , 9} for i = 1, 2, 3 and n {10, 9, 8, . . . , 10}. For normalized nonzero numbers, d1 = 0. For subnormal nonzero numbers, n = 10, d1 = 0 and di = 0 for i = 2 or 3. Like the IEEE oatingpoint number system, this number system also has the two special numbers +Infty and Infty which stand for numbers that are too large in magnitude (either positive or negative, respectively) to represent in this oating-point number system. In the oating-point number system described above, what is the result of each of the following oating-point arithmetic expressions? Write your answer as a normalized number in this oating-point system, if possible, or as a subnormal number in this oating-point system in the case of gradual underow, or as +Infty or Infty in the case of overow. (a) 6.03 107 + 5.04 107 (b) 6.21 103 4.12 101 (c) 3.05 106 2.03 101 (d) 4.01 105 2.03 106 (e) 5.08 105 4.04 107

2. [5 marks] Consider the function f (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.

3. [10 marks: 5 marks for each part] Consider the MatLab program segments a = 0.1; while a <= 0.5, a = a + 0.1; end a a = 1.1; while a <= 1.5, a = a + 0.1; end a

If you run these two MatLab program segments on the CDF system, then the one on the 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 computer that used correctly rounded decimal arithmetic? Justify your answer. (b) Why is the result produced on the CDF system for one of these two MatLab program segments so dierent than what you would get if you ran it on a computer that used correctly rounded decimal arithmetic? Justify your answer. [Note: this example illustrates why it is very bad programming practice to use oatingpoint variables as loop counters as we have done above.]

4. [5 marks] Use the matrix innity norm to compute the condition number of the matrix A= Show all your computations. 5 1 2 3

Page 2 of 3 pages.

5. [5 marks] Consider the system of linear equations Ax = b, where 3.01 1 1 1 A = 1 2.99 1 and b = 1 . 1 1 3.01 1 Its easy to see that an approximate solution to this system is 0.2 x = 0.2 0.2 in the sense that the associated residual 0.002 r = b A = 0.002 x 0.002 is small. The condition number of A in the innity-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 dierence between x and x in the innity norm is less than 2 10 .) Justify your answer.

Page 3 of 3 pages.

You might also like