solhw3

solhw3 - Solutions for Homework 3 Foundations of...

This preview shows pages 1–4. Sign up to view the full content.

Solutions for Homework 3 Foundations of Computational Math 2 Spring 2011 Problem 3.1 Show that given a set of points x 0 , x 1 , . . . , x n a Leja ordering can be computed in O ( n 2 ) operations. Solution: The following MATLAB code due to Higham (see Higham 2002 Second Edition) shows how a Leja ordering can be computed in O ( n 2 ) operations. function [a,perm] = leja(a) n = max(size(a)); perm= (1:n)’; [t,i] = max(abs(a)); if i ~= 1 a([1 i]) = a([i 1]) ; perm([1 i]) = perm([i 1]) ; end p = ones(n,1); for k=2:n-1 for i=k:n p(i) = p(i) *(a(i)-a(k-1)); end [t, i]=max(abs(p(k:n))); i = i+k-1; if i ~=k a([k i]) = a([i k]); p([k i]) = p([i k]); perm([k i]) = perm([i k]); end end Problem 3.2 Consider a polynomial p n ( x ) = α 0 + α 1 x + · · · + α n x n p n ( x ) can be evaluated using Horner’s rule (written here with the dependence on the formal argument x more explicitly shown) 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
c n ( x ) = α n for i = n 1 : 1 : 0 c i ( x ) = xc i +1 ( x ) + α i end p n ( x ) = c 0 ( x ) If the roots of the polynomial are known we can use a recurrence based on p n ( x ) = α n ( x ρ 1 ) · · · ( x ρ n ) given by: d 0 = α n for i = 1 : n d i = d i 1 ( x ρ i ) end p n ( x ) = d n This algorithm can be shown to compute p n ( x ) to high relative accuracy. Specifically, d n = p n ( x )(1 + μ ) , | μ | ≤ γ 2 n u where γ k = ku/ (1 ku ) and u is the unit roundoff of the floating point system used. 3.2.a An error analysis of Horner’s rule shows that the computed value of the polynomial satisfies ˆ c 0 = (1 + θ 1 ) α 0 + (1 + θ 3 ) α 1 x + · · · + (1 + θ 2 n ) α n x n where | θ k | ≤ γ k . Let ˜ p n ( x ) = | α 0 | + | α 1 | x + · · · + | α n | x n Show that | p n ( x ) ˆ c 0 | | p n ( x ) | γ 2 n ˜ p n ( | x | ) | p n ( x ) | (1) and therefore κ rel = ˜ p ( | x | ) | p ( x ) | is a relative condition number for perturbations to the coefficients bounded by γ 2 n . 2
3.2.b Equation 1 also yields an a priori bound on the forward error | p n ( x ) ˆ c 0 | that can be computed along with evaluating p n ( x ) with Horner’s rule. Write a code that evaluates p n ( x ) and the forward error bound using Horner’s rule and p n ( x ) using the product form . Apply the code to the polynomial p 9 ( x ) = ( x 2) 9 = x 9 18 x 8 + 144 x 7 672 x 6 + 2016 x 5 4032 x 4 + 5376 x 3 4608 x 2 + 2304 x 512 to evaluate p 9 ( x ) in both forms and the a priori bound on forward error at several hundred points in the interval [1 . 91 , 2 . 1].

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern