Lagrange Interpolation Method PDF
Lagrange Interpolation Method PDF
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
p. 3.1
CE30125 - Lecture 3
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
p. 3.2
CE30125 - Lecture 3
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
2 N
1 xo xo xo ao fo
2 N
1 x1 x1 x1 a1 f1
=
: :
2 N aN fN
1 xN xN xN
p. 3.3
CE30125 - Lecture 3
• Let
N
gx = fi Vi x
i=0
0 i j
Vi xj
1 i = j
g x3 = fo Vo x3 + f1 V1 x3 + f 2 V2 x3 + f 3 V3 x3 + f4 V4 x3
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
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
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
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
gx = fi Vi x
i=0
p. 3.6
CE30125 - Lecture 3
gx = 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
x1 = 5 f 1 = 4.0
5–x x–2
V o x = ----------- and V 1 x = -----------
3 3
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
x0 = 2 x1 = 5
p. 3.9
CE30125 - Lecture 3
gx = 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
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
x – 3 x – 5
V 1 x = ----------------------------------
4 – 34 – 5
x – 3 x – 4
V 2 x = ----------------------------------
5 – 35 – 4
p. 3.12
CE30125 - Lecture 3
1.0 V0 (x)
1.0
x
x0 = 3 x2 = 5
x1 = 4
x
x0 = 3 x1 = 4 x2 = 5
x0 = 3 x1 = 4 x2 = 5
p. 3.13
CE30125 - Lecture 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
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
g 0.60 = – 0.509976
p. 3.15
CE30125 - Lecture 3
• Using Taylor series analysis, the error can be shown to be given by:
e x = fx – gx
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
0 1 2 3 4 5
p. 3.17
CE30125 - Lecture 3
• As the size of the interpolating domain increases, so does the maximum error within
the interval
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 !
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
p. 3.20
CE30125 - Lecture 3
gx = fi Vi x
i=0
where
g x = the interpolating function approximating f(x)
• 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
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
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