This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Solutions for Homework 3 Foundations of Computational Math 2 Spring 2011 Problem 3.1 Show that given a set of points x , 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:n1 for i=k:n p(i) = p(i) *(a(i)a(k1)); end [t, i]=max(abs(p(k:n))); i = i+k1; 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 ) = + 1 x + + n x n p n ( x ) can be evaluated using Horners rule (written here with the dependence on the formal argument x more explicitly shown) 1 c n ( x ) = n for i = n 1 : 1 : 0 c i ( x ) = xc i +1 ( x ) + i end p n ( x ) = c ( 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 = 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 Horners rule shows that the computed value of the polynomial satisfies c = (1 + 1 ) + (1 + 3 ) 1 x + + (1 + 2 n ) n x n where  k  k . Let p n ( x ) =   +  1  x + +  n  x n Show that  p n ( x ) c   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  that can be computed along with evaluating p n ( x ) with Horners rule. Write a code that evaluates p n ( x ) and the forward error bound using Horners 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...
View Full
Document
 Spring '11
 gallivan

Click to edit the document details