Interpolation, Extrapolation & Polynomial Approximation

Interpolation, Extrapolation & Polynomial Approximation

Interpolation, Extrapolation & Polynomial Approximation Kostas Kokkotas November 11, 2019 Eberhard Karls University of T¨ubingen 1 Introduction In many cases we know the values of a function f (x) at a set of points x1, x2, ..., xN , but we don't have the analytic expression of the function that lets us calculate its value at an arbitrary point. We will try to estimate f (x) for arbitrary x by \drawing" a curve through the xi and sometimes beyond them. The procedure of estimating the value of f (x) for x 2 [x1; xN ] is called interpolation while if the value is for points x 2= [x1; xN ] extrapolation. The form of the function that approximates the set of points should be a convenient one and should be applicable to a general class of problems. 2 Polynomial Approximations Polynomial functions are the most common ones while rational and trigonometric functions are used quite frequently. We will study the following methods for polynomial approximations: • Lagrange's Polynomial • Hermite Polynomial • Taylor Polynomial • Cubic Splines 3 Lagrange Polynomiali Let's assume the following set of data: x0 x1 x2 x3 x 3:2 2:7 1:0 4:8 f (x) 22:0 17:8 14:2 38:3 f0 f1 f2 f3 Then the interpolating polynomial will be of 4th order i.e. ax 3 + bx 2 + cx + d = P(x). This leads to 4 equations for the 4 unknown coefficients 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(x) = −0:5275x 3 + 6:4952x 2 − 16:117x + 24:3499 4 Lagrange Polynomial ii It is obvious that this procedure is quite laboureous and Lagrange developed a direct way to find the polynomial n X Pn(x) = f0L0(x) + f1L1(x) + :::: + fnLn(x) = fi Li (x) (1) i=0 where Li (x) are the Lagrange coefficient polynomials (x − x0)(x − x1):::(x − xj−1)(x − xj+1):::(x − xn) Lj (x)= (2) (xj − x0)(xj − x1):::(xj − xj−1)(xj − xj+1):::(xj − xn) and obviously: ( 0 if j 6= k Lj (xk )= δjk = 1 if j = k where δjk is Kronecker's symbol. 5 Lagrange Polynomial iii ERRORS The error when the Lagrange polynomial is used to approximate a continuous function f (x) is : f (n+1)(ξ) E(x) = (x − x )(x − x )::::(x − x ) where ξ 2 [x ; x ] (3) 0 1 n (n + 1)! 0 N NOTE • Lagrange polynomial applies for evenly and unevenly spaced points. • If the points are evenly spaced then it reduces to a much simpler form. 6 Lagrange Polynomial : Examplei EXAMPLE: Find the Lagrange polynomial that approximates the function y = cos(πx). We create the table i 1 2 3 xi 0 0.5 1 fi 1 0.0 -1 The Lagrange coeffiecient polynomials are: (x − x2)(x − x3) (x − 0:5)(x − 1) 2 L1(x)= = =2 x − 3x + 1 ; (x1 − x2)(x1 − x3) (0 − 0:5)(0 − 1) (x − x1)(x − x3) (x − 0)(x − 1) L2(x)= = = −4x(x − 1) (x2 − x1)(x2 − x3) (0:5 − 0)(0:5 − 1) (x − x1)(x − x2) (x − 0)(x − 0:5) 2 L3(x)= = =2 x − x (x3 − x1)(x3 − x2) (1 − 0)(1 − 0:5) 7 Lagrange Polynomial : Example ii thus P(x)= f1 · L1(x)+ f2 · L2(x)+ f3 · L3(x) =1 · (2x 2 − 3x + 1) − 0 · 4x(x − 1)+( −1) · (2x 2 − x) = −2x + 1 The error will be: π3 sin(πξ) E(x) = x · (x − 0:5) · (x − 1) 3! e.g. for x = 0:25 is E(0:25) ≤ 0:24. 8 Newton Polynomiali Forward Newton-Gregory s(s − 1) s(s − 1)(s − 2) P (x )= f + s · ∆f + · ∆2f + · ∆3f + ::: n s 0 0 2! 0 3! 0 ! ! ! s s 2 s 3 = f0 + · ∆f0 + · ∆ f0 + · ∆ f0 + ::: 1 2 3 n ! X s i = · ∆ f0 (4) i i=0 where xs = x0 + s · h and ∆fi = fi+1 − fi (5) 2 ∆ fi = fi+2 − 2fi+1 + fi (6) 3 ∆ fi = fi+3 − 3fi+2 + 3fi+1 − fi (7) n(n − 1) n(n − 1)(n − 2) ∆nf = f − nf + f − f + ···(8) i i+n i+n−1 2! i+n−2 3! i+n−3 9 Newton Polynomial ii x f (x) ∆f (x) ∆2f (x) ∆3f (x) ∆4f (x) ∆5f (x) 0.0 0.000 0.203 0.2 0.203 0.017 0.220 0.024 0.4 0.423 0.041 0.020 0.261 0.044 0.032 0.6 0.684 0.085 0.052 0.246 0.096 0.8 1.030 0.181 0.527 1.0 1.557 Table 1: Example of a difference matrix ERROR The error is the same with the Lagrange polynomial : f (n+1)(ξ) E(x) = (x − x )(x − x )::::(x − x ) where ξ 2 [x ; x ] (9) 0 1 n (n + 1)! 0 N and since xs = x0 + s · h, it can be written as: f (n+1)(ξ) E (x ) = s(s − 1)(s − 2):::(s − n)hn+1 where ξ 2 [x ; x ] (10) n s (n + 1)! 0 N 10 Newton Polynomial iii Backward Newton-Gregory ! ! ! s s + 1 2 s + n − 1 n Pn(x) = f0 + · ∆f−1 + · ∆ f−2 + ::: + · ∆ f−n 1 2 n (11) x F (x) ∆f (x) ∆2f (x) ∆3f (x) ∆4f (x) ∆5f (x) 0.2 1.06894 0.11242 0.5 1.18136 0.01183 0.12425 0.00123 0.8 1.30561 0.01306 0.00015 0.13731 0.00138 0.000001 1.1 1.44292 0.01444 0.00014 0.15175 0.0152 1.4 1.59467 0.01596 0.16771 1.7 1.76238 11 Newton Polynomial iv EXAMPLE: Newton-Gregory forward with x0 = 0:5: ! ! s s P3(x)=1 :18136 + 0:12425 s + 0:01306 + 0:00138 2 3 = 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 x 2 + 0:085 x 3 EXAMPLE: Newton-Gregory backwards with x0 = 1:1: ! ! s + 1 s + 2 P3(x)=1 :44292 + 0:13731 s + 0:01306 + 0:00123 2 3 = 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 x 2 + 0:007593 x 3 12 Newton Polynomialv EXAMPLE: Prove that the Lagrange polynomial is reduced Newton Gregory if the points are equally spaced (try a 2nd order polynomial i.e. only 3 points) P(x) = L1f1 + L2f2 + L3f3 (12) where (x − x2)(x − x3) (x − x2)(x − x3) (s − 1)(s − 2) L1(x) = = 2 = (x1 − x2)(x1 − x3) 2h 2 (x − x1)(x − x3) (x − x1)(x − x3) L2(x) = = 2 = −s(s − 2) (x2 − x1)(x2 − x3) −h (x − x1)(x − x2) (x − x1)(x − x2) s(s − 1) L3(x) = = 2 = (x3 − x1)(x3 − x2) 2h 2 Here we used that : x − x s = 1 and x − x = sh ; x − x = h(s − 1) ; x − x = h(s − 2) (13) h 1 2 3 13 Newton Polynomial vi Thus the Lagrange polynomial will be (s − 1)(s − 2) s(s − 1) P (x) = f − s(s − 2)f + f (14) 2 2 1 2 2 3 while the Newton-Gregory formula gives: s(s − 1) P (x ) = f + s · ∆f + · ∆2f 2 s 1 1 2 1 s(s − 1) = f + s (f − f ) + (f − 2f + f ) 1 2 1 2 2 2 1 = ::: (15) 14 Hermite Polynomiali This applies when we have information not only for the values of f (x) but also on its derivative f 0(x) n n X X 0 P2n−1(x) = Ai (x)fi + Bi (x)fi (16) i=1 i=1 where 0 2 Ai (x) = 1 − 2(x − xi )Li (xi ) · [Li (x)] (17) 2 Bi (x) = (x − xi ) · [Li (x)] (18) and Li (x) are the Lagrange coefficients. ERROR: the accuracy is similar to that of Lagrange polynomial of order2 n! y (2n+1)(ξ) y(x) − p(x) = [(x − x )(x − x ) ::: (x − x )]2 (19) (2n + 1)! 1 2 n 15 Hermite Polynomial ii Example 0 k xk yk yk 0 0 0 0 Fit a Hermite polynomial to the data of the table: 1 4 2 0 The Lagrange coefficients are: x − x1 x − 4 x − 4 L0(x) = = = − x0 − x1 0 − 4 4 x − x0 x L1(x) = = x1 − x0 4 0 1 1 L0(x) = = − x0 − x1 4 0 1 1 L1(x) = = x1 − x0 4 16 Hermite Polynomial iii Thus 1 x − 4 2 A (x) = 1 − 2 · L0 (x − x ) · L2 = 1 − 2 · − (x − 0) · 0 0 0 0 4 4 1 x 2 x x 2 A (x) = 1 − 2 · L0 (x − x ) · L2 = 1 − 2 · (x − 4) · = 3 − · 1 0 1 1 4 4 2 4 x − 4 2 x − 4 2 B (x) = (x − 0) · = x 0 4 4 x 2 B (x) = (x − 4) · 1 4 And the Hermite polynomial is: 1 P(x) = (6 − x)x 2: 16 17 Taylor Polynomiali It is an alternative way of approximating functions with polynomials. In the previous two cases we found the polynomial P(x) that gets the same value with a function f (x) at N points or the polynomial that agrees with a function and its derivative at N points. Taylor polynomial has the same value x0 with the function but agrees also up to the Nth derivative with the given function.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    38 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us