0 views

Uploaded by duyvu

lecture

- Factoring Trinomials Test PDF
- Lab 1 Writeup
- 2016 Yr 11 Extn 1 Assessment Task 2
- Fuzzy Interpolation and Extrapolation_a Pratical Approach
- MAT575 2009-1
- Structure
- AutoCAD 2012 - Command Alias - Martin M.
- DFT
- math 10 1st
- Gegen Bauer poly
- IMOMATH - Equations in polynomials
- ChE516 Chapter 3
- Set of Real Numbers_edition2a.pdf
- Data Analysis
- Reversible Data Hiding using Improved Interpolation Technique
- adding subtracting polynomials
- 27_ftp
- Carl Benjamin Boyer - Cardan and the Pascal triangle
- Rr10106-Introductions to Computers
- addingsubtracting polynomials

You are on page 1of 18

Slide 1 of 10

Lecture 14a

Lagrange Interpolation

Brian G. Higgins

Department of Chemical Engineering & Materials Science

University of California, Davis

April 2014, Hanoi, Vietnam

ECM6Lecture14aVietnam_2014.nb

Concept of Interpolation

In a previous lecture we were given a set of data points

88x0 , y0 <, 8x1 , y1 <, 8x2 , y2 <, 8x3 , y3 <, , 8xM , yM <<

and our goal was to find a polynomial that was a best fit of the data in the least squares sense. That

is, we selected the coefficients ai of the polynomial

P HxL = a0 + a1 x + a2 x2 + a3 x3 + + an xn

such that square of the error

M

E2 HPL = HP Hxi L - yi L2

i=1

was minimized. This was called linear regression. An alternative approach is to find a polynomial PHxL

such that

P Hxi L = yi , i = 0, 1, 2, , M

Thus we want to find the polynomial that passes through each data point.

In other words we require that the error at each xi be zero. This is the concept of polynomial interpolation.

We will see later in this lecture that interpolation is the corner stone for constructing algorithms for

implementing numerical integration.

ECM6Lecture14aVietnam_2014.nb

Suppose we are given a set of 2 data points:

We would like to find a linear polynomial

P1 HxL = a0 + a1 x

such that

P1 Hx0 L = a0 + a1 x0 = y0

P1 Hx1 L = a0 + a1 x1 = y1

Thus we have two equations for the two unknowns a0 and a1 . Solving this system of linear equations

gives

a1 =

y1 - y0

x1 - x0

a0 =

x1 y0 - x0 y1

x1 - x0

P1 HxL =

x1 y0 - x0 y1

x1 - x0

y1 - y0

x1 - x0

P1 HxL =

Hx - x1 L

Hx0 - x1 L

y0 +

Hx - x0 L

Hx1 - x0 L

x0 x x1

y1 ,

This formula is a linear interpolation of y between x0 and x1 . Linear interpolation is widely used to

interpolate thermodynamic tables, as illustrated in the following example.

Example 1

Thermodynamic steam tables give the enthalpy of steam at 20 MPa as a function of temperature

T (C)

70

80

h (kJ/kg)

309.26

350.78

We will use linear interpolation to determine the enthalpy h at temperatures between 70 and 80 C .

Substituting the above data points into Eq. (10) gives

h HTL =

HT - 80L

H70 - 80L

309.26 +

HT - 70L

H80 - 70L

350.78

= 18.62+ 4.152 T

If we have more that two data points then it is possible to determine a higher order polynomial. In short

if we have n+1 data points we can find n+1 interpolating conditions given by Eq. (4) to determine n+1

polynomial conditions. We discuss this next

ECM6Lecture14aVietnam_2014.nb

If we have more that two data points then it is possible to determine a higher order polynomial. In short

if we have n+1 data points we can find n+1 interpolating conditions given by Eq. (4) to determine n+1

polynomial conditions. We discuss this next

ECM6Lecture14aVietnam_2014.nb

Suppose we are given n+1 data points of the form

88x0 , y0 <, 8x1 , y1 <, 8x2 , y2 <, 8x3 , y3 <, , 8xn , yn <<

and we want to determine a polynomial of degree n or less which passes through those points. We

begin our discussion by considering following polynomial

P HxL = c0 Hx - x1 L Hx - x2 L Hx - x3 L Hx - xn L

+ c1 Hx - x0 L Hx - x2 L Hx - x3 L Hx - xn L

+ c2 Hx - x0 L Hx - x1 L Hx - x3 L Hx - xn L

+

+ cn Hx - x0 L Hx - x1 L Hx - x2 L Hx - xn-1 L

Note that each term in the above expression is a polynomial of degree n. Thus the degree of P(x) is

also n.

Next we want to determine the values of ci such that the polynomial passes through all the yi in our

data set.

If we set x = x0 it follows from the construction of our polynomial that

P Hx0 L = c0 Hx0 - x1 L Hx0 - x2 L Hx0 - x3 L Hx0 - xn L = y0

Solving for c0 gives

c0 =

y0

Hx0 - x1 L Hx0 - x2 L Hx0 - x3 L Hx0 - xn L

y1

c1 =

Hx1 - x0 L Hx1 - x2 L Hx1 - x3 L Hx1 - xn L

c2 =

y2

Hx2 - x0 L Hx2 - x1 L Hx2 - x3 L Hx2 - xn L

cn =

yn

Hxn - x0 L Hxn - x1 L Hxn - x2 L Hxn - xn-1 L

ECM6Lecture14aVietnam_2014.nb

Substituting the above coefficients (see previous slide) into the polynomial we get

N

P HxL = Pj HxL

j=0

N

Pj HxL = yj

k=0

x - xk

xj - xk

kj

Note we have color coded the indices to emphasize how the product sum is formed. If we write out the

interpolating polynomial explicitly we get

Hx - x1 L Hx - x2 L Hx - x3 L Hx - xn L

P HxL =

y0

Hx - x0 L Hx - x2 L Hx - x3 L Hx - xn L

y1

+

+

Hx - x0 L Hx - x1 L Hx - x2 L Hx - xn-1 L

Hxn - x0 L Hxn - x1 L Hxn - x2 L Hxn - xn-1 L

yn

Thus if you select one of the interpolating points x j , then all P j HxL terms vanish except the Pi HxL for the

given point of interest. It is sometimes more convenient to express the functions as

Pj HxL = yj fj ,

N

where

fj =

k=0

x - xk

xj - xk

kj

so that

N

f0 =

k=0

x - xk

x0 - xk

x - x1

x - x2

x - x3

x0 - x1 x0 - x2 x0 - x3

x - xN

x0 - xN

k0

f1 =

k=0

x - xk

x0 - xk

x - x0

x - x2

x - x3

x1 - x0 x1 - x2 x1 - x3

x - xN

x1 - xN

k1

etc

The set of f j 's can be thought of as set of basis functions, and y j the interpolation points. Note further

that since kj, the denominator in the product sum can never be zero.

ECM6Lecture14aVietnam_2014.nb

The set of f j 's can be thought of as set of basis functions, and y j the interpolation points. Note further

that since kj, the denominator in the product sum can never be zero.

ECM6Lecture14aVietnam_2014.nb

Example 1

Determine the interpolation polynomial for the points

{{0,-3},{1,0},{3,30},{5,132}}

Substituting these values into our interpolating polynomial (19) gives

P HxL =

H0-1L H0-3L H0-5L

H-3L

Hx-3L Hx-5L

+ Hx-0L

H0L

H1-0L H1-3L H1-5L

H3-0L H3-1L H3-5L

H30L

H5-0L H5-1L H5-3L

H132L

Note that since y1 = 0 , the second term in the expression vanishes. Expanding the above polynomial

gives

P HxL = x2 + 2 x - 3

Here is a plot of the data and the polynomial

ECM6Lecture14aVietnam_2014.nb

P@x_D := x3 + 2 x - 3

plt1 = ListPlot@data, PlotStyle 8Red, PointSize@LargeD<,

Frame True, FrameLabel 8Style@"x", 16D, Style@"PHxL", 16D<D;

plt2 = Plot@P@xD, 8x, 0, 5<, PlotStyle 8Blue, Thick<,

Frame True, FrameLabel 8"x", "PHxL"<D;

Show@plt1, plt2, PlotRange AllD

120

100

PHxL

80

60

40

20

0

0

10

ECM6Lecture14aVietnam_2014.nb

Background

The Mathematica function InterpolatingPolynomial generates the interpolating polynomial we have

discussed above. Thus suppose we want to have a polynomial pass through the points

{{0,-3},{1,0},{3,30},{5,132}}

P3 = InterpolatingPolynomial@880, - 3<, 81, 0<, 83, 30<, 85, 132<<, xD

- 3 + x H3 + H- 1 + xL H1 + xLL

Simplify@P3D

- 3 + 2 x + x3

Example 1

In this example we are given the following data points

{{1,4},{2,8},{3,4},{5,-2}}

And we want to find the interpolating polynomial that passes through the points

P3 = InterpolatingPolynomial@881, 4<, 82, 8<, 83, 4<, 85, - 2<<, xD

4 + 4 + -4 +

13

12

H- 3 + xL H- 2 + xL H- 1 + xL

P3 Simplify

4+

1

12

H- 1 + xL I222 - 113 x + 13 x2 M

ECM6Lecture14aVietnam_2014.nb

plt1 = ListPlot@data, PlotStyle 8Red, PointSize@LargeD<,

Frame True, FrameLabel 8Style@"x", 16D, Style@"PHxL", 16D<D;

plt2 = Plot@P3, 8x, 0, 6<, PlotStyle 8Thick, Blue<,

Frame True, FrameLabel 8"x", "PHxL"<D;

Show@plt1, plt2, PlotRange AllD

PHxL

-5

-10

For the above example we can identify the basis functions fi as

f0 HxL =

f1 HxL =

f2 HxL =

f3 HxL =

Hx - 2L Hx - 3L Hx - 5L

H1 - 2L H1 - 3L H1 - 5L

Hx - 1L Hx - 3L Hx - 5L

H2 - 1L H2 - 3L H2 - 5L

Hx - 1L Hx - 2L Hx - 5L

H3 - 1L H3 - 2L H3 - 5L

Hx - 1L Hx - 2L Hx - 3L

H5 - 1L H5 - 2L H5 - 3L

f0 =

f1 =

f2 =

f3 =

Hx - 2L Hx - 3L Hx - 5L

H1 - 2L H1 - 3L H1 - 5L

Hx - 1L Hx - 3L Hx - 5L

H2 - 1L H2 - 3L H2 - 5L

Hx - 1L Hx - 2L Hx - 5L

H3 - 1L H3 - 2L H3 - 5L

Hx - 1L Hx - 2L Hx - 3L

H5 - 1L H5 - 2L H5 - 3L

;

;

;

;

11

ECM6Lecture14aVietnam_2014.nb

data = 881, 4<, 82, 8<, 83, 4<, 85, - 2<<;

plt1 = ListPlot@data, PlotStyle 8Red, PointSize@LargeD<,

Frame True, FrameLabel 8Style@"x", 16D, Style@"PHxL", 16D<D;

plt2 = Plot@4 f0 + 8 f1 + 4 f2 - 2 f3 , 8x, 0, 6<, PlotStyle 8Thick, Blue<,

Frame True, FrameLabel 8"x", "PHxL"<D;

Show@plt1, plt2, PlotRange AllD

PHxL

-5

-10

x

Now if we expand a function in terms of these polynomials in terms of a basis set of nth order, then we

must have n+1 terms

n

y HxL = yj fj HxL

j =0

where y j is the value of the function at the interpolation points. Here is plot of the individual basis

functions

Plot@8f0 , f1 , f2 , f3 <, 8x, 0, 6<,

PlotStyle 88Thick, Blue<, 8Red, Thick<, 8Magenta, Thick<, 8Thick, Orange<<,

Frame True, FrameLabel 8Style@"x", 16D, Style@"fi ", 16D<D

3

fi

12

-1

-2

0

x

Recall that the data used to generate these basis functions had values xo = 1, x1 = 2, x2 = 3, x3 = 5. This

plot illustrates that the basis function satisfy

fi Ixj M = 0, i j

ECM6Lecture14aVietnam_2014.nb

13

fi Ixj M = 0, i j

fi Ixj M = 1, i = j

Mathematicas Interpolation function generates a piecewise function through the data points. Consider

the following example

dataSin = Table@8x, Sin@3 xD<, 8x, 0, 2, 0.2<D;

myfunc = Interpolation@dataSinD

Plot@myfunc@xD, 8x, 0, 2<, Epilog 8Red, PointSize@0.02D, Map@Point@D &, dataSinD<D

InterpolatingFunction@880., 2.<<, <>D

1.0

0.5

0.5

1.0

1.5

2.0

-0.5

-1.0

Although the interpolating function is continuous at the data points, the derivatives are not continuous

Plot@myfunc '@xD, 8x, 0, 1<, PlotStyle Thick, Frame TrueD

3

-1

-2

-3

0.0

0.2

0.4

0.6

0.8

1.0

14

ECM6Lecture14aVietnam_2014.nb

-2

-3

-4

-5

-6

-7

-8

0.0

0.2

0.4

0.6

0.8

1.0

ECM6Lecture14aVietnam_2014.nb

Numerical Integration

Suppose we want to evaluate the integral

b

f HxL x

a

An interpolating polynomial of the function f(x) that goes through the points a and b is

f HxL = f HaL f1 HxL + f HbL f2 HxL

where the interpolating polynomials are

f1 HxL =

Hx - bL

Ha - bL

, f2 HxL =

Hx - aL

Hb - aL

Since we have two interpolating points, the interpolating polynomial is linear. Hence our integral then

becomes

b

a

b

f HxL x :f HaL

Hx - bL2 - b2

1

2

2 Ha - bL

+ f HbL

Hx - aL2 - a2

2 Hb - aL

Hb - aL

2

8f HaL + f HbL<

Graphical Representation

This is called the trapezoidal rule. Here is a graphical interpretation

>

b

a

15

16

ECM6Lecture14aVietnam_2014.nb

Area = Hb - aL f HbL +

1

2

Hb - aL Hf HaL - f HbLL

f HaL

= Hb - aL f HbL + Hb - aL

= Hb - aL :f HbL -

Hb - aL

2

f HbL

2

8f a)+f(b)}

2

+

f HaL

2

>

f HbL

2

ECM6Lecture14aVietnam_2014.nb

Improving the Accuracy

Example 1

Example 2

17

18

ECM6Lecture14aVietnam_2014.nb

References

The following textbooks were useful in preparing these notes:

B. Bradie, A Friendly Introduction to Numerical Analysis, Pearson Prentice Hall, 2006

A. J. Pettofrezzo, Introductory Numerical Analysis, Dover Publications, 1984

P. Wellin, R. Gaylord & S. Kamin, An Introduction to Programming with Mathematica, Cambridge

University Press, 2005

- Factoring Trinomials Test PDFUploaded byAndre
- Lab 1 WriteupUploaded bygt50201
- 2016 Yr 11 Extn 1 Assessment Task 2Uploaded byNathan Cao
- Fuzzy Interpolation and Extrapolation_a Pratical ApproachUploaded byLyna Choo
- MAT575 2009-1Uploaded byWan Fazrin
- StructureUploaded byrktiwary256034
- AutoCAD 2012 - Command Alias - Martin M.Uploaded bymartikeyy
- DFTUploaded byZuraidi Ependi
- math 10 1stUploaded byWerty Gigz Durendez
- Gegen Bauer polyUploaded byGiggio90
- IMOMATH - Equations in polynomialsUploaded byDijkschneier
- ChE516 Chapter 3Uploaded bygauravkumar2
- Set of Real Numbers_edition2a.pdfUploaded bynacijohn
- Data AnalysisUploaded byMuhammad Rizwan
- Reversible Data Hiding using Improved Interpolation TechniqueUploaded byIRJET Journal
- adding subtracting polynomialsUploaded byapi-304977850
- 27_ftpUploaded byujosec6138
- Carl Benjamin Boyer - Cardan and the Pascal triangleUploaded bylagatadezinc5733
- Rr10106-Introductions to ComputersUploaded bySRINIVASA RAO GANTA
- addingsubtracting polynomialsUploaded byapi-262089947
- grdfilesUploaded byTran
- SQL Tips and TricksUploaded byScott Lackey
- 2008 Feb06 Richard Lodholz Patterns Figurative NumbersUploaded byDeng Navarro Pasion
- How to Use GeologyUploaded byNicolas Mejia
- adding and subtracting polynomialsUploaded byapi-267265141
- adding subtracting polynomials small group 9616Uploaded byapi-304977850
- 331978207 xUploaded byAndres LOPEZ PENELAS
- addingsubtracting polynomialsUploaded byapi-231921302
- Adding and Subtracting PolynomialsUploaded bymalini72
- Manuscript 1Uploaded byAliyu AI Ma'ali

- ECM6Lecture14bVietnam_2014Uploaded byduyvu
- ECM6Lecture11cVietnam_2014Uploaded byduyvu
- ECM6Lecture14cVietnam_2014.npdfUploaded byduyvu
- ECM6Lecture11aVietnam_2014Uploaded byduyvu
- ECM6Lecture11dVietnam_2014Uploaded byduyvu
- ECM6Lecture11bVietnam_2014Uploaded byduyvu
- ECM6Lecture9Vietnam_2014Uploaded byduyvu
- ECM6Lecture6Vietnam_2014Uploaded byduyvu
- ECM6Lecture8Vietnam_2014Uploaded byduyvu
- ECM6Lecture5Vietnam_2014Uploaded byduyvu
- ECM6Lecture4Vitenam_2014Uploaded byduyvu
- ECM6Lecture2Vietnam_2014Uploaded byduyvu
- ECM6Lecture3Vietnam_2014Uploaded byduyvu

- untitled.pdfUploaded bySrikrishna Jana
- Midterm F15 SolsUploaded byDylan Ler
- Elliptic Curves - Physics Research Interaction Team, UMD, 2016 - NotesUploaded byJoseph Heavner
- Surveys in Geometry and Number Theory-Nicholas YoungUploaded bybeni
- w5Uploaded byPooja Sinha
- Sample Ques - ELQ, CompUploaded bySudhakar Joshi
- Generalized Hyperspaces and Non-Metrizable Fractals PREPRINTUploaded byJonathan Robert Kraus (OutofMudProductions)
- a1 6 2 packetUploaded byapi-327561261
- 36778588-Digital-Singal-Processing-EI-335Uploaded byNaveen Kumar
- Introduction to Programming Using MatlabUploaded byVen Viv Gumpic
- Module 0 Resource Guide2014 Editionv6Uploaded bySurya Gowtam
- fp3pp_june12Uploaded byMarkus1234567
- Calc Lesson 07 (Multivariable Diff Calc)Uploaded bybaha146
- A.iserlesUploaded byAnkur Bhatnagar
- On the base-b expansion of the Number of Trailing Zeros of b^k!Uploaded byEdwin J Montufar
- SynopsisUploaded byAbhinav Jain
- cis515-11-sl4.pdfUploaded bySufyan Sahoo
- Algebraic-Number-Theory-Notes-Anwar-Khan.pdfUploaded bySikandar Khan
- AlgebraIIUploaded byCarlos Alberto Ajila Loayza
- EJOR07Uploaded byjonathanmax1
- Qb Cs2303 Toc Ut1Uploaded byMaalavica Ramakrishnan
- abelianUploaded byparkosurf
- Lecture Periodic SchedulingUploaded byMalu Mohan
- Csecmultiplechoice - Coordinates(1)Uploaded byglenn
- Summer Review Packet 5Uploaded byteachopensource
- History Fourier SeriesUploaded byEram Khan
- Arnold CatmapUploaded byYashas
- AP Calculus BC SyllabusUploaded byengrroy
- Non Minimum Phase ZeroUploaded byAyoub Ayay
- HW-1Uploaded byTolga Akın