Interpolation, Extrapolation & Polynomial Approximation

Download Interpolation, Extrapolation & Polynomial Approximation

Post on 13-Jan-2017

212 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

<ul><li><p>Interpolation, Extrapolation&amp;</p><p>Polynomial Approximation</p><p>November 21, 2017</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Introduction</p><p>In many cases we know the values of a function f (x) at a set of pointsx1, x2, ..., xN , but we dont have the analytic expression of the functionthat lets us calculate its value at an arbitrary point. We will try toestimate f (x) for arbitrary x by drawing a curve through the xi andsometimes beyond them.</p><p>The procedure of estimating the value of f (x) for x [x1, xN ] is calledinterpolation while if the value is for points x / [x1, xN ] extrapolation.The form of the function that approximates the set of points should be aconvenient one and should be applicable to a general class of problems.</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Polynomial Approximations</p><p>Polynomial functions are the most common ones while rational andtrigonometric functions are used quite frequently.</p><p>We will study the following methods for polynomial approximations:</p><p>Lagranges Polynomial</p><p>Hermite Polynomial</p><p>Taylor Polynomial</p><p>Cubic Splines</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Lagrange Polynomial</p><p>Lets assume the following set of data:</p><p>x0 x1 x2 x3x 3.2 2.7 1.0 4.8f (x) 22.0 17.8 14.2 38.3</p><p>f0 f1 f2 f3</p><p>Then the interpolating polynomial will be of 4th order i.e.ax3 + bx2 + cx + d = P(x). This leads to 4 equations for the 4 unknowncoefficients and by solving this system we get a = 0.5275, b = 6.4952,c = 16.117 and d = 24.3499 and the polynomial is:</p><p>P(x) = 0.5275x3 + 6.4952x2 16.117x + 24.3499</p><p>It is obvious that this procedure is quite laboureus and Lagrangedeveloped a direct way to find the polynomial</p><p>Pn(x) = f0L0(x) + f1L1(x) + ....+ fnLn(x) =n</p><p>i=0</p><p>fiLi (x) (1)</p><p>where Li (x) are the Lagrange coefficient polynomials</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Lj(x) =(x x0)(x x1)...(x xj1)(x xj+1)...(x xn)</p><p>(xj x0)(xj x1)...(xj xj1)(xj xj+1)...(xj xn)(2)</p><p>and obviously:</p><p>Lj(xk) = jk =</p><p>{0 if j 6= k1 if j = k</p><p>where jk is Kroneckers symbol.</p><p>ERRORSThe error when the Lagrange polynomial is used to approximate acontinuous function f (x) is :</p><p>E (x) = (x x0)(x x1)....(x xn)f (n+1)()</p><p>(n + 1)!where [x0, xN ] (3)</p><p>NOTE Lagrange polynomial applies for evenly and unevenly spaced points. If the points are evenly spaced then it reduces to a much simpler form.</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Lagrange Polynomial : Example</p><p>EXAMPLE: Find the Lagrange polynomialthat approximates the function y = cos(x).We create the table</p><p>xi 0 0.5 1fi 1 0.0 -1</p><p>The Lagrange coeffiecient polynomials are:</p><p>L1(x) =(x x2)(x x3)</p><p>(x1 x2)(x1 x3)=</p><p>(x 0.5)(x 1)(0 0.5)(0 1)</p><p>= 2x2 3x + 1,</p><p>L2(x) =(x x1) (x x3)</p><p>(x2 x1)(x2 x3)=</p><p>(x 0)(x 1)(0.5 0)(0.5 1)</p><p>= 4x(x 1)</p><p>L3(x) =(x x1)(x x2)</p><p>(x3 x1)(x3 x2)=</p><p>(x 0)(x 0.5)(1 0)(1 0.5)</p><p>= 2x2 x</p><p>thus</p><p>P(x) = 1 (2x2 3x + 1) 0 4x(x 1) + (1) (2x2 x) = 2x + 1</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>The error will be:</p><p>E (x) = x (x 0.5) (x 1)3 sin()</p><p>3!</p><p>e.g. for x = 0.25 is E (0.25) 0.24.</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Newton Polynomial</p><p>Forward Newton-Gregory</p><p>Pn(xs) = f0 + s f0 +s(s 1)</p><p>2!2f0 +</p><p>s(s 1)(s 2)3!</p><p>3f0 + ...</p><p>= f0 +</p><p>(s1</p><p>)f0 +</p><p>(s2</p><p>)2f0 +</p><p>(s3</p><p>)3f0 + ...</p><p>=n</p><p>i=0</p><p>(si</p><p>)i f0 (4)</p><p>where xs = x0 + s h and</p><p>fi = fi+1 fi (5)2fi = fi+2 2fi+1 + fi (6)3fi = fi+3 3fi+2 + 3fi+1 fi (7)</p><p>nfi = fi+n nfi+n1 +n(n 1)</p><p>2!fi+n2 </p><p>n(n 1)(n 2)3!</p><p>fi+n3 + (8)</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Newton Polynomial</p><p>ERROR The error is the same with the Lagrange polynomial :</p><p>E (x) = (x x0)(x x1)....(x xn)f (n+1)()</p><p>(n + 1)!where [x0, xN ] (9)</p><p>x f (x) f (x) 2f (x) 3f (x) 4f (x) 5f (x)0.0 0.000</p><p>0.2030.2 0.203 0.017</p><p>0.220 0.0240.4 0.423 0.041 0.020</p><p>0.261 0.044 0.0320.6 0.684 0.085 0.052</p><p>0.246 0.0960.8 1.030 0.181</p><p>0.5271.0 1.557</p><p>Table: Example of a difference matrix</p><p>Backward Newton-Gregory</p><p>Pn(x) = f0+</p><p>(s1</p><p>)f1+</p><p>(s + 1</p><p>2</p><p>)2f2+...+</p><p>(s + n 1</p><p>n</p><p>)nfn</p><p>(10)</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>x F (x) f (x) 2f (x) 3f (x) 4f (x) 5f (x)0.2 1.06894</p><p>0.112420.5 1.18136 0.01183</p><p>0.12425 0.001230.8 1.30561 0.01306 0.00015</p><p>0.13731 0.00138 0.0000011.1 1.44292 0.01444 0.00014</p><p>0.15175 0.01521.4 1.59467 0.01596</p><p>0.167711.7 1.76238</p><p>Newton-Gregory forward with x0 = 0.5:</p><p>P3(x) = 1.18136 + 0.12425 s + 0.01306</p><p>(s2</p><p>)+ 0.00138</p><p>(s3</p><p>)= 1.18136 + 0.12425 s + 0.01306 s (s 1)/2 + 0.00138 s (s 1) (s 2)/6= 0.9996 + 0.3354 x + 0.052 x2 + 0.085 x3</p><p>Newton-Gregory backwards with x0 = 1.1:</p><p>P3(x) = 1.44292 + 0.13731 s + 0.01306</p><p>(s + 1</p><p>2</p><p>)+ 0.00123</p><p>(s + 2</p><p>3</p><p>)= 1.44292 + 0.13731 s + 0.01306 s (s + 1)/2 + 0.00123 s (s + 1) (s + 2)/6= 0.99996 + 0.33374 x + 0.05433 x2 + 0.007593 x3</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Hermite Polynomial</p><p>This applies when we have information not only for the values of f (x)but also on its derivative f (x)</p><p>P2n1(x) =n</p><p>i=1</p><p>Ai (x)fi +n</p><p>i=1</p><p>Bi (x)fi (11)</p><p>where</p><p>Ai (x) = [1 2(x xi )Li (xi )] [Li (x)]2 (12)</p><p>Bi (x) = (x xi ) [Li (x)]2 (13)</p><p>and Li (x) are the Lagrange coefficients.</p><p>ERROR: the accuracy is similar to that of Lagrange polynomial of order2n!</p><p>y(x) p(x) = y(2n+1)()</p><p>(2n + 1)![(x x1)(x x2) . . . (x xn)]2 (14)</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Hermite Polynomial : Example</p><p>Fit a Hermite polynomial to thedata of the table:</p><p>k xk yk yk</p><p>0 0 0 01 4 2 0</p><p>The Lagrange coefficients are:</p><p>L0(x) =x x1x0 x1</p><p>=x 40 4</p><p>= x 44</p><p>L1(x) =x x0x1 x0</p><p>=x</p><p>4</p><p>L0(x) =1</p><p>x0 x1= 1</p><p>4L1(x) =</p><p>1</p><p>x1 x0=</p><p>1</p><p>4</p><p>Thus</p><p>A0(x) =[</p><p>1 2 L0(x x0)] L20 =</p><p>[1 2 </p><p>(</p><p>1</p><p>4</p><p>)(x 0)</p><p>](</p><p>x 44</p><p>)2A1(x) =</p><p>[1 2 L0(x x1)</p><p>] L21 =</p><p>[1 2 </p><p>1</p><p>4(x 4)</p><p>](</p><p>x</p><p>4</p><p>)2=</p><p>(3 </p><p>x</p><p>2</p><p>)(</p><p>x</p><p>4</p><p>)2B0(x) = (x 0) </p><p>(x 4</p><p>4</p><p>)2= x</p><p>(x 4</p><p>4</p><p>)2B1(x) = (x 4) </p><p>(x</p><p>4</p><p>)2And the Hermite polynomial is:</p><p>P(x) = (6 x)x2</p><p>16.</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Taylor Polynomial</p><p>It is an alternative way of approximating functions with polynomials. Inthe previous two cases we found the polynomial P(x) that gets the samevalue with a function f (x) at N points or the polynomial that agrees witha function and its derivative at N points. Taylor polynomial has the samevalue x0 with the function but agrees also up to the Nth derivative withthe given function. That is:</p><p>P(i)(x0) = f(i)(x0) and i = 0, 1, ..., n</p><p>and the Taylor polynomial has the well known form from Calculus</p><p>P(x) =Ni=0</p><p>f (i)(x)</p><p>i !(x x0)i (15)</p><p>ERROR: was also estimated in calculus</p><p>EN(x) = (x x0)N+1f (N+1)()</p><p>(N + 1)!(16)</p><p>Interpolation, Extrapolation &amp; Polynomial Approximation</p></li><li><p>Taylor Polynomial : Example</p><p>We will show that for the calculation of e = 2.718281828459... with13-digit approximation we need 15 terms of the Taylor expansion.All the derivatives at x = 1 are:</p><p>y0 = y(1)0 = y</p><p>(2)0 = ... = y</p><p>(n)0 = 1</p><p>thus</p><p>p(x) =n</p><p>i=1</p><p>1</p><p>i !xn = 1 + x +</p><p>x2</p><p>2+ ...+</p><p>1</p><p>n!xn</p><p>and the error will be</p><p>|En| = xn+1e</p><p>(n + 1)!=</p><p>e</p><p>16!</p></li></ul>