Top Banner

of 22

Numerical Analysis - Chapter3.pdf

Apr 14, 2018

Download

Documents

vmedeau
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    1/22

    InterpolationPolynomial interpolation is an ancient practice, but theheavy industrial use of interpolation began with cubicsplines in the 20th c e n ~ u r y . Motiva ted by practices inthe shipbuilding.and aircraft Industries, engineers Paul deCasteljau and Pierre Bezier at rival European car manufac-turers Citroen and Renault, followed by others at GeneralMotors in the United States. spurred the development ofwhat are now called cubic splines and Be.zier splines.

    Although developed for aerodynamic studies.of auto-mobiles, splines have been used for many applications,

    Including computer typesetting. A re.volution in printingwas caused by two Xerox engineers who formed a com-pany named Adobe and released the PostScript11-I Janguagein .1984 . It came to the attention of Steve Jobs at .A,ppleCorporation, who was looking for a way to control a newly-invented laser pr inter. Bezier splines were a simple way toadapt the same mathematical curves to multiple printerresolutions.Reality Reality Check 3 on page 188 explores how

    E11eck PostScript construc ts letters as Bezier splines.

    E ficiem ways of representing data are fundamental to advancing the undersr.anding ofscientific problems. At its most fundament:al, approximating data by a polynomialis an act of data compression. Suppose that points (x .y) are taken from a givenfunction y = f (x) . or perhaps from an experiment where :c denotes temperarure and ydenotes reaction rate. A function on ,!lie real nuJ;llbers represents ao infinire amount ofinformation. Finding apolynomial through the setofdatn means replacing the infonnationwith a rule that can be evaluated jn a finite number of steps. AJthough it is unrealistic toexpect the polynomial m represent the function exactly at new inputs x. it may be closeenough to solve practical pr.oblems.

    This chapterintroducespolynomial .interpolation and l:n.terpolation a.; convenienttoo ls for find ing fun ctions that_pass through given data points.

    139

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    2/22

    140 I CHAPTER 3 lnterpolatiqn13.1 DATA AND INTERPOLATING FUNCTIONS

    DEFif\JITION 3.1

    A function is said to interpolatea setofdata points .ifit passes through thoseROints. Supposethat a set of (x, y) data points has been collected, such as (0, 1), (2, 2) , d (3,4) . There isa parabola that passes through the three points, shown in F igure3.1. This parabola ualledthe degree 2 interpolating polynomial passing through the th ree points.

    y

    Figure 3.1 In terpo lat ion byparabola. Th e po ints (0,1 . (2,2),and (3.4) are interpolated by thefunct ion Pix)= !x 2 - }x + 1.

    I

    The function y = P (x ) interpolates the data points (.q , Yt), . . . . (xn, Yn) if. P(x;') = y; fore.acb I ::.:; i ::.:; 11.

    Note that P is required to be a function; that is , each value x corresponds to a single yTllis puts a restriction on the set ofdata points { :r;, y;)} that can be interpolated-the x;must be all distinct in orderfor a function to.pass through them. There is no such restrictior.on they; 's.

    ComplexityWhy do we use polynomials? Polynomials are very often used for interpolation becauseof lbeir straightforward mathematical properties. There is_a simple theory about whenan imerpolating polynomial of a given degree ex.ists for a given set of points. Moreimportant, in a real sense, polynomials are the most .fundamenta] of functions fordigital computers. Central processing units usually have fast methods in hardware foradding and multiplying floating points numbers, which are the operations needed toevaluate a polynomial. Complicated functions cun be approximated by interpolatingpolynomials in order to make tbern computable with these two hardware operations.

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    3/22

    EXAMPLE 3.1

    3.1 Data and Interpolating Functions I 141To begin. we will look for an interpolating polynomial. Does uch a pol ynomial always

    exi st? Assuming that th e x-coordinmes of the points are distinct, the answer is yes. Nomauer bow many points are given, there is some polynomial y = P (x ) that runs lhrough aUthe point"S. This and several other f:1cts about interpolating polynomials are proved in thissection.Interpolation is the reverse of evaluation. In polynomial evaluation (such as the nestedmultiplication ofChapter 0) we are given a polynomial and asked to evaluate a y-value fora &iven :c-value-that is. compute points lying on the cu.rve. Polynomial interpolation asksl'or the opposite process: Given these points. compute a polynomial that can generate them.

    3.1.1 L9gra119e interpglati9QAssume that n data points (x1, Yl ) ... (xn, y11 ) are given, and that we would like to findan tnterpolating polynomial .There is an expli'cit formula, ca lled the Lagrange interpolatingformula. for writing down a polynomial of degree d = 1 - 1 that interpolates the points.For example. suppose tim we are given three points (.tt, YJ ). (x2. Y2). (.t"3, )'3). Then thepolynomial

    is the Lagrange interpolating polynomial for these points. First notice why the points eachlie on the polynomialcurve.When Xt is substiruted for x . the terms evaluate to Yt + 0 + 0 =Yt The second and Lhi rd numerators arc chosen to disappear when X t is ubstitutcd, andthe first denominator is chosen just so to balance the first denominator so that :v 1 pops out.l t is similar wben x2 :wd x3 are substiwted. When any othe r number is subs tituteu for xwe have little comrol over the res ult. But then. the job was onl y to interpolate at the lhreepoiot s - lhat is the ex tent of our concern. Second, notice that the polynomial (3. 1) is ofdegree two In the variable x.Find an interpolating polynomial for the data points {0. 1). (2, 2) and (3 . 4) in Figure 3.1.

    Substituting into Lagrange's formula (3. 1) yieldsp, ( ) (x - 2)(x- 3) .., (x - O)(x - ,3) (x - O)(x - 2)\' - I + , I 4 - - --- -2 . - (0 - 2)(0- 3) - (2 - 0)(2 - J) T (3 - 0)(3- 2)

    = - 5x + 6) + 2 ( - ~ ) (x2 - 3x) + ) (x 2 - 2x)I , 1= -x - -2x + l.2

    Check that P2(0) = I , P2(2) = 2 and P2(3) = 4.

    In general. suppose that we are presented with 11 points (x1. YJ), . . . , (x11 , Yn). For each kbetween 1 and 11, define the term

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    4/22

    142 I CHAPTER 3 Interpolation

    THEOREM3.2

    EXAMPLE 3.2

    The interesting property of Lk is that Lk = J, while Lk(x1) = 0, where x1 is any of theother data pointS. Then define the degree 11 - 1 polynomial

    This is a straightforward generalization of the polynomial in (3.1) and wo rks the same way.Substituting Xk f.or x yields

    so it works as designed.We bave constructed a polynomiaJ of degree at most 11 - 1 that passes through any setof n poin!S with distiuct x; 's. Interestingly, it is the only one.

    1\lain Theorem ofPolynomlallnterpolation.Let (x t, Yl) ... (x , . y11 ) be n pointS in l.beplane witb distinctx1 Then there exists one and only one polynomial P of degree.n - 1orless that satisfies P(x;) = )' i for i = 1, ... ,n. Proof. The existence is proved by the explicit formula for Lagrange in terpolation. Tosbo''' there is only one, assume 'for the sake of argument that there are two, say, P (x ) andQ(x), that have degree at most n - I and that both interpolate aJln points. That is, we are

    assuming that P(.\J) = Q(.q) = Yl. P(x:.) = Q(x2) = )'2, . . . P(xn) = Q(x,) = Yi: Nowdefine the new polynomiaJ H (x) = P(x ) - Q(x ). Clearly, the degree of H is also aLmostn - 1. and. no te that 0 = H (:q) = B (x2) = = H (xn) ; that is, H bas n distinct zeros.According to the FundameotaJ Theorem ofAlgebra, a dcgreed polynomial can have at mosrd zeros, unless it is the identically zero polynomiaJ. Therefore, H is the iden tically zeropolynomiaJ, and P (x ) =Q(x) . We conclude that tJ1ere is a unique P (x ) of e g r e e ~ n - 1interpolating then poiots (x;, )'I). DFind the polynomial of degree 3 or less that interpolates the points (0, 2), (1, J), (2 . 0),and (3, -1).

    Tl1e Lagrange form is as follows:(x - l) (x - 2)(x - 3) (x - O)(x - 2)(x - 3)Pf;r:) = 2 (0 - 1)(0 - 2)(0 - 3) + (1 - 0)(1 - 2)(1 - 3)

    +0 (x - O)(x - l )(x - 3) _ 1(,, - O)(x - l )(x - 2)(2 - 0) (2 - 1) (2 - 3) (3 - 0)(3 - 1)(3 - 2)= - ~ - 6x2 + 1 x - 6) + ~ ( x - 5x2+6:c)- ~ ( x - 3x 2 +2x)=-X +2.

    Theorem 3.2 says that there existS exactly one interpolating polynomial ofdegree 3 orless, but it may or may not be exactly degree 3. ln Example 3.2, the data points arecolllnear, so the interpolating polyoomjaJ has degree 1. Theorem 3.2 implies l.bat there areno interpol.ating polynomiaJs of degree two or three.ltn10y be already intuitively obviousto you thal no parabola or cubic cu rve can pass throughfour collinear points, bul here isthe reason.

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    5/22

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    6/22

    144 I CHAPTER 3 Interrelation

    EXAMPLE 3.3

    for i= 2, . . . , 11for j = 1, .. . ,n+ 1 - i

    f(X j . . XJ+i-IJ = ( f [x1..,.t . Xj+t-1) - / [X j . . . Xj+;-:!))/(XJ+i-1- Xj)endend(+The interpolating polynomial is

    nP(x) = L f [.q ... x; ] (x- x, -) ( x - Xi-1)

    i= !

    The recursive definition of the Ncwtoos divided differences allows arrangement intoa convenient rable. For three points the table has the form

    .q f[xt] rrx, .Q]X2 f[x2 ] f lx t. .\"2 X3]J[x2 x3).t3 J[x3]

    The coefficients of tbc polynomial (3 .3) can be read from the top edge of tbe triangle.lfse divided differences to find the interpolating polynomial passing through the points(0 , 1), (2, 2), (3, 4).

    Applying the defi nitions of divided differences leads to the fo llowing table:0 l

    2 12 2 223 4

    This table is computed as follows: After writing down the x and y coordinates in separatecolum.ns, calculate the next columns, left to right , as divided differences. as in (3 .2). Forexample.

    4 - 2 = 2.3 -2After completing the divided difference u:iangle, the coefficients of the polynomial I.1/2, 1/2 can be rend from the top edge of the table. The interpolating polynomial can bewrin(m as

    1 lP (x) = I + - (x- 0) + (x - O)(x - 2).2 -or, in nested form,

    P(x ) = 1 + ( x - 0) ( ~ + (x - 2) ~ ) .

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    7/22

    EXAMPLE 3.4

    EXAMPLE 3 .5

    3.1 Data and Interpolating Functions J 145The base poims for me nested fonn (see Chapter 0) are r1 = 0 and r2 = 2. Alternatively,we could do more algebra and write the interpolating polynomial as

    1 I 1 ., IP(x) = 1 + 2x + 2x (x - 2) =2,..-- 2x + 1,matching th e Lagrange .interpolntion version shown previously.

    Using the ilivided difference approach, new data points that a n i ~ e after computing rl1eoriginal interpolating polynomial can be easily added.Add the fourth data point ( I, 0) to the list in Example 3.3 .

    We can keep the calculations that were already done.and just add :1 new bonom row tothe triangle:

    0 12 I2 2 22. l-2..,.) 4 0

    20The result is one new term to add .to the original polynomial P2(x). 'Reading .from the topedge of th e triangle , we see that the new degree 3 interpolating polynomjal is

    P3(x) = I + ( x - 0) + ( x - O)(x- 2 ) - ~ t - O)(x- 2) (x - 3).2 2 2Note that P3(.t) = P2(x) - t(x - O){x - 2)(x - 3), so the prev iouspolynomial can bereused as part of the new one.

    [tis interesting to compare the extra work necessary to add a new poim to the Lagrangefonnulation versus the divided difference fonnulation. Tho Lagrange po lynomial must berestarted from the beginning when a new point is acldeo: none of the previous calculnlioncan be used. On the other hand. in divided difference form, we keep the earlier wo rk and uddone new term to the polynomial. Therefore, the divided difference appr.oach bas a real-timeupdating" property that the Lagrange form lacks. ').'he operation counts for Lagrange anddivided difference jn[erpolation are compared in Exereise 15.Use Newton's cjivided dife rences to lind t11 e lnterpolalingJ)Oiynomial passing through(0, 2), (I 1 l) , (2, 0), (3, - I).

    The divided difference triangle is0 2 - 1. 0- I 02 Q, 0

    - I3 - 1

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    8/22

    146 I CHAPTER 3 Interpolation

    EXAMPLE 3.6

    Reading off the o e f f i c i e n t s we find that the inrerpolating polynomial of degree 3 orless is

    P(x) = 2 + (-l ) ( x - 0) = 2- x.agreeing with Example 3.2, but arrived a t with much less work .

    3.1.3 How many degree d polynomials pass through n points?Theorem 3.2 . the Main Theorem of polynomial interpolation, answers this question i f05;d sn- I. Given n = 3'points (0, 1).(2.2),(3,4) . t.here is one interpolating poly-nomial of degree 2 or less. 'Example 3. 1shows that it is degree 2, o there are no degree 0or I interpolating polynomials through the three data points.How many degree 3 polynomials interpolate lhc same three points? One \..,.ay to constructsuch apolynomial is clear from the previous discussion: Add a fourth point. Extendingthe Newtondivided difference triangle gives a new top eocfficicnt.ln Example 3.4. the poinl( I , 0) was added. The resulting polynomial,

    1P3(x ) = P2(x) - 2(x - O)(x - 2)(x- 3), (3 .4)passes through the three points in question, in addition to the new point (1, 0) . So thereis at least one degree 3 polynomial passing through our three original points (0.1 ), (2. 2) .(3,4).

    Of course. tbere are maily different ways we could ha\'e chosen tbe fourth point. Forexample. if we keep the same x4 = 1 and simply change .\'.t from 0. we must get a differ-ent degree 3 interpolating polynomial. since a function can only go through one y valueat x4. Now we know there are iniirutely many polynomials that interpolate the three points(Xt ,)'J). (x2, )'?.) . (x3 , )'3). since for any fixed X4 tbere are infinitely many ways y4 can bechosen. each giving a djffere.nrpolynomial. n,h line of thinking shows that. given n datapoints C.rr, y; ) with distinct x; , there are infinitely many degr-ee 11 polynomials passingthrough tbern.A :o.econd loo)< at (3.4) suggests a more direct way to produce interpolating polynomialsof degree 3 through three points. Instead of adding a fourth point to generate a new degree 3coefficient. why not just pencil in a new coefficient? Does the result in terpolate the originalLhree points?Ycs. because P2(x) does, and the new term evaluates to zero at x.1, x2, andx3. Sothere is really no need to consLrUct the extra !\e'.\'too's divided differences for this purpose.Any degree 3 polynomial of the form

    with c f:. 0 will pass through (0, l) . (2. 2) . and (3, -I). 'This technique will also easily con-sLruct (inftnitely many) polynomials of degree::=._ 11 for 11 g i n ~ data points. as illustrated inthe next example.

    How many polynomials of each degree 0::: d 5; 5 pas t11rough the points ( - I . -5).(0, - I ) , (2.1) . and (3 . U )?

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    9/22

    3.1 Data and Interpolating Functions I 147The Newton' divided difference rriangle is

    -1 -54

    0 - 1 - 12 3

    103 IISo there are no interpolating polynomials of degree 0. I. or 2. and the single degree 3 is

    P3(x) = -5 + 4(x + I) - (x + l )x + x + )x(x - 2) .There arc infinitely many degree 4 interpolati ng polyno mia ls

    = P3(x) + c1 (x + l )x (x - 2)(. \ ' - 3)fo r arbi trary ct :;!: 0. and infini tely many degree 5 interpolating polynomials

    Ps (x ) = P3(x ) + c2(x + l )x2(x - 2)(x - 3)for arbitrary c2 :;!: 0.

    3.1.4 Code for interpolationTbe M ATLAB program newt.dd . m for computing the coefficients follows:

    % P r o g r a ~ 3 . 1 Newton Div1ded D ~ f f e r e n c e In:erpolat ion Method%Computes c o e ~ f l c i e n t s of im:erpolaLing polynomial%I.:1put : x and y are veccors con ta ining t he :< and y coordinates% c : t h ~ n da=a p c i ~ : s% O u t ~ u c coe:: lcie; .cs c o= ~ t ~ r p o l a t i ~ s p o l y ~ o ~ a l r.ested to=rn%Use th nest . rn Lo eva lt.:ac.e !.n:er;:>olat.ir:g ;:>olyr.omial: unction c=newcdd(x,y , n)::or j : : l : nv ( j , l ) =ylj ) ; \ f ~ l l y columr. of Newton ~ a n g l eendfo r i= 2 : n % For co lumn i ,

    Ear j= l :o+l-i % Eil l in column from top co boccomi J = ( v ( j ~ l i - 1 ) - v { j , i - l ) x ( j ~ i - 1 ) - x ( j ) )endend:o r i= l : n

    c ( i )=v( l , i ) ;end

    Read a l o ~ ~ cop of c = i ~ g l e% fo r oucput coeff ic ientsThis program can be appl ied to the da ta poin ts of Example 3.3 to return the coefficientsI. 1/ 2, 1/ 2 found above. The.ccoefficients can be used in the nested multiplicationprogram

    1.0 evaluate the interpolating poly nomial at various x-values.For example, the MAn.AB code segmemx0=[0 2 3];y o= r1 2 4J:

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    10/22

    148 I CHAPTER3 Interpolationc = : ' l e l ~ t d d (xO, yO, J I ;X:0 : .01 : 4 ;y = ~ e s t 2 . c , x , x

    p l o t x , y O , ' o ' ,x , y )will result in the plot of the polynomial shown in Figure 3. 1.Now that we have !vLm .AB code for finding the coefficients of the interpolating poly

    nomial (newtdd . n) and for evaluating the polynorruaJ (nest .m) . we can put themtog_ether to build a polynomial interpolation routine. The progran1 c l ick in te rp .muses MATLAB's grapbics capability to plot the interpolation polynomial as it is being created. Sec Figure 3.2. MATL

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    11/22

    S P ~ O N

    EXAMPLE3.7

    3. 1 Data and Interpolating Functions I 149CompressionThis i our first em:ounrer with the concept of compression in numerical analysis. Atfirst, interpolation may no t seem like compression. After all. we taken points as inputand deliver 11 coefficients (of the interpolating polynomial) as output. What has beencompressed'!

    Think of the data points as coming from somewhere, say as representativeschosen from lhe multirudeofpoints on a curve y = f (.r). Tbc degree" - 1polyoomial, charucterized by n coefficients, is a compressed version" of f (x) ., andmay in some cases be used as a fairly simple representative of f(x) for computationalpLtrposes .

    For example. what happens when the sin button is pushed on a ca lculutor? Thecalcul ator has hardware to add and multiply, but how does it compute the sin of anumber? Somehow the operation must reduce to the evaluation of a po lynomial. whichrequires exactly those operations. By choosing d:.tt:l points lying on lhe sine curve, aninterpolating polynomial can be calculated and stored in the calculator as a compressedversion of the sine function.

    This type of compression is "lossy compression: meaning that there will beerror involved. since lhe sine function is not actually a polynomial. How much error ismade when a function f (x ) is replaced by an interpolating polynomial is the subject ofthe next seCLion.

    3 .1.5 Representing functions by approximating polynomialsA major use of polynomiallnterpolalionis to rep lace eva luation of a complicated functionby evaluation of a polynomial which .involves ou ly elementary computer operations likeaddition, subtraction. and multiplication. Think of this as a form of compression: Somethingcomplex is replaced \vi th something simpler and computable. with pe rhaps some loss inaccuracy that we will have to analyze. We begin with an exa mple from trigo nometry.In terpolate the function f(x') = sinx at 4 equally-spaced points on [0, rr/ 21.

    Let's compress the sine function on the interval fOrr /2 ]. Take four da ta points atequally spaced points and .form the divided difference triangle. We list the vhlues to fourcorrec t places:

    0 0.0000 0.95497i/ 6 0.5000 -0.24430.6691 -0.1 1392rr / 6 0.8660 -0.4232

    0.25593rr/6 1.0000

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    12/22

    150 I CHAPTER 3 InterpolationThe degree 3 interpolating polynomial is therefore

    P3 (x) = 0 + 0.9549x- 0.1443x(x- tr/ 6)- O.IL3.9x(x - tr /6)(x- rr/ 3)= 0 + x(0.9549 + (x - tr / 6)(- 0.2443 + x - 1f/3)( - 0. 1139))) . (3 .5)

    This polynomial is graphed together with the sine function in Figure 3.3. At this level ofresolution, P3(x) and sinx are virtually indisti.nguishablt: on the interval[O.tr/ 2]. Wehave compressed the infinite amount of infom1alion held by the sine curve into a fewstored coefficients and the ability to perform the 3 adds and 3 multiplies in (3.5).

    How close are we to designing thes in key on a calculator? Certainly we need to handleinputs from the entire real line.But due to the symmetries of the sine function, we have don ethe hard part. Tbc interval [0, rr/ 2] is a so-cal led fundamental domain for sine, meaningthat an inpm from any other interval can be referred back to it. Given an input x from[rr / 2. rr]. say. we can.compute sin x as sin(:r - x), since sin is symmetric about x = JT /2.Given an input x frori1 [rr. 2JT], sin x = - sin(2JT - x) due to antisymmerry about x = tr .Finally. because sin repeats its behavior on the interval [0 , 2rr] across the entire real line,we ca n calculate fo r any inpul by firsl reducing modulo 2rr. This leads to a straightforwarddc S"igo for the s LT"J key:lit?r:og:::am 3 . 3 3uildi:pi

    xl = 2p i-xl ;5 = -1 ;

    e.::!d:Lf xl > pi /2xl = pi-xl ;endy = s nes t{J , c ,x l , b) ;

    Most of the work in Program 3.3 is tO place x into the fundamental domain. Then weevaluate the degree 3polynomial by nested mu ltiplication. Here is some typical output fromProgram 3.3:

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    13/22

    3.1 Exercises

    3.1 Data and Inte rpo lating Functions I 15 1):,l

    Figu re 3.3 Degree 3 in terpolationof sin x. The inrerpolation polynomial'(5old cu rve:) Is plotted alohg withy= sin :

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    14/22

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    15/22

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    16/22

    154 I CHAPTER 3 Interpolation

    EXAMPLE 3.8

    lbe interpolation error that is usually impossible to evaluate exactly. bm often can at leastlead to an error bound.Assume that P (x ) is the (degree n - 1 or less) interpolating polynomial fitting t.be n points(xt . )'1 ), . . . , (x1 )'n) . The interpolation error is

    f (x) - P (x ) = (x - Xt ) ( : r - ;r:!) .. . (x - Xn) ! (")(c). (3.6)n!where c lies between the smallest and largest of the numbers x, XJ, .. , x11

    See Section 3.2.2 for a proof of Theorem 3.3 , We can use the theorem to assess theaccuracy of the s in key we buill in Example 3.7. Equa tion (3.6) yields. ) (x - 0) (x - i) (x - 1-) (x - %) 11 , smx - P (x = 41 - f (c).

    where 0 < c < rr / 2. The fourth derivative / 1111(c) =s in c varies from 0 to 1 in this range.At wors t. Isin cl is no more than l . so we can be assured of an upper bound on interpolationerror:

    l(.r - 0) (x - !!.) (x- !!.) (x- ?)Ijs inx- P (x )l ~ 6 24 3 ' Il l.Au = I. the worst-case error is

    Isin 1 - P(l )l ~ i - O){l- % ~ ~ - ~ ) ( I - !) Il l ~ 0.0005348. (3.7)This is an upper bound for the error, since we used a "worst case" bound for t.be fourthderivative. Note that the actual error al x = I was .0004, which is within the error boundgiven by {3.7). We can make some conclusions on the basis of 11e form of the interpolation

    error fonnula. Weexpect smaller errors whenxis closer to the middle of the interval ofx i sthan when it is near one of the ends, because there will be more small te rms in the product.For example, \ve compare the preceding error bound to the case x = 0.2, which is near theleft end of the range of data points. In this case, the error fonnula is

    I

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    17/22

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    18/22

    156 ] CHAPTER 3 Interpolation

    !JMMA 3.4

    DEFINITION 3.5

    LEMMA 3.6

    know it must agreewilb h e L ~ g r a n g e version. We start by finding aformuJo for the degree11 - I coefficiem of Pn-1, and then specialize to the Newton form.

    Consider two other interpolating polynomials: Pn-2 which imerpolarcs x1, . . Xn- L.and Q11-2 , which imerpolares x 2 . . . Xn. The following rela tion holds berween them:

    Proof. Since the difference between the two side s is a polynomial of degree ar most

    n - l , it suffices to prove thaL the rwo sides are equal at any n distinct points. Then, bythe FundamenU':I.l Theorem of Algebra, rhe difference must be the identically zero po lynomial. The 11 points we choose are t:he n interpolation points. At x = x 1, the left sideis zero because both Pn-1 and Pn-2 interpolate the point (x i , .n). The rigbr side is alsozero. At x =x2 .. .. x11_ 1, both sides are zero because all three po lynomials. Pn-1 P11-z,.Qn -2. imerpolate the points. For x =X11 , both sides are identical because P11-t(X11 ) =Qn -2(.\'n). 0We denote Lbe degree 11 - J coefficient of Lbe unique degree .::: 11 - 1 pol ynomial interpolating XJ Xrr by f[xt .. . Xn 1.

    Using this definition, the degreen - 1coefficient of the left-hand side inLemma 3.4 isf lxl . .. Xn] (Xn - XJ).

    and the degree n - 1 coefficient of the right-hand side is

    Since they must be equal, we have proved the following:I f f[.,l ... Xn] denotes the degree n - 1 coefficient of Lbe degree .::: n - 1 polynomiali oterpolali.ng x , , ... ,x,, then

    . , ) _ j[x2 .. . x,J - .f[.\'1 . . . x,_ l]J lx1 .. . ,t" - .x,l - XJ (3.8)Now we know how to find lhe degree 11 - i coefficiem. Using the recursive natureof (3.8),we can C\aluate it by using a Newton divided difference triangle.

    We tberefore specialize our discussion to the Newton form:P11 -t(X) =OJ+ 112(X- :q ) + OJ(X- .q ) (X- X:?)+ ... + an (X - Xl) . . (x- Xn-J). (3.9)

    Firsl. is it always possible to wri te the interpolating polynomial in thi s form? We show thatit is possible, by soJ,ing for the coefficients a; in term s of the data poults )';. For example.substituting .\'[ into the Newton fom1 (3.9) yields

    (3. iO)

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    19/22

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    20/22

    158 I CHAPTER 3 Interpolationa new poim where h' = 0. by Rolle's Theorem (see Chapter 0). I11ere are 11 of the e points.Between each pair of these, there must be a new point where lz" = 0: there are n - I oft.bese. Comjnuing in this way, there must be one point c for which h(">(c) = 0, where c liesbe tween the smallest and largest of x. XJ , x,. NOle that

    because the 11th derivative of the polynomial Pn-1 (t) is zero. Substituting c gives

    whicb leads toj (n) (c)

    f (x) = Pn - l (x ) + ( x - XJ) (.t - x,. ) ,n!using (3. t4).3.2.3 Runge phenomenonPolynomials can fit any set ofdata points. as Theorem 3.2 shows. However, there are someshapes that polynomials prefer over others. You can achleve a better understancling of thispoint by playing with Program 3.2. Try data p o i n ~ that cause Lhe function to be zero atequally spaced points x = -3 , -2.5, - 2. - 1.5 . . . . . 2.5, 3, except for x =0, where we seta value. of 1. Tbe data poi nts arc flat along the x-axis, except for a triangular "bump'' atx = 0, as shown in Figure 3.5.

    The polynomial that goes through points siruated like this refuses to stay between 0and 1. unlike Lbe data points. This is an illusu-:uion of the so-called Runge phenomenon.ft is usually used to describe extreme polynomial wiggle'' associated with high-degreepolynomial interpolation at evenly-spaced points.

    y

    Figure 3.5 Interpo la tion oftriangular bum p function. Theinterpoi

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    21/22

    EXAMPLE 3.9

    Exercises

    3.2 Interpolation Error I 159Interpolate f (x) = 1/(1 + 12x2) ar evenly-spaced points in ( -1. 1].

    This is called the Runge e..xample.. The function h:ts the same general shape as thetriangular bump in Figure 3.5. Figure 3.6 shows the result of the interpolation, behavior!.bat is characteristic of the Runge phenomenon: polynomial wiggle near the ends of heinterpolation interval.

    y y

    - X - X

    (a) (b)Figure 3.6 Runge example. Po lyn omial interpolation of the Runge function ofExample 3.9 at evenly spaced base points causes extreme variation near the endsof the interval, similar to Figure 3.5. (a) 15 base points (bl 25 base points.

    As we have seen, examples with the Runge phenomenon characteristically largeerror near the outside of the interval of data points. The cure for this problem is intuitive:Move some of the interpolation points toward the outside of he interval. where thefunctionproducing the data can be bener fiL We will see how to accomplish this in the next sectionon Chebyshev interpolation.

    1. (a) Find the degree 2 interpolating polynomial Pz(x) through the points {0, 0), (rr/2.1). and(rr, 0). (b) Calculate P2Crr/ 4), an approximation for sin(rr 4). (c) Use Theorem 3.3 ro give anerror bound for the approximation in part (b). (d) Using a calculator or M">TI.A.B, compare theactual error to your error bound.

    2. (a) Given the data points ( I. 0) , (2, In2), (4, ln4). find the degree 2 interpolating polynomial.(b) Use the result of (a) to approximate In 3. (c) Use Theorem 3.3 to give an error bound for theapproximation in part (b). (d) Compare the actual error to your error bound.

    3. Assume that the polynomial P9(x) interpolates the function f (x) = e-2:c ar the 10evenly-spaced points x= 0, 1/9, 2/ 9.3/9 ... ,S/9. 1. (a) Find an upper bound for the error1/(l/2)- 1'9(1 /2)1(b) How many decimal places can you guarantee to be correct if ?9 ( 1/2 )is used to approximatee- 1?

    4. Consider the interpolating polynomial for f (x) = 1/ (x + 5) with interpolation nodesx = 0,2, 4 ,6, 8. 10. Fmd an upper bound for the interpolation error at (a) x = I and (b) x = 5.

  • 7/27/2019 Numerical Analysis - Chapter3.pdf

    22/22

    160 I CHAPTER 3 Interpolation5. t\ s umc that a function f (x) bas been approxjmated by the degree 5 interpolating polynomial

    P (x) , using the data points (x, . f(x,)). where .q = .I. x2 = . l . XJ = .3 . x.t = 4, xs = 5, _X6 = .6. Do you expect the in!erpolation error lf(x) - P(x)l to be smaJler for x = .35 orforx = 55? Quantify your answer.

    6. Assume that rhe po lynomial P5(x) i m c r p o l a . t e ~ u function f(x) at the