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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 3. INTERPOLATION 107<br />

end<br />

pr=1.0<br />

for j <strong>in</strong> 1:(m-1)<br />

pr=pr*(z-x[j])<br />

sum=sum+a[j+1]*pr<br />

end<br />

return sum<br />

Out[5]: newton (generic function <strong>with</strong> 1 method)<br />

Let’s verify the code by comput<strong>in</strong>g p 3 (1.761) of Example 57:<br />

In [6]: newton([1.765,1.760,1.755,1.750],[0.92256,0.92137,0.92021,0.91906]<br />

,1.761)<br />

Out[6]: 0.92160496<br />

Exercise 3.1-7: This problem discusses <strong>in</strong>verse <strong>in</strong>terpolation which gives another<br />

method to f<strong>in</strong>d the root of a function. Let f be a cont<strong>in</strong>uous function on [a, b] <strong>with</strong> one<br />

root p <strong>in</strong> the <strong>in</strong>terval. Also assume f has an <strong>in</strong>verse. Let x 0 ,x 1 , ..., x n be n +1 dist<strong>in</strong>ct<br />

numbers <strong>in</strong> [a, b] <strong>with</strong> f(x i )=y i ,i =0, 1, ..., n. Construct an <strong>in</strong>terpolat<strong>in</strong>g polynomial P n<br />

for f −1 (x), by tak<strong>in</strong>g your data po<strong>in</strong>ts as (y i ,x i ),i=0, 1, ..., n. Observe that f −1 (0) = p, the<br />

root we are try<strong>in</strong>g to f<strong>in</strong>d. Then, approximate the root p, by evaluat<strong>in</strong>g the <strong>in</strong>terpolat<strong>in</strong>g<br />

polynomial for f −1 at 0, i.e., P n (0) ≈ p. Us<strong>in</strong>g this method, and the follow<strong>in</strong>g data, f<strong>in</strong>d an<br />

approximation to the solution of log x =0.<br />

x 0.4 0.8 1.2 1.6<br />

log x -0.92 -0.22 0.18 0.47<br />

3.2 High degree polynomial <strong>in</strong>terpolation<br />

Suppose we approximate f(x) us<strong>in</strong>g its polynomial <strong>in</strong>terpolant p n (x) obta<strong>in</strong>ed from (n +1)<br />

data po<strong>in</strong>ts. We then <strong>in</strong>crease the number of data po<strong>in</strong>ts, and update p n (x) accord<strong>in</strong>gly. The<br />

central question we want to discuss is the follow<strong>in</strong>g: as the number of nodes (data po<strong>in</strong>ts)

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

Saved successfully!

Ooh no, something went wrong!