Professional Documents
Culture Documents
LECTURE 6
LAGRANGE INTERPOLATION
th
Fit N + 1 points with an N degree polynomial
g(x)
f2
f0
x0
f1
f(x)
f3
x1 x2 x3
f4
fN
x4 ...
xN
f ( x ) = exact function of which only N + 1 discrete values are known and used to establish 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. 6.1
f ( xo ) f o
x1
f ( x1 ) f 1
x2
f ( x2 ) f 2
xN
f ( xN ) f N
There exists only one N th degree polynomial that passes through a given set of N + 1
points. Its form is (expressed as a power series):
2
g ( x ) = ao + a1 x + a2 x + a3 x + + a N x
g ( xo ) = f o
ao + a1 xo + a2 xo + + a N xo = f o
g ( x1 ) = f 1
ao + a1 x1 + a2 x1 + + a N x1 = f 1
g( xN ) = f N
ao + a1 x N + a2 x N + + a N x N = f N
1 xo xo xo
ao
1 x1 x1 x1
a1
:
aN
1 xN xN xN
fo
=
f1
:
fN
It is relatively computationally costly to solve the coefficients of the interpolating function g ( x ) (i.e. you need to program a solution to these equations).
p. 6.3
g( x) =
f i V i( x)
i=0
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 )
V i ( 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 x o ) ( x x 1 ) ( x x 2 ) ( 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. 6.5
V i ( xi ) = 1
( x2 xo ) ( 1 ) ( x2 x2 ) ( x2 x3 ) ( x2 x N )
= 0
V 1 ( x 2 ) = ---------------------------------------------------------------------------------------------------------( 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 V i ( x ) is:
N
g( x) =
f iV i( x)
i=0
g( x) =
f iV i( x)
i=0
g( x) = f oV o( x) + f 1V 1( x)
where
( x1 x )
( x x1 )
V o ( x ) = --------------------- = --------------------( x1 xo )
( xo x1 )
1.0
and
( x xo )
V 1 ( x ) = -------------------( x1 xo )
V1(x)
V0 (x)
(x)
x0
x1
p. 6.7
Example
Given the following data:
xo = 2
f o = 1.5
x1 = 5
f 1 = 4.0
and
x2
V 1 ( x ) = ----------3
p. 6.8
4
1.5 V0 (x)
x
x0 = 2
x1 = 5
4
4.0 V1(x)
2
x0 = 2
x1 = 5
x0 = 2
x1 = 5
p. 6.9
g( x) =
f i V i( x)
i=0
g( x) = f oV o( x) + f 1V 1( x) + f 2V 2( 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. 6.10
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 ( xo ) = V o ( xo ) f o + V 1 ( xo ) f 1 + V 2 ( xo ) f 2 = f 0
g ( x1 ) = V o ( x1 ) f o + V 1 ( x1 ) f 1 + V 2 ( x1 ) f 2 = f 1
g ( x2 ) = V o ( x2 ) f o + V 1 ( x2 ) f 1 + V 2 ( x2 ) f 2 = f 2
p. 6.11
Example
Given the following data:
xo = 3
fo = 1
x1 = 4
f1 = 2
x2 = 5
f2 = 4
1.0 V0 (x)
1.0
x0 = 3
x1 = 4
x2 = 5
2.0 V1(x)
2.0
x0 = 3 x1 = 4 x2 = 5
4.0 V2(x)
4.0
x0 = 3 x1 = 4 x2 = 5
x0 = 3
x1 = 4
x2 = 5
p. 6.13
xi
fi
0.40
-0.916291
0.50
-0.693147
0.70
-0.356675
0.80
-0.223144
p. 6.14
g ( 0.60 ) = 0.509976
p. 6.15
( N + 1)
()
xo x N
where
f
N+1
() = N + 1
th
( 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
f
(N + 1)
( x) = 0
e ( x ) = 0 for all x
p. 6.16
( N + 1)
( x m ) where x m
xo + x N
= ------------------- .
2
1 2
3 4
As the size of the interpolating domain increases, so does the maximum error within
the interval
D = x N x o L max
x0 x x N
L max
x0 x x N
Therefore convergence as N
x0 x x N
e max
x0 x x N
e max
x0 x x N
p. 6.18
x0 x x N
Example
Estimate the error made in the previous example knowing that f ( x ) = ln ( x ) (usually we
do not have this information).
e( x) L( x) f
(N + 1)
( xm )
( x xo ) ( x x1 ) ( x x2 ) ( x x3 )
e ( x ) ----------------------------------------------------------------------------( 3 + 1 )!
(3 + 1)
( xm )
e ( 0.60 ) = 0.000017
(4)
( 0.6 )
p. 6.19
We estimate the fourth derivative of f(x) using the analytical function itself
f ( x ) = ln x
f
f
f
f
f
(1)
( x) = x
(2)
( x) = x
(3)
( x ) = 2x
(4)
( x ) = 6x
(4)
( 0.6 ) = 46.29
Therefore
e ( 0.60 ) = 0.00079
th
degree polynomial
find coefficients by
th
Lagrange Interpolation passes an N degree polynomial through N + 1 data points
Use specialized nodal functions to make finding g ( x ) easier.
g( x) =
f iV i( 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 inbetween.
p. 6.21
V0
V1
V2
g( x) = f oV o( x) + f 1V 1( x) + f 2V 2( x)
f0
g(x)
f1
p. 6.22
f2
( N + 1)
()
xo x N
where
f
N+1
() = N + 1
th
( x x o ) ( x x 1 ) ( x x N )
th
L ( x ) = ---------------------------------------------------------------- = an N + 1 degree polynomial
( N + 1 )!
p. 6.23