Presentation is loading. Please wait.

Presentation is loading. Please wait.

LAGRANGE INTERPOLATING POLYNOMIALS

Similar presentations


Presentation on theme: "LAGRANGE INTERPOLATING POLYNOMIALS"β€” Presentation transcript:

1 LAGRANGE INTERPOLATING POLYNOMIALS
Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS

2 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
deg poly ? Consider the following polynomial L(1) = 𝐿 π‘₯ = (π‘₯βˆ’1)(π‘₯βˆ’2)(π‘₯βˆ’3)(π‘₯βˆ’4)(π‘₯βˆ’6)(π‘₯βˆ’7)(π‘₯βˆ’8)(π‘₯βˆ’9) (5βˆ’1)(5βˆ’2)(5βˆ’3)(5βˆ’4)(5βˆ’6)(5βˆ’7)(5βˆ’8)(5βˆ’9) L(2) = L(9) = L(8) = L(5) = Define: 𝑝 π‘₯ =100βˆ—πΏ π‘₯ Difference ? Lagrange interpolating polynomial

3 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
𝑳 𝟎 𝒙 = (π’™βˆ’πŸ)(π’™βˆ’πŸ‘) (πŸβˆ’πŸ)(πŸβˆ’πŸ‘) Consider 𝑳 𝟎 𝟏 = 𝑳 𝟎 𝟐 = 𝑳 𝟎 πŸ‘ = 𝒙 π’Š 𝒇(𝒙 π’Š ) 𝑳 𝟏 𝒙 = (π’™βˆ’πŸ)(π’™βˆ’πŸ‘) (πŸβˆ’πŸ)(πŸβˆ’πŸ‘) 𝑳 𝟏 𝟏 = 𝑳 𝟏 𝟐 = 𝑳 𝟏 πŸ‘ = 𝑳 𝟐 𝒙 = (π’™βˆ’πŸ)(π’™βˆ’πŸ) (πŸ‘βˆ’πŸ)(πŸ‘βˆ’πŸ) 𝑳 𝟐 𝟏 = 𝑳 𝟐 𝟐 = 𝑳 𝟐 πŸ‘ = 𝑷 𝒙 =πŸπŸŽπŸŽβˆ—π‘³ 𝟎 𝒙 + πŸ“πŸŽπŸŽβˆ—π‘³ 𝟏 𝒙 + πŸ—πŸŽπŸŽβˆ— 𝑳 𝟐 𝒙 𝑷 𝟏 = 𝑷 𝟐 = 𝑷 πŸ‘ = The Lagrange interpolating polynomial is simply a reformulation of the Newton polynomial that avoids the computation of divided differences.

4 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
The Lagrange interpolating polynomial is simply a reformulation of the Newton polynomial that avoids the computation of divided differences. π‘₯ 0 π‘₯ 1 π‘₯ π‘–βˆ’1 π‘₯ 𝑖 π‘₯ 𝑛 β‹― 𝑓(π‘₯ 0 ) 𝑓(π‘₯ 1 ) 𝑓(π‘₯ π‘–βˆ’1 ) 𝑓(π‘₯ 𝑖 ) 𝑓(π‘₯ 𝑛 ) Given the set of data 𝐿 𝑖 π‘₯ = (π‘₯βˆ’ π‘₯ 0 )(π‘₯βˆ’ π‘₯ 1 )β‹―(π‘₯βˆ’ π‘₯ π‘–βˆ’1 )(π‘₯βˆ’ π‘₯ 𝑖+1 )β‹―(π‘₯βˆ’ π‘₯ 𝑛 ) ( π‘₯ 𝑖 βˆ’ π‘₯ 0 )( π‘₯ 𝑖 βˆ’ π‘₯ 1 )β‹―( π‘₯ 𝑖 βˆ’ π‘₯ π‘–βˆ’1 )( π‘₯ 𝑖 βˆ’ π‘₯ 𝑖+1 )β‹―( π‘₯ 𝑖 βˆ’ π‘₯ 𝑛 ) Realize that each term Li (x) will be 1 at x = xi and 0 at all other sample points 𝐿 𝑖 π‘₯ = 𝑗=0 𝑗≠𝑖 𝑛 (π‘₯βˆ’ π‘₯ 𝑗 ) ( π‘₯ 𝑖 βˆ’ π‘₯ 𝑗 ) where designates the β€œproduct of 𝑝 𝑛 π‘₯ = 𝑖=1 𝑛 𝑓( π‘₯ 𝑖 )𝐿 𝑖 π‘₯ 𝑝 𝑛 π‘₯ is the unique nth order polynomial that passes exactly through all n + 1 data points.

5 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
Example 𝒙 π’Š 𝒇(𝒙 π’Š ) Estimate f (4) using Lagrange interpolating polynomials of order 3. Given the data 𝑳 𝟎 πŸ’ = βˆ’πŸ βˆ’πŸ– 𝑳 𝟎 𝒙 = (π’™βˆ’πŸ)(π’™βˆ’πŸ‘)(π’™βˆ’πŸ“) (πŸβˆ’πŸ)(πŸβˆ’πŸ‘)(πŸβˆ’πŸ“) = (π’™βˆ’πŸ)(π’™βˆ’πŸ‘)(π’™βˆ’πŸ“) βˆ’πŸ– 𝑳 𝟏 πŸ’ = βˆ’πŸ‘ πŸ‘ 𝑳 𝟏 𝒙 = (π’™βˆ’πŸ)(π’™βˆ’πŸ‘)(π’™βˆ’πŸ“) (πŸβˆ’πŸ)(πŸβˆ’πŸ‘)(πŸβˆ’πŸ“) = (π’™βˆ’πŸ)(π’™βˆ’πŸ‘)(π’™βˆ’πŸ“) πŸ‘ 𝑳 𝟐 𝒙 = (π’™βˆ’πŸ)(π’™βˆ’πŸ)(π’™βˆ’πŸ“) (πŸ‘βˆ’πŸ)(πŸ‘βˆ’πŸ)(πŸ‘βˆ’πŸ“) = (π’™βˆ’πŸ)(π’™βˆ’πŸ‘)(π’™βˆ’πŸ“) βˆ’πŸ’ 𝑳 𝟐 πŸ’ = βˆ’πŸ” βˆ’πŸ’ 𝑳 πŸ‘ πŸ’ == πŸ” πŸπŸ’ 𝑳 πŸ‘ 𝒙 = (π’™βˆ’πŸ)(π’™βˆ’πŸ)(π’™βˆ’πŸ‘) (πŸ“βˆ’πŸ)(πŸ“βˆ’πŸ)(πŸ“βˆ’πŸ‘) = (π’™βˆ’πŸ)(π’™βˆ’πŸ)(π’™βˆ’πŸ‘) πŸπŸ’ 𝒑 πŸ‘ 𝒙 =βˆ’πŸ– 𝑳 𝟎 𝒙 + πŸ” 𝑳 𝟏 𝒙 + πŸπŸ” 𝑳 𝟐 𝒙 + πŸ’πŸ–π‘³ πŸ‘ 𝒙 𝒑 πŸ‘ πŸ’ =βˆ’πŸ– 𝑳 𝟎 πŸ’ + πŸ” 𝑳 𝟏 πŸ’ + πŸπŸ” 𝑳 𝟐 πŸ’ + πŸ’πŸ–π‘³ πŸ‘ πŸ’ 𝒑 πŸ‘ πŸ’ =βˆ’πŸ– 𝟏 πŸ’ +πŸ” βˆ’πŸ +πŸπŸ” πŸ‘ 𝟐 +πŸ’πŸ– 𝟏 πŸ’ =πŸπŸ–

6 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
Derivation of the Lagrange Form Directly from Newton’s Interpolating Polynomial 𝒙 𝟎 𝒇(𝒙 𝟎 ) 𝒙 𝟏 𝒇(𝒙 𝟏 ) NEWTON’S INTERPOLATING POLYNOMIAL LANGRANGE INTERPOLATING POLYNOMIAL 𝒑 𝟏 𝒙 =𝒇[ 𝒙 𝟎 ]+𝒇[ 𝒙 𝟏 , 𝒙 𝟎 ] π’™βˆ’ 𝒙 𝟎 𝑝 1 π‘₯ =𝒇( 𝒙 𝟎 ) 𝑳 𝟎 (𝒙)+𝒇( 𝒙 𝟏 ) 𝑳 𝟏 (𝒙) =𝒇( 𝒙 𝟎 )+ 𝒇 𝒙 𝟏 βˆ’π’‡( 𝒙 𝟎 ) 𝒙 𝟏 βˆ’ 𝒙 𝟎 π’™βˆ’ 𝒙 𝟎 =𝒇 𝒙 𝟎 π’™βˆ’ 𝒙 𝟏 𝒙 𝟎 βˆ’ 𝒙 𝟏 + 𝒇( 𝒙 𝟏 ) (π’™βˆ’ 𝒙 𝟎 ) ( 𝒙 𝟏 βˆ’ 𝒙 𝟎 ) =𝒇( 𝒙 𝟎 )+ 𝒇 𝒙 𝟏 βˆ’π’‡( 𝒙 𝟎 ) 𝒙 𝟏 βˆ’ 𝒙 𝟎 π’™βˆ’ 𝒙 𝟎 =𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 π’™βˆ’ 𝒙 𝟎 𝒙 𝟏 βˆ’ 𝒙 𝟎 βˆ’π’‡ 𝒙 𝟎 π’™βˆ’ 𝒙 𝟎 𝒙 𝟏 βˆ’ 𝒙 𝟎 =𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 π’™βˆ’ 𝒙 𝟎 𝒙 𝟏 βˆ’ 𝒙 𝟎 +𝒇 𝒙 𝟎 π’™βˆ’ 𝒙 𝟎 𝒙 𝟎 βˆ’ 𝒙 𝟏 =𝒇 𝒙 𝟎 𝟏+ π’™βˆ’ 𝒙 𝟎 𝒙 𝟎 βˆ’ 𝒙 𝟏 +𝒇 𝒙 𝟏 π’™βˆ’ 𝒙 𝟎 𝒙 𝟏 βˆ’ 𝒙 𝟎 𝒇 𝒙 𝟎 π’™βˆ’ 𝒙 𝟏 𝒙 𝟎 βˆ’ 𝒙 𝟏 + 𝒇( 𝒙 𝟏 ) (π’™βˆ’ 𝒙 𝟎 ) ( 𝒙 𝟏 βˆ’ 𝒙 𝟎 )

7 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
Example 𝒙 π’Š 𝒇(𝒙 π’Š ) Estimate f (4) using Lagrange interpolating polynomials of order 3. Given the data function [yy] = langrange(x,y,xx) n = length(x); sum = 0; for i=1:n product = y(i); for j=1:n if (i~= j) ; product = product*(xx-x(j))/(x(i)-x(j)); end sum = sum + product; yy = sum; x=[ ] y=[ ] [yy] = langrange(x,y,4) [d]=Divided_diff(x,y); [yi] = eval_poly(x,d,4)

8 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
Errors of Lagrange Interpolating Polynomials 𝑓 π‘₯ βˆ’ 𝑝 𝑛 π‘₯ = 𝑹 𝒏 (𝒙) 𝑓 π‘₯ βˆ’ 𝑖=1 𝑛 𝑓( π‘₯ 𝑖 )𝐿 𝑖 π‘₯ = 𝑓 𝑛+1 πœ‰ (𝑛+1)! 𝒋=𝟎 𝒏 π’™βˆ’ π‘₯ 𝑗 𝑹 𝒏 (𝒙)=𝒇[ 𝒙,𝒙 𝒏 , β‹―,𝒙 𝟎 ] 𝒋=𝟎 𝒏 π’™βˆ’ π‘₯ 𝑗 if an additional point is available at x = xn+1, an error estimate can be obtained 𝑹 𝒏 (𝒙)β‰ˆπ’‡[ 𝒙 𝒏+𝟏 ,𝒙 𝒏 , β‹―,𝒙 𝟎 ] 𝒋=𝟎 𝒏 π’™βˆ’ π‘₯ 𝑗

9 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
In summary, for cases where the order of the polynomial is unknown, the Newton method has advantages because of the insight it provides into the behavior of the different order formulas. In addition, the error estimate can usually be integrated easily into the Newton computation because the estimate employs a finite difference. Thus, for exploratory computations, Newton’s method is often preferable. When only one interpolation is to be performed, the Lagrange and Newton formulations require comparable computational effort. However, the Lagrange version is somewhat easier to program. Because it does not require computation and storage of divided differences, the Lagrange form is often used when the order of the polynomial is known a priori.

10 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
The interpolating polynomial with high degree oscillates wildly Figure shows a ruddy duck in flight. To approximate the top profile of the duck, we have chosen points along the curve through which we want the approximating curve to pass. The table lists the coordinates of 21 data. Notice that more points are used when the curve is changing rapidly than when it is changing more slowly.

11 Sec:18.2 LAGRANGE INTERPOLATING POLYNOMIALS
close all; clc; clear; xdata=[ ]; ydata=[ ]; x=xdata(1:2:21); y=ydata(1:2:21); xq = 0.9:0.01:13.3; [yq] = langrange(x,y,xq); plot(xq,yq,'-r','linewidth',1.5)


Download ppt "LAGRANGE INTERPOLATING POLYNOMIALS"

Similar presentations


Ads by Google