Você está na página 1de 3

65 minutes

Numerical Methods Test 2 Winter 2010 One 3 5 card of notes is allowed. Computers are allowed, but not the Internet. 2 1/2 2 1/2 (1) (15pts) Let b = 7, u = 1/2 . 1 1/2 (a) What is u ? u = u u = 1/4 + 1/4 + 1/4 + 1/4 = 1 (b) Find the projection of b onto u. u b u u = u(u b) ((since u u = 1)) 3/2 3/2 = 3u = 3/2 . 3/2

proju b = u

(2) (10pts) Suppose A has 0.520640 0.828069 A= 0.080957 0.191525

the following QR decomposition. 2 7 0 3 0.768264 0.139406 0.345355 0.555950 0.070289 0.016763 5 3 2 0.230934 0.934486 0.258557 1 9 0.217623 0.319940 0.901996 2
Q R

This was computed using 3 Householder transformations, each of which has determinant 1. (The reason we only need 3, as opposed to 4, is that making a 4 4 matrix uppertriangular only requires worrying about the rst 3 columnseverything in the 4th column is automatically on or above the diagonal.) (a) What is det(A)? det(A) = det(Q) det(R) = (1)3 (2 5 1 2) = 20 (b) What would the residual be if you computed the least-squares solution to Ax = b where b = (1.1, 1.1, 1.2, 0.7)? Since A is nonsingular (det(A) = 0), Ax = b is solvable, the least-squares solution is an actual solution, and the residual would be 0 . (If you take roundo error into eect, the norm of the residual would be about 1016 .) (3) (10pts) Suppose you have a function f : R4 R4 such that, at each root of f , the Jacobian of f is 2I . What function could you iterate to nd roots of f ? We use Newtons method, except that we can simply x J = 2I since we already know what the Jacobian matrix is at the roots. That leaves g (x) = x J 1 f (x)
1 =x+ 2 f (x)

(since (2I )1 = 1 2 I)

(4) (15pts) The 64-bit oating point representation of a nonzero number a takes the form a = s m 2x where s = 1 depending on sign, m [1, 2) is represented with 52 bits of accuracy and x is between 1022 and 1023.

(a) How could you create a function that eciently computes a very accurate approximation of log2 (m) for m [1, 2)? (You may use expensive computations to help you come up with the code in the rst place, but once written, it should be ecient.) We can use a Chebyshev polynomial. [That answer would be sucient, barely.] More specically, we let f (x) = log2 ((x + 3)/2) (in order to change in domain to [1, 1]), and nd a Chebyshev approximation C (x) of f (x); we experiment to nd what degree is necessary to get the accuracy we want. The code itself would take m and evaluate C (2m 3). (b) What is log2 (2x )? x (c) How could you create a function that eciently computes a very accurate approximation of log2 (a), for a > 0? log2 (a) = log2 (m 2x ) = log2 (m) + x, so we can compute log2 (a) by evaluating log2 (m) as in (a) and then adding x. (5) (15pts) Suppose you are nding a root of a function f by inverse quadratic interpolation, and that your last few points are x4 = 1.4 x5 = 1.6 x6 = 1.5 f (x4 ) = 1 f (x5 ) = 0.9 f (x6 ) = 0.1

What would x7 be? (For the sake of partial credit, you may wish to describe how you calculated x7 .) We nd the polynomial x = p(y ) = ay 2 + by + c that goes through these 3 points; then x7 = p(0) = c. x = [1.4; 1.6; 1.5]; y = [-1; 0.9; 0.1]; p = vander(y)\x; p(3) The result is x7 = 1.4891 . (6) (10pts) The Schur decomposition of a square matrix A is A = QRQ where Q is unitary and R is upper-triangular. This decomposition is more expensive than the QR decomposition, so it is not the best way to nd least-squares solutions to Ax = b. Nevertheless, supposing you have already factored A as A = QRQ , how would you nd the least-squares solution to Ax = b? QRQ x = b RQ x = Q b So, after multiplying b on the left by Q , we can use back-substitution to solve Rc = Q b for c where c = Q x. We then have x = Qc. (Note: If any columns of R are missing pivots, then we let the corresponding variables be 0 when doing back-substitution.) (7) (25pts) Consider the following data table of typical hard disk capacities C (in GB) as a function of time t (years since 1984). t C 0 0.01 11 2 18 50 26 1000

Suppose we wish to t this data to a model C = aekt . This is not linear in k , but taking the natural logarithm of both sides yields log C = log a + kt, which is linear in log a and k . (a) Use this observation and the method of least-squares to t the above data to C = aekt . (Note: In most scientic computing software, including MATLAB/Octave, log is the natural logarithm, not the base 10 logarithm. For the sake of partial credit, you may wish to describe how you came up with a and k .) t = [0; 11; 18; 26]; C = [0.01; 2; 50; 1000]; y = log(C); M = [ones(4,1), t]; coeffs = M\y; % We now have coeffs = [log(a); k]. a = exp(coeffs(1)) k = coeffs(2) This leaves us with a = 0.0122, k = 0.446, so our model is C = 0.0122e0.446t . Equivalently, we can express our model as C = elog(a)+kt , which leaves C = e4.40+0.446t . This latter form has some numeric advantages. For example, if we had just the years directly as values of t, we would have log(a) = 889.2, giving us C = e889.2+0.446t . The former method would explicitly calculate a = e889.2 , which would evaluate to 0 because this is too small to represent with a 64-bit double. (b) What would the model predict for disk capacities in 2020? We have t = 36 in 2020, leaving C = 0.0122e0.44636 = 115, 000GB.

Você também pode gostar