21.06.2014 Views

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Attention:<br />

strong oscillations of the interpolation polynomials of high degree on uniformly spaced nodes!<br />

8.3 Polynomial Interpolation: Algorithms<br />

✸<br />

i=0<br />

Barycentric interpolation formula p(t) = n∑<br />

Computational effort: computation of λ i : O(n 2 ) (only once),<br />

every subsequent evaluation of p:<br />

⇒ total effort O(Nn) + O(n 2 )<br />

n∑<br />

i=0<br />

O(n),<br />

λ i<br />

t − t i<br />

y i<br />

. (8.3.1)<br />

λ i<br />

t − t i<br />

Given: nodes T := {−∞ < t 0 < t 1 < . .. < t n < ∞},<br />

values y := {y 0 , y 1 ,...,y n },<br />

define: p := I T (y) as the unique Lagrange interpolation polynomial given by Theorem 8.2.1.<br />

8.3.1 Multiple evaluations<br />

Task: evaluation of p in many points x 1 , ...,x N ∈ R, N ≫ 1.<br />

• Interpolation with Lagrange polynomials (8.2.3) , (8.2.4) is not efficient: O(n 2 ) operations for every<br />

value t ∈ R.<br />

• More efficient formula:<br />

p(t) =<br />

with λ i =<br />

n∑<br />

L i (t) y i =<br />

i=0<br />

n∑<br />

i=0<br />

n∏<br />

j=0<br />

j≠i<br />

t − t j<br />

t i − t j<br />

y i =<br />

n∑ ∏ n n∏ n∑<br />

λ i (t − t j ) y i = (t − t j ) ·<br />

i=0<br />

j=0<br />

j≠i<br />

1<br />

(t i − t 0 ) · · · (t i − t i−1 )(t i − t i+1 ) · · · (t i − t n ) , i = 0,...,n.<br />

From above formula, with p(t) ≡ 1, y i = 1:<br />

1 =<br />

n∏<br />

(t − t j )<br />

j=0<br />

n∑<br />

λ i<br />

t − t<br />

i=0 i<br />

⇒<br />

j=0<br />

n∏<br />

1<br />

(t − t j ) = ∑ ni=0 λ i<br />

j=0<br />

t−t i<br />

i=0<br />

λ i<br />

t − t i<br />

y i .<br />

Ôº º¿<br />

Code 8.3.1: Evaluation of the interpolation polynomials with barycentric formula<br />

1 function p = i n t p o l y v a l ( t , y , x ) % Arguments must be row vectors!<br />

2 n = length ( t ) ; N = length ( x ) ;<br />

3 for k = 1 : n , lambda ( k ) = 1 / prod ( t ( k ) − t ( [ 1 : k−1,k +1:n ] ) ) ; end ;<br />

4 for i = 1 :N<br />

5 z = ( x ( i )−t ) ; j = find ( z == 0) ;<br />

6 i f (~ isempty ( j ) ) , p ( i ) = y ( j ) ;<br />

7 else<br />

Ôº º¿<br />

8 mu = lambda . / z ; p ( i ) = dot (mu, y ) /sum(mu) ;<br />

9 end<br />

10 end<br />

Lines 6-7 → avoid division by zero.<br />

tic-toc-computational time, Matlab polyval vs. barycentric formula → Ex. 8.3.3.<br />

8.3.2 Single evaluation<br />

Task: evaluation of p in few points, Aitken-Neville scheme<br />

Given: nodes T := {t j } n j=0 ⊂ R, pairwise different, t i ≠ t j for i ≠ j,<br />

values y 0 , ...,y n ,<br />

one evaluation point t ∈ R.<br />

Ôº º¿<br />

For {i 0 ,...,i m } ⊂ {0, . ..,n}, 0 ≤ m ≤ n:<br />

p i0 ,...,i m = interpolation polynomial of degree m through (t i0 , y i0 ),...,(t im , y im ),<br />

Ôº º¿

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

Saved successfully!

Ooh no, something went wrong!