12.07.2015 Views

HW4 Solution

HW4 Solution

HW4 Solution

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Computational math: Assignment 4Based on Ting Gao1. (Exercise 12.2)<strong>Solution</strong>: (a) Derive a formula for matrix A.Denote the n-vector of data at x j to be z j , i.e.Z =⎡⎢⎣z 1.z n⎤⎥⎦ =⎡⎢⎣Y =1 x 1 · · · x n−11⎤ ⎡⎥ ⎢. . . ⎦ ⎣1 x n · · · x n−1n⎢⎣c 0.c n−1⎤⎥⎦ . = XCwhere c j (j = 0 · · · n − 1) are the coefficients of degree n − 1 polynomial.Denote⎡1 y 1 · · · y1n−1 ⎤i.e.,Hence,Therefore,. . .1 y m · · · ymn−1AZ = A(XC) = (Y C),(AX − Y )C = 0,A = Y X −1 .⎥⎦∀Z ∈ R n∀C ∈ R n(b) Write a program to calculate A and plot ‖A‖ ∞ .See code Gaot4a1.m and Fig.1.10 7 n10 610 510 410 310 210 1||A|| ∞Lebesgue constants10 00 5 10 15 20 25 30Figure 1:1


(c) The ∞-norm condition number κ of the problem of interpolating the constantfunction 1?Consider the input: n-vector data, i.e., constant function 1 at x j . We denote it as Z =[1, 1, · · · , 1] T . The output is p(y j ). Then f(x) = Ax = ( 1 1 · · · 1 ) T∈ R n ,where A = Y X −1 as above. Hence, J(x) = A and for n = 1, 2, . . . , 30, the conditionnumber is‖J‖ ∞κ == ‖A‖ ∞‖f(x)‖ ∞ /‖x‖ ∞ 1/1 = ‖A‖ ∞.We can find when n increase, it will be ill-conditioned.(d) How close is your result for n = 11 to the bound implicit in Fig.11.1?See Fig.3543210−1−1 −0.5 0 0.5 1Figure 2:2. Find the closest Marc-32 machine number to x = −9.8 and the round-off error?<strong>Solution</strong>: Since on a Marc-32 machine, we haveWe can obtainand(−9.8) 10 = (−1) 1 · (1.225) 10 · 2 3 .(9.8) + 10 = (1.00111001100110011001101) 2 · 2 3 = (9.800000190734863) 10(9.8) − 10 = (1.00111001100110011001100) 2 · 2 3 = (9.799999237060547) 10 .Since |9.8−(9.8) + | < |9.8−(9.8) − |, the closest machine number of −9.8 is −9.800000190734863,and the relative round-off error is 0.000000019462741 = 1.9462741 × 10 −8 .3. Suggest ways to avoid loss of significance in these calculations:(a) √ x 2 + 1 − 1;We can use rationalization when the cancelation occurs near |x| ≪ 1.√x2 + 1 − 1 =x 2√x2 + 1 + 1 .2


(b) sin(x) − tan(x).We can use triangular formula when the cancelation occurs near x = kπ(k ∈ Z)sin(x) − tan(x) = sin(x) cos(x) − 1cos(x)2 sin 2 ( x= − sin(x) 2 )cos(x) .4. If at most 2 bits of precision can be lost in the computation of y = √ x 2 + 1 − 1,what restriction must be placed on x assuming computed as it is?<strong>Solution</strong>: Based on the Theorem, we have1 −1√x2 + 1 ≥ 1 2 2 .Hence, we can get|x| ≥⎧√ ⎪⎨ x2 + 1 − 1,x 2⎪⎩ √x2 + 1 + 1 ,√73 .if |x| ≥else.√73,14.1. True of False?(b) sin x = O(1) as x → 0.(c) log x = O(x 1100 ) as x → ∞.(f) fl(π) − π = O(ɛ machine ). (We do not mention that the limit is ɛ machine → 0, since thatis implicit for all expressions O(ɛ machine in this book.)(g) fl(nπ) − nπ = O(ɛ machine ), uniformly for all integers n. (Here nπ represents theexact mathematical quantity, not the result of a floating point calculation.)(b) True, because | sin(x)| ≤ 1 when x → 0.(c) True, because | log(x)/x 1/100 | → ∞ when x → 0.(f) True, because fl(π) can approximate π better when ɛ machine → 0.(g) False, because fl(nπ) − nπ = O(ɛ machine ) does not hold uniformly for alln ∈ Z.14.2. (a) Show that (1 + O(ɛ machine ))(1 + O(ɛ machine )) = 1 + O(ɛ machine ). Theprecise meaning of this statement is that if f is a function satisfying f(ɛ machine ) =(1 + O(ɛ machine ))(1 + O(ɛ machine )) as ɛ machine → 0, then f also satisfies f(ɛ machine ) =1 + O(ɛ machine ) as ɛ machine → 0.<strong>Solution</strong>:(1 + O(ɛ machine ))(1 + O(ɛ machine ))=1 + 2O(ɛ machine ) + O(ɛ machine )O(ɛ machine )=1 + O(ɛ machine ) + o(ɛ machine )=1 + O(ɛ machine )3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!