0 Up votes0 Down votes

0 views18 pageslecture

Jun 14, 2015

© © All Rights Reserved

PDF, TXT or read online from Scribd

lecture

© All Rights Reserved

0 views

lecture

© All Rights Reserved

- Neuromancer
- The E-Myth Revisited: Why Most Small Businesses Don't Work and
- How Not to Be Wrong: The Power of Mathematical Thinking
- Drive: The Surprising Truth About What Motivates Us
- Chaos: Making a New Science
- The Joy of x: A Guided Tour of Math, from One to Infinity
- How to Read a Person Like a Book
- Moonwalking with Einstein: The Art and Science of Remembering Everything
- The Wright Brothers
- The Other Einstein: A Novel
- The 6th Extinction
- The Housekeeper and the Professor: A Novel
- The Power of Discipline: 7 Ways it Can Change Your Life
- The 10X Rule: The Only Difference Between Success and Failure
- A Short History of Nearly Everything
- The Kiss Quotient: A Novel
- The End of Average: How We Succeed in a World That Values Sameness
- Made to Stick: Why Some Ideas Survive and Others Die
- Algorithms to Live By: The Computer Science of Human Decisions
- The Universe in a Nutshell

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

- Programming EngineersUploaded byashishmanyan
- Taller 4Uploaded byDavid Navia
- Class 10 Imo PaperUploaded byyatishgoyal
- how to evaluate for PAUT.xlsxUploaded byphan hoang diep
- Root Approximation by; Newton's Method, Bisection Method, Simple Iterative Method, and Second Method.Uploaded byKarl LeSénateur ViRil
- Denesting fractionsUploaded byMilloCz
- intermediate-algebra-posttest.pdfUploaded byachuth
- SınavHazırlıkSorularıUploaded byMert Akıcı
- Computational PhysicsUploaded byMohsen Khosravi
- Automatic Alignment and Reconstruction of Facial Depth ImagesUploaded bySyahroni Wahyu
- Mws Gen Inp Txt LagrangeUploaded bypawan_the_great
- Prac Simul 2018Uploaded bymote
- polynomialUploaded byRohan
- Test Problems in OptimizationUploaded byMahmoud Sleem
- 178630228-checkshot-pdf.pdfUploaded bysindy larasati
- Dynamic Programming with Hermite InterpolationUploaded byshoibalc
- Derivation of Lag Rang Ian Shape Functions for Hexahedral Element- Hani Aziz AmeenUploaded byHani Aziz Ameen
- e_SPEL_Ref71_r5Uploaded byTani Ricafrente
- Analysis of Geostatistical and Deterministic Techniques in the Spatial Variation of Groundwater Depth in the North-western Part of BangladeshUploaded byAbba-Gana Mohammed
- scope -n- sequenceUploaded byapi-292350369
- Http Tutorial Math Lamar Edu Classes Alg ZeroesOfPolynomials AspxUploaded byAkash Tuti
- Multiplicity of Zeros of Functions TeacherUploaded bySebooo
- algebra 2 curriculum alignmentUploaded byapi-254765842
- ch12.pdfUploaded bycathy
- 9 PolynomialsUploaded byNilam Doctor
- 10 Scar DoUploaded bytringuyenttt
- Learning Polynomials With Neural NetworksUploaded byjoscribd
- 4 Array and Matrix Operations.pdfUploaded byAugusto De La Cruz Camayo
- Assignment 1Uploaded byBun
- Lecture 3Uploaded byTebsu Tebsuko

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

- Asymptotes.pdfUploaded byMUDASSIR
- Objective_Ch_4_FSC_part1_imranUploaded byAbdul Hafeez Dayo
- Alg Complete AssignmentsUploaded bytanzeil
- High School Algebra 2016Uploaded byEdfinity
- math 10c factors products unit plan kaUploaded byapi-373646215
- Pure Mathematics 2&3 [Advaced Level Maths (2)Uploaded byGhassan Nabhan
- Common Errors in Mathematical WritingUploaded byluis199555
- Usage NotesUploaded byAndrew Fong
- ComplexAnalysis Ch2 Unit DiskUploaded byajay2g
- Exam Review_Polynomial FunctionsUploaded byKaiser Rex Pama
- Solving Recurrence RelationsUploaded bycompiler&automata
- AbelRuffini+theoremUploaded byAravind Narayan
- Algebraic CurvesUploaded byYiannis Markakis
- Toronto MathCompUploaded byTanagorn Jennawasin
- tat2 instructors manualUploaded byapi-437948879
- 3.3 - pptUploaded byJonalyn Bautista-Canlas
- z KovacsUploaded byKtk Zad
- Weighted residuals methodUploaded byPranavKherdekar
- Algebra 2 Unit 2 CK12 Flexbook LinksUploaded byYiannis Papagiannopoulos
- Introduction to PolynomialsUploaded bywolfretonmaths
- Ada 173823Uploaded bysagar1503
- 88431840 NCERT Mathematic Class XII Book Part IIUploaded byParisha Singh
- productFlyer_978-1-4419-7287-3Uploaded byExistentialist Mark
- EarlyAlgebraAndAlgebraicReasoning.pdfUploaded byGreySi
- Publications of Paul ErdösUploaded byzhazzu
- 6 Groebner Bases Algorithm1995 6Uploaded bycarloareis1864
- Wassenaar J. 2D Curves 2003Uploaded bystat_ista
- Math 1431-032 - Spring 2015 - Syllabus(1)Uploaded byMarla Barnett
- Ms Capp Math 2016Uploaded byBhimesh Jetti
- Método de FrobeniusUploaded byBrayan Pimentel

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.