Bindel, Spring 2011

Intro to Scientific Computing (CS 3220)

Practice prelim 1
The exam is closed book, but you may bring one letter-sized piece of paper with writing on both sides. The actual exam will be two hours. 1. True or false: (a) Suppose we want to solve Ax = b, and x is an approximate soluˆ tion. If κ(A) is small and Aˆ − b / b is small, then x − x / x x ˆ is small. Answer: True. (b) Floating point addition is associative, i.e. (a+b)+c and a+(b+c) yield the same floating point number in MATLAB. Answer: False. (c) IEEE arithmetic obeys the bound fl(x × y) = (x × y)(1 + δ), |δ| < mach , for every possible floating point number x and y. Answer: False. IEEE arithmetic obeys this bound for normalized floating point numbers. In general, we are guaranteed to get the exact result, rounded to the closest number in our system, but there is a larger relative distance between subnormal numbers. (d) The power basis {1, x, . . . , xd } is an orthonormal basis for the space of polynomials of degree at most d with the inner product

p, q =

p(x)q(x) dx.

Answer: False. This was discussed in class and in section. (e) It is always true that A Answer: True.

= AT


(f) In double precision floating point (which has 52 bits after the binary point), fl(1/3) < 1/3. Answer: True.
4 2 ˆ 2. Let f (x) = 1 − cos(x). The function f (x) = x − x is a truncated 2 24 Taylor approximation to f near zero. Is this approximation correct to a relative error of 10−8 for all x in the range 0 < x < 0.1?

But the relative error is absolute error divided by magnitude.Bindel. 3. Without using A directly or writing explicit inverses (e. L. for example.5 2 2.1 we’re looking at relerr ≈ 10−6 /720 = 10−4 /360 > 10−8 .5 1 1. 2 1 0 −1 0 0. 10−2 /2 The (small) error in approximating f (0. 1) entry of A−1 .1) by a first order Taylor expansion is not big enough to change this estimate. The absolute error in the approximation is roughly x6 /6!. Spring 2011 Intro to Scientific Computing (CS 3220) Answer: No. which is bounded by 10− 6/720 < 10−8 . so at 0. U) Ainv1 = U\(L\P(:.1)). and we have computed P A = LU . Suppose A is a nonsingular matrix. 4. c. and d): . Ainv11 = Ainv1(1). Answer: function Ainv11 = compute Ainv11(P. Suppose the cubic equation ax3 + bx2 + cx + d = 0 has three positive real roots.5 Complete the first line of this Matlab code to find the smallest root (which should be correct regardless of the values of a. inv(L) or U^(-1)). write a Matlab function that returns the (1.g. b.

.. % Numerically stable computation of an upper bound x = fzero(@(x) d+x∗(c+x∗(b+x∗a)). most other upper bounds are not guaranteed to separate the first from the second root. Show that for any starting guess x0 . [0. and so f (x1 ) = f (ξ) (x1 − x0 )2 ≥ 0. Spring 2011 Intro to Scientific Computing (CS 3220) u = . f (x1 ) = f (x0 ) + f (x0 )(x1 − x0 ) + The Newton iteration is defined by f (x1 ) + f (x1 )(x1 − x0 ) = 0. Answer: By Taylor’s theorem with remainder. Hint: Use Taylor’s theorem with remainder about x0 . In order to avoid potential catastrophic cancellation. 2 f (ξ) (x1 − x0 )2 2 . Then there is a unique x∗ such that f (x∗ ) = 0. we should use the fact that the product of the roots is c/(3a).Bindel.. one step of Newton’s method applied to f gives x1 ≥ x∗ .u]). Answer: A good upper bound is the smaller root of the quadratic 3ax2 + 2bx + c = 0. Suppose f has two continuous derivatives and that f is monotonically increasing and convex (f > 0 everywhere). so that u= 6a c c √ √ = 3a −2b − 4b − 12ac −b − b − 3ac 5.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.