lecture6

23
CE 341/441 - Lecture 6 - Fall 2004 p. 6.1 LECTURE 6 LA GRANGE INTERPOLA TION Fit points with an degree polynomial = exact function of which only discrete values are known and used to estab- lish an interpolating or approximating function = approximating or interpolating function. This function will pass through all specified interpolation points (also referred to as data points or nodes). N 1 + N th f 1 x 0 g(x) f(x) f 0 f 2 f 3 f 4 f N x 1 x 2 x 3 x 4 x N ... fx ( 29 N 1 + gx ( 29 gx ( 29 N 1 +

Upload: nakul-surana

Post on 25-Jul-2015

30 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

known and used to estab-

tion will pass through allints or nodes).

p. 6.1

LECTURE 6

LAGRANGE INTERPOLA TION

• Fit points with an degree polynomial

• = exact function of which only discrete values arelish an interpolating or approximating function

• = approximating or interpolating function. This funcspecified interpolation points (also referred to asdata po

N 1+ Nth

f1

x0

g(x)f(x)

f0

f2

f3 f4fN

x1 x2 x3 x4 xN...

f x( ) N 1+g x( )

g x( )N 1+

Page 2: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

through a given set of

).

N 1+

p. 6.2

• The interpolation points or nodes are given as:

:

• There exists only one degree polynomial that passespoints. It’s form is (expressed as a power series):

where = unknown coefficients, ( coefficients

• No matter how we derive the degree polynomial,

• Fitting power series

• Lagrange interpolating functions

• Newton forward or backward interpolation

The resulting polynomial will always be the same!

xo f xo( ) f o≡

x1 f x1( ) f 1≡

x2 f x2( ) f 2≡

xN f xN( ) f N≡

Nth

g x( ) ao a1x a2x2 a3x3 … aN xN+ + + + +=

ai i 0 N,= N 1+

Nth

Page 3: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

s of the interpolating func-ations).

f o

f 1=

f N=

p. 6.3

Power Series Fitting to Define Lagrange Interpolation

• must match at the selected data points⇒

: :

• Solve set of simultaneous equations

• It is relatively computationally costly to solve the coefficienttion (i.e. you need to program a solution to these equ

g x( ) f x( )

g xo( ) f o= ao a1xo a2xo2 … aNxo

N+ + + + =

g x1( ) f 1= ao a1x1 a2x12

+ + … aNx1N

+ +

g xN( ) f N= ao a1xN+ a2xN2 … aNxN

N+ + +

1 xo xo2 … xo

N

1 x1 x12 … x1

N

… … … … …

1 xN xN2 … xN

N

ao

a1

:

aN

f o

f 1

:

f N

=

g x( )

Page 4: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

h node such that

; ;

i

V4 x3( )

x3( ) 0= V3 x3( ) 1=

p. 6.4

Lagrange Interpolation Using Basis Functions

• We note that in general

• Let

where = polynomial of degree associated with eac

• For example if we have 5 interpolation points (or nodes)

Using the definition for : ; ;

,we have:

g xi( ) f i=

g x( ) f i Vi x( )i 0=

N

∑=

Vi x( ) N

Vi x j( )0 i j≠1 i = j

g x3( ) f oVo x3( ) f 1V1 x3( ) f 2V2 x3( ) f 3V3 x3( ) f 4+ + + +=

Vi xj( ) V0 x3( ) 0= V1 x3( ) 0= V2

V4 x3( ) 0=

g x3( ) f 3=

Page 5: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

)

ots, i.e. it equals zero at

nity at

ns

)

xi

x( )

x xN–( ))… xi xN–( )------------------------------

p. 6.5

• How do we construct ?

• Degree

• Roots at (at all nodes except

• Let

• The function is such that wedo have the required ronodes except at node

• Degree of is

• However in the form presented will not equal to u

• We normalize and define the Lagrange basis functio

Vi x( )

N

xo x1 x2 …xi 1– xi 1+ … xN, , , , , , xi

Vi xi( ) 1=

Wi x( ) x xo–( ) x x1–( ) x x2–( )… x xi 1––( ) x xi 1+–( )… x xN–(=

Wi

xo x1 x2 ... , xN, , , xi

Wi x( ) N

Wi x( )

Wi x( ) Vi

Vi x( )x xo–( ) x x1–( ) x x2–( )… x xi 1––( ) x xi 1+–( )…

xi xo–( ) xi x1–( ) xi x2–( )… xi xi 1––( ) xi xi 1+–(-----------------------------------------------------------------------------------------------------------------------------=

Page 6: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

specified form of is:

of degree

ting coefficients .

… xi xN–( )xi xN–( )

----------------------------

N)

N)------- 0=

Vi x( )

N

ao … aN, ,

p. 6.6

• Now we have such that equals:

• We also satisfy

e.g.

• The general form of the interpolating function with the

• The sum of polynomials of degree is also polynomial

• is equivalent to fitting the power series and compu

Vi x( ) Vi xi( )

Vi xi( )xi xo–( ) xi x1–( ) xi x2–( )… xi xi 1––( ) 1( ) xi xi 1+–( )

xi xo–( ) xi x1–( ) xi x2–( )… xi xi 1––( ) xi xi 1+–( )…----------------------------------------------------------------------------------------------------------------------------------=

Vi xi( ) 1=

Vi xj( ) 0 for i j≠=

V1 x2( )x2 xo–( ) 1( ) x2 x2–( ) x2 x3–( )⋅ … x2 x–(x1 xo–( ) 1( ) x1 x2–( ) x1 x3–( )… x1 x–(

---------------------------------------------------------------------------------------------------=

g x( )

g x( ) f iVi x( )i 0=

N

∑=

N

g x( )

Page 7: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

nterpolation

x xo–( )x1 xo– )-------------------

p. 6.7

Lagrange Linear Interpolation Using Basis Functions

• Linear Lagrange is the simplest form of Lagrange I

where

and

N 1=( )

g x( ) f iVi x( )i 0=

1

∑=

g x( ) f oVo x( ) f 1V1 x( )+=

Vo x( )x x1–( )xo x1–( )

---------------------x1 x–( )x1 xo–( )

---------------------= = V1 x( )(--=

x0

(x)

V0 (x)

x1

V1(x)1.0

Page 8: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

p. 6.8

Example

• Given the following data:

Find the linear interpolating function

• Lagrange basis functions are:

and

• Interpolating functiong(x) is:

xo 2= f o 1.5=

x1 5= f 1 4.0=

g x( )

Vo x( ) 5 x–3

-----------= V1 x( ) x 2–3

-----------=

g x( ) 1.5Vo x( ) 4.0V1 x( )+=

Page 9: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

(x)

p. 6.9

x0 = 2

1.5 V0 (x)4

2

4

2

x1 = 5x

4.0 V1(x)

x0 = 2 x1 = 5x

x0 = 2 x1 = 5

g(x) = 1.5 V0(x) + 4.0V1

Page 10: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

p. 6.10

Lagrange Quadratic Interpolation Using Basis Functions

• For quadratic Lagrange interpolation,N=2

where

g x( ) f i Vi x( )i 0=

2

∑=

g x( ) f oVo x( ) f 1V1 x( ) f 2V2 x( )+ +=

Vo x( )x x1–( ) x x2–( )

xo x1–( ) xo x2–( )-------------------------------------------=

V1 x( )x xo–( ) x x2–( )

x1 xo–( ) x1 x2–( )-------------------------------------------=

V2 x( )x xo–( ) x x1–( )

x2 xo–( ) x2 x1–( )-------------------------------------------=

Page 11: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

are defined such that the

. Thus:i

0

1

2

p. 6.11

• Note that the location of the roots of , and

basic premise of interpolation is satisfied, namely that

x0

V0 (x)

1.0

x1

xx2

V1(x) V2(x)

V0 x( ) V1 x( ) V2 x( )g xi( ) f=

g xo( ) Vo xo( ) f o V1 xo( ) f 1 V2 xo( ) f 2+ + f= =

g x1( ) Vo x1( ) f o V1 x1( ) f 1 V2 x1( ) f 2+ + f= =

g x2( ) Vo x2( ) f o V1 x2( ) f 1 V2 x2( ) f 2+ + f= =

Page 12: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

p. 6.12

Example

• Given the following data:

Find the quadratic interpolating function

• Lagrange basis functions are

• Interpolating functiong(x) is:

xo 3= f o 1=

x1 4= f 1 2=

x2 5= f 2 4=

g x( )

Vo x( ) x 4–( ) x 5–( )3 4–( ) 3 5–( )

----------------------------------=

V1 x( ) x 3–( ) x 5–( )4 3–( ) 4 5–( )

----------------------------------=

V2 x( ) x 3–( ) x 4–( )5 3–( ) 5 4–( )

----------------------------------=

g x( ) 1.0Vo x( ) 2.0V1 x( ) 4.0V2 x( )+ +=

Page 13: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

2(x)

p. 6.13

1.0 V0 (x)1.0x

4.0 V2(x)

x1 = 4x0 = 3 x2 = 5

2.0

4.0

x1 = 4x0 = 3 x2 = 5

x1 = 4x0 = 3 x2 = 5

x

x

2.0 V1(x)

x1 = 4x0 = 3 x2 = 5

4.0g(x) = 1.0 V0(x) + 2.0V1(x) + 4.0V

Page 14: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

with )f x( ) xln=

) x x3–( )

2) x1 x3–( )--------------------------

x1) x x2–( )x1) x3 x2–( )

---------------------------------

p. 6.14

Lagrange Cubic Interpolation Using Basis Functions

• For Cubic Lagrange interpolation,N=3

Example

• Consider the following table of functional values (generated

• Find as:

0 0.40 -0.916291

1 0.50 -0.693147

2 0.70 -0.356675

3 0.80 -0.223144

i xi f i

g 0.60( )

g x( ) f o

x x1–( ) x x2–( ) x x3–( )xo x1–( ) xo x2–( ) xo x3–( )

----------------------------------------------------------------- f 1

x xo–( ) x x2–(x1 xo–( ) x1 x–(

---------------------------------------+=

f 2

x xo–( ) x x1–( ) x x3–( )x2 xo–( ) x2 x1–( ) x2 x3–( )

----------------------------------------------------------------- f 3

x xo–( ) x –(x3 xo–( ) x3 –(

--------------------------------+ +

Page 15: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

0.80– )0.80– )

------------------

0)0)----

0)0)----

0)0)----

p. 6.15

g 0.60( ) 0.9162910.60 0.50–( ) 0.60 0.70–( ) 0.60(0.40 0.50–( ) 0.40 0.70–( ) 0.40(

------------------------------------------------------------------------------⋅–=

0.6931470.60 0.40–( ) 0.60 0.70–( ) 0.60 0.8–(0.50 0.40–( ) 0.50 0.70–( ) 0.50 0.8–(

--------------------------------------------------------------------------------------------⋅–

0.3566750.60 0.40–( ) 0.60 0.50–( ) 0.60 0.8–(0.70 0.40–( ) 0.70 0.50–( ) 0.70 0.8–(

--------------------------------------------------------------------------------------------⋅–

0.2231440.60 0.40–( ) 0.60 0.50–( ) 0.60 0.7–(0.80 0.40–( ) 0.80 0.50–( ) 0.80 0.7–(

--------------------------------------------------------------------------------------------⋅–

g 0.60( ) 0.509976–=

Page 16: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

given by:

omial

p. 6.16

Err ors Associated with Lagrange Interpolation

• Using Taylor series analysis, the error can be shown to be

where

derivative of w.r.t. evaluated at

• Notes

• If = polynomial of degree where , then

⇒ for all x

Therefore will be an exact representation of

e x( ) f x( ) g x( )–=

e x( ) L x( ) f N 1+( ) ξ( )= xo ξ xN≤ ≤

fN 1+ ξ( ) N 1

th+= f x ξ

L x( )x xo–( ) x x1–( )… x xN–( )

N 1+( )!----------------------------------------------------------------- an N 1

thdegree polyn+= =

f x( ) M M N≤

fN 1+( )

x( ) 0= e x( ) 0=

g x( ) f x( )

Page 17: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

is small and if

.

.) formulae

um near the edges

rge outside of the interval.

fN 1+( )

x( )

--

p. 6.17

• Since in general is not known, if the intervaldoes not change rapidly in the interval

where

• can be estimated by using Finite Difference (F.D

• will significantly effect the distribution of the error

• is a minimum at the center of and a maxim

• e.g. using 6 point interpolation looks like:

• at all data points

• largest . becomes very la

ξ xo xN,[ ]

e x( ) L x( ) f N 1+( ) xm( )≈ xm

xo xN+

2-----------------=

fN 1+( )

L x( )

L x( ) xo xN,[ ]

L x( )

0 1 2 3 4 5

L x( ) 0=

L x( ) 0 x 1≤ ≤ 4 x 5≤ ≤ L x( )

Page 18: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

s the maximum error within

and thus ↑

ur!!

d vary

xN≤

x x0 x xN≤ ≤

emax x0 x xN≤ ≤

p. 6.18

• As the size of the interpolating domain increases, so doethe interval

↑ ⇒ ↑ ⇒

• As increases from a small value, ↓ ⇒

• However as ⇒ ↑ for a given

• Therefore convergence as↑ does not necessarily occ

• Properties of will also influence error as an

D xN xo–= Lmax x0 x xN≤ ≤emax x0 x≤

N Lmax x0 x xN≤ ≤ema

N NCRIT> Lmax x0 x xN≤ ≤xo xN,[ ]

N

fN 1+( ) ξ( ) D N

Page 19: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

at (usually wex) x( )ln=

80)------ f3 1+( )

0.6( )

p. 6.19

Example

• Estimate the error made in the previous example knowing thdo not have this information).

f (

e x( ) L x( ) fN 1+( )

xm( )≈

e x( )x xo–( ) x x1–( ) x x2–( ) x x3–( )

3 1+( )!----------------------------------------------------------------------------- f

3 1+( )xm( )≈

e 0.60( ) 0.60 0.40–( ) 0.60 0.50–( ) 0.60 0.70–( ) 0.60 0.–(3 1+( )!

--------------------------------------------------------------------------------------------------------------------------≈

e 0.60( ) 0.000017 f4( )

0.6( )=

Page 20: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

nction itself

a Finite Difference (F.D.)

p. 6.20

• We estimate the fourth derivative off(x) using the analytical fu

• Therefore

• Exact error is computed as:

Therefore error estimate is excellent

• Typically we wouldalso have to estimate using

approximation (a discrete differentiation formula).

f x( ) xln=

f1( )

x( ) x1–

=

f2( )

x( ) x2–

–=

f3( )

x( ) 2x3–

=

f4( )

x( ) 6x4–

–=

f4( )

0.6( ) 46.29–=

e 0.60( ) 0.00079–=

E x( ) 0.60( ) g 0.60( )–ln 0.00085–= =

fN 1+( )

xm( )

Page 21: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

ints.

l→ find coefficients by

hrough data points→r.

) pointi

ch that it equals unity at thedata points and nonzero in-

N 1+

p. 6.21

SUMMARY OF LECTURES 5 AND 6

• Linear interpolation passes a straight line through 2 data po

• Power series→ data points→ degree polynomiasolving a matrix

• Lagrange Interpolation passes an degree polynomial tUse specialized nodal functions to make finding easie

where

= the interpolating function approximatingf(x)

fi = the value of the function at the data (or interpolation

= the Lagrange basis function

• Each Lagrange polynomial or basis function is set up sudata point with which it is associated, zero at all otherbetween.

N 1+ Nth

Nth

g x( )

g x( ) f iVi x( )i 0=

N

∑=

g x( )

Vi x( )

Page 22: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

p. 6.22

• For example whenN 2= 3 data points→

V0 V1 V2

0 1 2

g x( ) f oVo x( ) f 1V1 x( ) f 2V2 x( )+ +=

f0

f1

f2 g(x)

Page 23: Lecture6

CE 341/441 - Lecture 6 - Fall 2004

with

(or at some point in

1=

m)

mial

p. 6.23

• Linear interpolation is the same as Lagrange Interpolation

• Error estimates can be derived but depend on knowingthe interval).

where

derivative of w.r.t. evaluated at

N

fN 1+( )

x(

e x( ) L x( ) f N 1+( ) ξ( )= xo ξ xN≤ ≤

fN 1+ ξ( ) N 1

th+= f x ξ

L x( )x xo–( ) x x1–( )… x xN–( )

N 1+( )!----------------------------------------------------------------- an N 1

thdegree polyno+= =