solhw3

solhw3 - Solutions for Homework 3 Foundations of...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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: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 ) = α + α 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 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 Horner’s 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 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...
View Full Document

This note was uploaded on 11/10/2011 for the course MAD 5404 taught by Professor Gallivan during the Spring '11 term at FSU.

Page1 / 9

solhw3 - Solutions for Homework 3 Foundations of...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online