06.09.2021 Views

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

CHAPTER 3. INTERPOLATION 95<br />

for i =0, 1, ..., n, or <strong>in</strong> matrix form<br />

⎡<br />

⎤<br />

1 0 0 ... 0 ⎡ ⎤ ⎡ ⎤<br />

a 1 (x 1 − x 0 ) 0 0<br />

0 y 0<br />

1 (x 2 − x 0 ) (x 2 − x 0 )(x 2 − x 1 ) 0<br />

a 1<br />

y ⎢ ⎥ =<br />

1<br />

⎢ ⎥<br />

⎢<br />

⎣.<br />

.<br />

.<br />

.<br />

⎥ ⎣ . ⎦ ⎣ . ⎦<br />

⎦<br />

∏<br />

1 (x n − x 0 ) (x n − x 0 )(x n − x 1 ) ... n−1<br />

i=0 (x a n y n<br />

n − x i ) } {{ } } {{ }<br />

} {{ } a y<br />

A<br />

for [a 0 , ..., a n ] T . Note that the coefficient matrix A is lower-triangular, and a can be solved<br />

by forward substitution, which is shown <strong>in</strong> the next example, <strong>in</strong> O(n 2 ) operations.<br />

Example 49. F<strong>in</strong>d the <strong>in</strong>terpolat<strong>in</strong>g polynomial us<strong>in</strong>g Newton’s basis for the data:<br />

(−1, −6), (1, 0), (2, 6).<br />

Solution. We have p 2 (x) =a 0 + a 1 π 1 (x)+a 2 π 2 (x) =a 0 + a 1 (x +1)+a 2 (x +1)(x − 1). F<strong>in</strong>d<br />

a 0 ,a 1 ,a 2 from<br />

p 2 (−1) = −6 ⇒ a 0 + a 1 (−1+1)+a 2 (−1+1)(−1 − 1) = a 0 = −6<br />

p 2 (1) = 0 ⇒ a 0 + a 1 (1+1)+a 2 (1 + 1)(1 − 1) = a 0 +2a 1 =0<br />

p 2 (2) = 6 ⇒ a 0 + a 1 (2+1)+a 2 (2 + 1)(2 − 1) = a 0 +3a 1 +3a 2 =6<br />

or, <strong>in</strong> matrix form<br />

Forward substitution is:<br />

⎡ ⎤ ⎡ ⎤ ⎡ ⎤<br />

1 0 0 a 0 −6<br />

⎢ ⎥ ⎢ ⎥ ⎢ ⎥<br />

⎣1 2 0⎦<br />

⎣a 1 ⎦ = ⎣ 0 ⎦ .<br />

1 3 3 a 2 6<br />

a 0 = −6<br />

a 0 +2a 1 =0⇒−6+2a 1 =0⇒ a 1 =3<br />

a 0 +3a 1 +3a 2 =6⇒−6+9+3a 2 =6⇒ a 2 =1.<br />

Therefore a =[−6, 3, 1] T and<br />

p 2 (x) =−6+3(x +1)+(x +1)(x − 1).<br />

Factor<strong>in</strong>g out and simplify<strong>in</strong>g gives p 2 (x) =−4+3x + x 2 , which is the polynomial discussed<br />

<strong>in</strong> Example 48.

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

Saved successfully!

Ooh no, something went wrong!