lecture 3 lagrange interpolation - university of notre …coast/jjwteach/www/www/30125/pdf... ·...
TRANSCRIPT
![Page 1: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/1.jpg)
CE30125 - Lecture 3
p. 3.1
LECTURE 3
LAGRANGE INTERPOLATION
• 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 allspecified interpolation points (also referred to as data points or nodes).
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: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/2.jpg)
CE30125 - Lecture 3
p. 3.2
• The interpolation points or nodes are given as:
:
• There exists only one degree polynomial that passes through a given set of points. 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 fo
x1 f x1 f1
x2 f x2 f2
xN f xN fN
Nth
N 1+
g x ao a1x a2x2 a3x3 aNxN+ + + + +=
ai i 0 N= N 1+
Nth
![Page 3: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/3.jpg)
CE30125 - Lecture 3
p. 3.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 coefficients of the interpolating func-tion (i.e. you need to program a solution to these equations).
g x f x
g xo fo = ao a1xo a2xo2 aNxo
N+ + + + fo=
g x1 f1 = ao a1x1 a2x12
+ + aNx1N
+ + f1=
g xN fN = ao a1xN+ a2xN2 aNxN
N+ + + fN=
1 xo xo2 xo
N
1 x1 x12 x1
N
1 xN xN2 xN
N
ao
a1
:
aN
fo
f1
:
fN
=
g x
![Page 4: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/4.jpg)
CE30125 - Lecture 3
p. 3.4
Lagrange Interpolation Using Basis Functions
• We note that in general
• Let
where = polynomial of degree associated with each node such that
• For example if we have 5 interpolation points (or nodes)
Using the definition for : ; ; ; ;
,we have:
g xi fi=
g x fi Vi x i 0=
N
=
Vi x N i
Vi xj 0 i j1 i = j
g x3 foVo x3 f1V1 x3 f2V2 x3 f3V3 x3 f4V4 x3 + + + +=
Vi xj V0 x3 0= V1 x3 0= V2 x3 0= V3 x3 1=
V4 x3 0=
g x3 f3=
![Page 5: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/5.jpg)
CE30125 - Lecture 3
p. 3.5
• How do we construct ?
• Degree
• Roots at (at all nodes except )
•
• Let
• The function is such that we do have the required roots, i.e. it equals zero at nodes except at node
• Degree of is
• However in the form presented will not equal to unity at
• We normalize and define the Lagrange basis functions
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 xi
Wi x Vi x
Vi x x xo– x x1– x x2– x xi 1–– x xi 1+– x xN–
xi xo– xi x1– xi x2– xi xi 1–– xi xi 1+– xi xN– --------------------------------------------------------------------------------------------------------------------------------------------------------=
![Page 6: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/6.jpg)
CE30125 - Lecture 3
p. 3.6
• Now we have such that equals:
• We also satisfy
e.g.
• The general form of the interpolating function with the specified form of is:
• The sum of polynomials of degree is also polynomial of degree
• is equivalent to fitting the power series and computing coefficients .
Vi x Vi xi
Vi xi xi xo– xi x1– xi x2– xi xi 1–– 1 xi xi 1+– xi xN–
xi xo– xi x1– xi x2– xi xi 1–– xi xi 1+– xi xN– ------------------------------------------------------------------------------------------------------------------------------------------------------------=
Vi xi 1=
Vi xj 0 for i j=
V1 x2 x2 xo– 1 x2 x2– x2 x3– x2 xN– x1 xo– 1 x1 x2– x1 x3– x1 xN–
--------------------------------------------------------------------------------------------------------- 0= =
g x Vi x
g x fiVi x i 0=
N
=
N N
g x ao aN
![Page 7: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/7.jpg)
CE30125 - Lecture 3
p. 3.7
Lagrange Linear Interpolation Using Basis Functions
• Linear Lagrange is the simplest form of Lagrange Interpolation
where
and
N 1=
g x fiVi x i 0=
1
=
g x foVo x f1V1 x +=
Vo x x x1– xo x1–
---------------------x1 x– x1 xo–
--------------------- = = V1 x x xo– x1 xo–
---------------------=
x0
(x)
V0 (x)
x1
V1(x)1.0
![Page 8: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/8.jpg)
CE30125 - Lecture 3
p. 3.8
Example
• Given the following data:
Find the linear interpolating function
• Lagrange basis functions are:
and
• Interpolating function g(x) is:
xo 2 = fo 1.5=
x1 5 = f1 4.0=
g x
Vo x 5 x–3
----------- = V1 x x 2–3
-----------=
g x 1.5Vo x 4.0V1 x +=
![Page 9: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/9.jpg)
CE30125 - Lecture 3
p. 3.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(x)
![Page 10: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/10.jpg)
CE30125 - Lecture 3
p. 3.10
Lagrange Quadratic Interpolation Using Basis Functions
• For quadratic Lagrange interpolation, N=2
where
g x fi Vi x i 0=
2
=
g x foVo x f1V1 x f2V2 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: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/11.jpg)
CE30125 - Lecture 3
p. 3.11
• Note that the location of the roots of , and are defined such that the
basic premise of interpolation is satisfied, namely that . Thus:
x0
V0 (x)
1.0
x1
xx2
V1(x) V2(x)
V0 x V1 x V2 x g xi fi=
g xo Vo xo fo V1 xo f1 V2 xo f2+ + f0= =
g x1 Vo x1 fo V1 x1 f1 V2 x1 f2+ + f1= =
g x2 Vo x2 fo V1 x2 f1 V2 x2 f2+ + f2= =
![Page 12: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/12.jpg)
CE30125 - Lecture 3
p. 3.12
Example
• Given the following data:
Find the quadratic interpolating function
• Lagrange basis functions are
• Interpolating function g(x) is:
xo 3= fo 1=
x1 4 = f1 2=
x2 5 = f2 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: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/13.jpg)
CE30125 - Lecture 3
p. 3.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.0V2(x)
![Page 14: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/14.jpg)
CE30125 - Lecture 3
p. 3.14
Lagrange Cubic Interpolation Using Basis Functions
• For Cubic Lagrange interpolation, N=3
Example
• Consider the following table of functional values (generated with )
• Find as:
0 0.40 -0.916291
1 0.50 -0.693147
2 0.70 -0.356675
3 0.80 -0.223144
f x xln=
i xi fi
g 0.60
g x fo
x x1– x x2– x x3– xo x1– xo x2– xo x3–
---------------------------------------------------------------- f1
x xo– x x2– x x3– x1 xo– x1 x2– x1 x3–
----------------------------------------------------------------+=
f2
x xo– x x1– x x3– x2 xo– x2 x1– x2 x3–
---------------------------------------------------------------- f3
x xo– x x1– x x2– x3 xo– x3 x1– x3 x2–
----------------------------------------------------------------+ +
![Page 15: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/15.jpg)
CE30125 - Lecture 3
p. 3.15
g 0.60 0.9162910.60 0.50– 0.60 0.70– 0.60 0.80– 0.40 0.50– 0.40 0.70– 0.40 0.80–
------------------------------------------------------------------------------------------------–=
0.6931470.60 0.40– 0.60 0.70– 0.60 0.80– 0.50 0.40– 0.50 0.70– 0.50 0.80–
------------------------------------------------------------------------------------------------–
0.3566750.60 0.40– 0.60 0.50– 0.60 0.80– 0.70 0.40– 0.70 0.50– 0.70 0.80–
------------------------------------------------------------------------------------------------–
0.2231440.60 0.40– 0.60 0.50– 0.60 0.70– 0.80 0.40– 0.80 0.50– 0.80 0.70–
------------------------------------------------------------------------------------------------–
g 0.60 0.509976–=
![Page 16: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/16.jpg)
CE30125 - Lecture 3
p. 3.16
Errors Associated with Lagrange Interpolation
• Using Taylor series analysis, the error can be shown to be given by:
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
th degree polynomial+= =
f x M M N
fN 1+
x 0 = e x 0=
g x f x
![Page 17: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/17.jpg)
CE30125 - Lecture 3
p. 3.17
• Since in general is not known, if the interval is small and if does not change rapidly in the interval
where .
• can be estimated by using Finite Difference (F.D.) formulae
• will significantly effect the distribution of the error
• is a minimum at the center of and a maximum near the edges
• e.g. using 6 point interpolation looks like:
• at all data points
• largest . becomes very large outside of the interval.
xo xN fN 1+
x
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: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/18.jpg)
CE30125 - Lecture 3
p. 3.18
• As the size of the interpolating domain increases, so does the maximum error withinthe interval
• As increases from a small value,
• However as for a given and thus
• Therefore convergence as does not necessarily occur!!
• Properties of will also influence error as and vary
D xN xo–= Lmax x0 x xN
emax x0 x xN
N Lmax x0 x xN
emax x0 x xN
N NCRIT Lmax x0 x xN
xo xN emax x0 x xN
N
fN 1+ D N
![Page 19: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/19.jpg)
CE30125 - Lecture 3
p. 3.19
Example
• Estimate the error made in the previous example knowing that (usuallywe do not have this information).
f x x ln=
e x L x f N 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.80– 3 1+ !
--------------------------------------------------------------------------------------------------------------------------------f3 1+
0.6
e 0.60 0.000017 f4
0.6 =
![Page 20: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/20.jpg)
CE30125 - Lecture 3
p. 3.20
• We estimate the fourth derivative of f(x) using the analytical function itself
• Therefore
• Exact error is computed as:
Therefore error estimate is excellent
• Typically we would also have to estimate using a Finite Difference (F.D.)
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: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/21.jpg)
CE30125 - Lecture 3
p. 3.21
SUMMARY OF LECTURES 2 AND 3
• Linear interpolation passes a straight line through 2 data points.
• Power series data points degree polynomial find coefficients bysolving a matrix
• Lagrange Interpolation passes an degree polynomial through data points Use specialized nodal functions to make finding easier.
where
= the interpolating function approximating f(x)
fi = the value of the function at the data (or interpolation) point i
= the Lagrange basis function
• Each Lagrange polynomial or basis function is set up such that it equals unity at thedata point with which it is associated, zero at all other data points and nonzero in-between.
N 1+ Nth
Nth
N 1+g x
g x fiVi x i 0=
N
=
g x
Vi x
![Page 22: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/22.jpg)
CE30125 - Lecture 3
p. 3.22
• For example when N 2 = 3 data points
V0 V1 V2
0 1 2
g x foVo x f1V1 x f2V2 x + +=
f0
f1
f2 g(x)
![Page 23: LECTURE 3 LAGRANGE INTERPOLATION - University of Notre …coast/jjwteach/www/www/30125/pdf... · 2011-10-13 · CE30125 - Lecture 3 p. 3.1 LECTURE 3 LAGRANGE INTERPOLATION • Fit](https://reader030.vdocuments.site/reader030/viewer/2022020319/5d38ca4188c9932a128cbd51/html5/thumbnails/23.jpg)
CE30125 - Lecture 3
p. 3.23
• Linear interpolation is the same as Lagrange Interpolation with
• Error estimates can be derived but depend on knowing (or at some point inthe interval).
where
derivative of w.r.t. evaluated at
N 1=
fN 1+
xm
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
th degree polynomial+= =