13.07.2015 Views

HW1 Solution

HW1 Solution

HW1 Solution

SHOW MORE
SHOW LESS

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 II Assignment 1Math578/Math4781. Sec. 6.1 of the textbook by Kincard and Cheney: 13, 15,16, 22.3. Sec. 6.2 of the textbook by Kincard and Cheney: 4, 10, 24.5. Sec. 6.1 of the textbook by Kincard and Cheney: 27.I. Section 6.113. Prove that if we take any set of 23 nodes in the interval [1, 1] and interpolate the functionf(x) = cosh x with a polynomial p of degree 22, then the relative error ‖p(x) − f(x)‖/‖f(x)‖ is nogreater than 5 × 10 6 on [−1, 1].Proof:It is obvious f(x) = cosh x = ex +e −x2∈ C 23 [−1, 1]. Let x 0 , x 1 , . . . , x 22 denote 23 nodes in theinterval [1, 1] and the interpolating polynomial is p(x), then we can have the error by Theorem 2.f(x) − p(x) = 123! f (23) (ξ x )22∏i=0(x − x i ), where ξ x , x ∈ [−1, 1].We know that f (23) (ξ x ) = sinh(ξ x ) = eξx −e −(ξx)2is a monotonous increasing function,|f (23) (ξ x )| ≤ sinh(1) < 3 2 , ξ x ∈ [−1, 1].∏22And we know∣ (x − x i )∣ < 223 as x ∈ [−1, 1].i=0Combine all these inequality, we have |f(x) − p(x)| < 123! · 32 · 223 . And |f(x)| ≥ 1, then|p(x) − f(x)||f(x)|


2In this algorithm, there are n − i + 1 times of additions and no subtractions.16. Write an efficient algorithm for evaluatingu =n∑ i∏d j .i=1 j=1<strong>Solution</strong>:The algorithmu ← d nfor i = n − 1 to 1 step -1 dou ← (u + 1)d ienddo22. Find the Lagrange and Newton forms of the interpolating polynomial for these data: Writex −2 0 1f(x) 0 1 −1both polynomials in the form a + bx + cx 2 in order to verify that they are identical as functions.<strong>Solution</strong>:Lagrange form:l 0 (x) =l 1 (x) =l 2 (x) =x(x − 1)(−2)(−2 − 1)(x + 2)(x − 1)2(−1)(x + 2)x(1 + 2)1x(x − 1)= ,6=(x + 2)x3p L (x) = 0l 0 (x) + l 1 (x) − l 2 (x)(x + 2)(x − 1)= −2(x + 2)(x − 1) (x + 2)x= − −23= 1 − 7 6 x − 5 6 x2 .


3Newton:p 0 (x) = c 0 ⇒ c 0 = f(x 0 ) = 0,p 1 (x) = c 0 + c 1 (x + 2) ⇒ c 1 = 1 2 ,p 2 (x) = c 0 + c 1 (x + 2) + c 2 (x + 2)x ⇒ c 2 = − 5 6 .p N (x) = c 0 + c 1 (x + 2) + c 2 (x + 2)x= 1 2 (x + 2) − 5 (x + 2)x6= 1 − 7 6 x − 5 6 x2 .We can find the Lagrange form and Newton form are the same.III. Section 6.24. Prove that if f is a polynomial of degree k, then for n > kf[x 0 , x 1 , . . . , x n ] = 0.Proof:Suppose p(x) is the interpolation polynomial of at most degree n for f, thenp(x i) = f(x i ). i = 0, 1, . . . , n.Let q(x) = p(x) − f(x) be a polynomial of at most degree n. From above, we know that q(x) atleast has n + 1 roots. Henceq(x) = 0. ⇒ p(x) − f(x) = 0 ⇔ p(x) = f(x).Which means p(x) is a polynomial of degree k. By divided difference, we havep(x) =n∑∏i−1f[x 0 , x 1 , . . . , x i ] · (x − x j ).i=0Then f[x 0 , x 1 , . . . , x n ] is the coefficient of x n . Hence, f[x 0 , x 1 , . . . , x n ] = 0 when n > k.j=010. Compare the efficiency of the divided difference algorithm to the procedure de- scribed inSection 6.1 for computing the coefficients in a Newton interpolating polynomial.<strong>Solution</strong>:Algorithm in Section 6.1:c 0 ← y 0for k = 1 to n dod ← x k − x k−1u ← c k−1for i = k − 2 to 0 step − 1 dou ← u(x k − x i ) + c i


4d ← d(x k − x i )end doc k ← (y k − u)/dend doWe just need to calculate the number of operations in inner loop. There are 1 addition, 2subtractions and 2 multiplies. Then the number of operations is:n∑0∑k=1 i=k−25 =n∑5(k − 1) = 5 n 2 − 5 2 2 n ∼ 5 2 n2 .k=1Algorithm in section 6.2:for i = 0 to n dod i ← f xiend dofor j = 1 to n dofor i = j to n dod i ← (d i − d i−1 )/(x i − x i−j )end doend doWe just need to calculate the number of operations in inner loop. There are 2 multiplies and 1dividings. Then the number of operations is:n∑j=1 i=jn∑3 =n∑3(n − j + 1) = 3 2 n2 + 3 2 n ∼ 3 2 n2 .j=1Hence, the algorithm in section 6.2 is more efficient than the algorithm in section 6.1.24. Write the Newton interpolating polynomial by divided differences for these data:x 4 2 0 3f(x) 63 11 7 28<strong>Solution</strong>:By divided differences, we have table as following:4 63 26 6 12 11 2 50 7 73 28Then the Newton interpolating polynomial is:p(x) = 63 + 26(x − 4) + 6(x − 4)(x − 2) + (x − 4)(x − 2)x.


5IV. Section 6.1:27. If we interpolate the function f(x) = e x−1 with a polynomial p of degree 12 using 13 nodesin [−1, 1], what is a good upper bound for |f(x) − p(x)| on [−1, 1]?<strong>Solution</strong>:As f(x) = e x−1 is smooth enough, we can choose Chebyshev points to interpolate f(x). Therefore,we can get the error formula1|f(x) − p(x)| ≤2 12 (12 + 1)! max |f 13 (t)||t|≤11=2 12 · 13! max|t|≤1 |et−1 |1=2 12 · 13! .1Hence, the good upper bound is2 12·13! ≈ 3.9207 × 10−14 .

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

Saved successfully!

Ooh no, something went wrong!