0% found this document useful (0 votes)
157 views

Lagrange Interpolation Method PDF

- The document describes Lagrange interpolation, which fits an Nth degree polynomial to N+1 data points. - It introduces Lagrange basis polynomials Vi(x) that are zero at all points except xi, where it is 1. - The interpolating polynomial g(x) is the sum of the basis polynomials multiplied by the corresponding function values fi. - This allows defining the interpolating polynomial without directly solving a system of equations for the coefficients.

Uploaded by

Swati Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views

Lagrange Interpolation Method PDF

- The document describes Lagrange interpolation, which fits an Nth degree polynomial to N+1 data points. - It introduces Lagrange basis polynomials Vi(x) that are zero at all points except xi, where it is 1. - The interpolating polynomial g(x) is the sum of the basis polynomials multiplied by the corresponding function values fi. - This allows defining the interpolating polynomial without directly solving a system of equations for the coefficients.

Uploaded by

Swati Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

CE30125 - Lecture 3

LECTURE 3

LAGRANGE INTERPOLATION
th
• Fit N + 1 points with an N degree polynomial

g(x)
f2
f(x)
f3 f4
f1
f0 fN

x0 x1 x2 x3 x4 ... xN

• f  x  = exact function of which only N + 1 discrete values are known and used to estab-
lish an interpolating or approximating function g  x 

• g  x  = approximating or interpolating function. This function will pass through all


specified N + 1 interpolation points (also referred to as data points or nodes).

p. 3.1
CE30125 - Lecture 3

• The interpolation points or nodes are given as:


xo f  xo   fo
x1 f  x1   f1
x2 f  x2   f2
:
xN f  xN   fN

th
• There exists only one N degree polynomial that passes through a given set of N + 1
points. It’s form is (expressed as a power series):
2 3 N
g  x  = ao + a1 x + a2 x + a3 x +  + aN x

where a i = unknown coefficients, i = 0 N ( N + 1 coefficients).

• No matter how we derive the N th degree polynomial,


• Fitting power series
• Lagrange interpolating functions
• Newton forward or backward interpolation
The resulting polynomial will always be the same!

p. 3.2
CE30125 - Lecture 3

Power Series Fitting to Define Lagrange Interpolation

• g  x  must match f  x  at the selected data points 

2 N
g  xo  = fo  ao + a1 xo + a2 xo +  + aN xo = fo
2 N
g  x1  = f1  ao + a1 x1 + a2 x1 +  + aN x1 = f1
: :
2 N
g  xN  = fN  ao + a1 xN + a2 xN +  + aN xN = fN

• Solve set of simultaneous equations

2 N
1 xo xo  xo ao fo
2 N
1 x1 x1  x1 a1 f1
=
     : :
2 N aN fN
1 xN xN  xN

• It is relatively computationally costly to solve the coefficients of the interpolating func-


tion g  x  (i.e. you need to program a solution to these equations).

p. 3.3
CE30125 - Lecture 3

Lagrange Interpolation Using Basis Functions

• We note that in general g  x i  = f i

• Let
N

gx =  fi Vi  x 
i=0

where V i  x  = polynomial of degree N associated with each node i such that

0 i  j
Vi xj   
1 i = j

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

g  x3  = fo Vo  x3  + f1 V1  x3  + f 2 V2  x3  + f 3 V3  x3  + f4 V4  x3 

Using the definition for V i  x j  : V 0  x 3  = 0 ; V1  x 3  = 0 ; V 2  x 3  = 0 ; V 3  x 3  = 1 ;


V 4  x 3  = 0 ,we have:

g  x3  = f3

p. 3.4
CE30125 - Lecture 3

• How do we construct V i  x  ?

• Degree N
• Roots at x o x 1 x 2 x i – 1 x i + 1  x N (at all nodes except x i )

• Vi  xi  = 1

• Let W i  x  =  x – x o   x – x 1   x – x 2   x – x i – 1   x – x i + 1   x – x N 

• The function W i is such that we do have the required roots, i.e. it equals zero at nodes
x o x 1 x 2 ... , x N except at node x i

• Degree of W i  x  is N

• However W i  x  in the form presented will not equal to unity at x i

• We normalize W i  x  and define the Lagrange basis functions V i  x 

 x – xo   x – x 1   x – x2   x – x i – 1   x – x i + 1   x – x N 
V i  x  = --------------------------------------------------------------------------------------------------------------------------------------------------------
 x i – x o   x i – x 1   x i – x 2   x i – x i – 1   x i – x i + 1   x i – x N 

p. 3.5
CE30125 - Lecture 3

• Now we have V i  x  such that V i  x i  equals:

 x i – x o   x i – x 1   x i – x 2   x i – x i – 1   1   x i – x i + 1   x i – x N 
V i  x i  = ------------------------------------------------------------------------------------------------------------------------------------------------------------ 
 x i – x o   x i – x 1   x i – x 2   x i – x i – 1   x i – x i + 1   x i – x N 

Vi  xi  = 1

• We also satisfy Vi  x j  = 0 for i  j

 x2 – xo   1   x2 – x2    x2 – x3    x2 – xN 
e.g. V 1  x 2  = --------------------------------------------------------------------------------------------------------- = 0
 x 1 – x o   1   x 1 – x 2   x 1 – x 3   x 1 – x N 

• The general form of the interpolating function g  x  with the specified form of Vi  x  is:
N

gx =  fi Vi  x 
i=0

• The sum of polynomials of degree N is also polynomial of degree N


• g  x  is equivalent to fitting the power series and computing coefficients a o  a N .

p. 3.6
CE30125 - Lecture 3

Lagrange Linear Interpolation Using Basis Functions

• Linear Lagrange  N = 1  is the simplest form of Lagrange Interpolation


1

gx =  fi Vi  x 
i=0

g  x  = foVo  x  + f1V1  x 

where
 x – x1   x1 – x   x – xo 
V o  x  = --------------------- = --------------------- and V 1  x  = ---------------------
 xo – x1   x1 – xo   x1 – xo 

V0 (x) V1(x)
1.0

(x)
x0 x1

p. 3.7
CE30125 - Lecture 3

Example

• Given the following data:


xo = 2 f o = 1.5

x1 = 5 f 1 = 4.0

Find the linear interpolating function g  x 

• Lagrange basis functions are:

5–x x–2
V o  x  = ----------- and V 1  x  = -----------
3 3

• Interpolating function g(x) is:

g  x  = 1.5V o  x  + 4.0V 1  x 

p. 3.8
CE30125 - Lecture 3

4
2 1.5 V0 (x)
x
x0 = 2 x1 = 5

4
4.0 V1(x)
2
x
x0 = 2 x1 = 5

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

x0 = 2 x1 = 5

p. 3.9
CE30125 - Lecture 3

Lagrange Quadratic Interpolation Using Basis Functions


• For quadratic Lagrange interpolation, N=2
2

gx =  fi Vi  x 
i=0

g  x  = fo Vo  x  + f1 V1  x  + f2 V2  x 

where
 x – x1   x – x2 
V o  x  = ------------------------------------------
 xo – x1   xo – x2 

 x – xo   x – x2 
V 1  x  = ------------------------------------------
 x1 – xo   x1 – x2 

 x – xo   x – x1 
V 2  x  = ------------------------------------------
 x2 – xo   x2 – x1 

p. 3.10
CE30125 - Lecture 3

V0 (x) V1(x) V2(x)


1.0

x
x0 x1 x2

• Note that the location of the roots of V 0  x  , V 1  x  and V 2  x  are defined such that the
basic premise of interpolation is satisfied, namely that g  x i  = f i . Thus:

g  x o  = V o  x o f o + V 1  x o f 1 + V 2  x o f 2 = f 0

g  x 1  = V o  x 1 f o + V 1  x 1 f 1 + V 2  x 1 f 2 = f 1

g  x 2  = V o  x 2 f o + V 1  x 2 f 1 + V 2  x 2 f 2 = f 2

p. 3.11
CE30125 - Lecture 3

Example
• Given the following data:
xo = 3 fo = 1

x1 = 4 f1 = 2

x2 = 5 f2 = 4

Find the quadratic interpolating function g  x 

• Lagrange basis functions are


x – 4 x – 5
V o  x  = ----------------------------------
3 – 43 – 5

x – 3 x – 5
V 1  x  = ----------------------------------
4 – 34 – 5

x – 3 x – 4
V 2  x  = ----------------------------------
5 – 35 – 4

• Interpolating function g(x) is:

g  x  = 1.0V o  x  + 2.0V 1  x  + 4.0V 2  x 

p. 3.12
CE30125 - Lecture 3

1.0 V0 (x)
1.0
x
x0 = 3 x2 = 5
x1 = 4

2.0 2.0 V1(x)


x
x0 = 3 x1 = 4 x2 = 5

4.0 4.0 V2(x)

x
x0 = 3 x1 = 4 x2 = 5

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


4.0

x0 = 3 x1 = 4 x2 = 5

p. 3.13
CE30125 - Lecture 3

Lagrange Cubic Interpolation Using Basis Functions

• For Cubic Lagrange interpolation, N=3

Example
• Consider the following table of functional values (generated with f  x  = ln x )

i xi fi
0 0.40 -0.916291
1 0.50 -0.693147
2 0.70 -0.356675
3 0.80 -0.223144

• Find g  0.60  as:

 x – x1   x – x2   x – x3   x – xo   x – x2   x – x3 
g  x  = f o ---------------------------------------------------------------- + f 1 ----------------------------------------------------------------
 xo – x1   xo – x2   xo – x3   x1 – xo   x1 – x2   x1 – x3 

 x – xo   x – x1   x – x3   x – xo   x – x1   x – x2 
+ f 2 ---------------------------------------------------------------- + f 3 ----------------------------------------------------------------
 x2 – xo   x2 – x1   x2 – x3   x3 – xo   x3 – x1   x3 – x2 

p. 3.14
CE30125 - Lecture 3

 0.60 – 0.50   0.60 – 0.70   0.60 – 0.80 


g  0.60  = – 0.916291  ------------------------------------------------------------------------------------------------
 0.40 – 0.50   0.40 – 0.70   0.40 – 0.80 

 0.60 – 0.40   0.60 – 0.70   0.60 – 0.80 


– 0.693147  ------------------------------------------------------------------------------------------------
 0.50 – 0.40   0.50 – 0.70   0.50 – 0.80 

 0.60 – 0.40   0.60 – 0.50   0.60 – 0.80 


– 0.356675  ------------------------------------------------------------------------------------------------
 0.70 – 0.40   0.70 – 0.50   0.70 – 0.80 

 0.60 – 0.40   0.60 – 0.50   0.60 – 0.70 


– 0.223144  ------------------------------------------------------------------------------------------------
 0.80 – 0.40   0.80 – 0.50   0.80 – 0.70 

g  0.60  = – 0.509976

p. 3.15
CE30125 - Lecture 3

Errors Associated with Lagrange Interpolation

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

e x = fx – gx

N + 1
e  x  = L  x f  xo    xN

where
N+1 th
f  = N + 1 derivative of f w.r.t. x evaluated at 

 x – x o   x – x 1   x – x N  th
L  x  = --------------------------------------------------------------- = an N + 1 degree polynomial
 N + 1 !

• Notes
• If f  x  = polynomial of degree M where M  N , then
N + 1 
f x = 0  e  x  = 0 for all x
Therefore g  x  will be an exact representation of f  x 

p. 3.16
CE30125 - Lecture 3

N + 1 
• Since in general  is not known, if the interval  x o x N  is small and if f x
does not change rapidly in the interval
N + 1 xo + xN
e  x   L  x f  xm  where x m = ------------------ .
2
N + 1 
• f can be estimated by using Finite Difference (F.D.) formulae

• L  x  will significantly effect the distribution of the error

• L  x  is a minimum at the center of  x o x N  and a maximum near the edges

• e.g. using 6 point interpolation L  x  looks like:

0 1 2 3 4 5

• L  x  = 0 at all data points


• L  x  largest 0  x  1 4  x  5 . L  x  becomes very large outside of the interval.

p. 3.17
CE30125 - Lecture 3

• As the size of the interpolating domain increases, so does the maximum error within
the interval

D = x N – x o  L max  e max 


x0  x  xN x0  x  x N

• As N increases from a small value,  L max  e max 


x0  x  xN x0  x  xN

• However as N  N CRIT  L max  for a given  x o x N  and thus  e max 


x0  x  x N x0  x  xN

• Therefore convergence as N  does not necessarily occur!!

N + 1
• Properties of f    will also influence error as D and N vary

p. 3.18
CE30125 - Lecture 3

Example

• Estimate the error made in the previous example knowing that f  x  = ln  x  (usually
we do not have this information).

N + 1
e  x   L  x f  xm 

 x – xo   x – x1   x – x2   x – x3   3 + 1 
e  x   --------------------------------------------------------------------------- f  xm 
 3 + 1 !

 0.60 – 0.40   0.60 – 0.50   0.60 – 0.70   0.60 – 0.80   3 + 1 


e  0.60   -------------------------------------------------------------------------------------------------------------------------------- f  0.6 
 3 + 1 !

4 
e  0.60  = 0.000017 f  0.6 

p. 3.19
CE30125 - Lecture 3

• We estimate the fourth derivative of f(x) using the analytical function itself
f  x  = ln x 
1  –1
f x = x 
2  –2
f  x  = –x 
3  –3
f  x  = 2x 
4  –4
f  x  = – 6x 
4 
f  0.6  = – 46.29
• Therefore
e  0.60  = – 0.00079

• Exact error is computed as:


E  x  = ln  0.60  – g  0.60  = – 0.00085

Therefore error estimate is excellent

• Typically we would also have to estimate f  N + 1   x m  using a Finite Difference (F.D.)


approximation (a discrete differentiation formula).

p. 3.20
CE30125 - Lecture 3

SUMMARY OF LECTURES 2 AND 3

• Linear interpolation passes a straight line through 2 data points.


th
• Power series  N + 1 data points  N degree polynomial  find coefficients by
solving a matrix

• Lagrange Interpolation passes an N th degree polynomial through N + 1 data points 


Use specialized nodal functions to make finding g  x  easier.
N

gx =  fi Vi  x 
i=0

where
g  x  = the interpolating function approximating f(x)

fi = the value of the function at the data (or interpolation) point i


V i  x  = the Lagrange basis function

• Each Lagrange polynomial or basis function is set up such that it equals unity at the
data point with which it is associated, zero at all other data points and nonzero in-
between.

p. 3.21
CE30125 - Lecture 3

• For example when N = 2  3 data points

V0 V1 V2

0 1 2

g  x  = fo Vo  x  + f1 V1  x  + f2 V2  x 

f0
g(x) f2

f1

p. 3.22
CE30125 - Lecture 3

• Linear interpolation is the same as Lagrange Interpolation with N = 1

N + 1
• Error estimates can be derived but depend on knowing f  x m  (or at some point in
the interval).

N + 1
e  x  = L  x f  xo    xN

where
N+1 th
f  = N + 1 derivative of f w.r.t. x evaluated at 
 x – x o   x – x 1   x – x N  th
L  x  = --------------------------------------------------------------- = an N + 1 degree polynomial
 N + 1 !

p. 3.23

You might also like