Académique Documents
Professionnel Documents
Culture Documents
LECTURE 6
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. 6.1
CE 341/441 - Lecture 6 - Fall 2004
• There exists only one N th 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 + … + a N x
p. 6.2
CE 341/441 - Lecture 6 - Fall 2004
2 N
g ( xo ) = f o ⇒ ao + a1 xo + a2 xo + … + a N xo = f o
2 N
g ( x1 ) = f 1 ⇒ ao + a1 x1 + a2 x1 + … + a N x1 = f 1
: :
2 N
g( xN ) = f N ⇒ ao + a1 x N + a2 x N + … + a N x N = f N
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. 6.3
CE 341/441 - Lecture 6 - Fall 2004
0 i ≠ j
V i( x j) ≡
1 i = j
g ( x3 ) = f o V o ( x3 ) + f 1 V 1 ( x3 ) + f 2 V 2 ( x3 ) + f 3 V 3 ( x3 ) + f 4 V 4 ( x3 )
g ( x3 ) = f 3
p. 6.4
CE 341/441 - Lecture 6 - Fall 2004
• 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
( 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
CE 341/441 - Lecture 6 - Fall 2004
( 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 )
V i ( xi ) = 1
( x2 – xo ) ( 1 ) ( x2 – x2 ) ⋅ ( x2 – x3 ) … ( x2 – x N )
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 V i ( x ) is:
N
g( x) = ∑ f iV i( x)
i=0
p. 6.6
CE 341/441 - Lecture 6 - Fall 2004
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. 6.7
CE 341/441 - Lecture 6 - Fall 2004
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. 6.8
CE 341/441 - Lecture 6 - Fall 2004
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. 6.9
CE 341/441 - Lecture 6 - Fall 2004
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
CE 341/441 - Lecture 6 - Fall 2004
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
CE 341/441 - Lecture 6 - Fall 2004
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 – 3)(4 – 5)
( x – 3)( x – 4)
V 2 ( x ) = ----------------------------------
(5 – 3)(5 – 4)
p. 6.12
CE 341/441 - Lecture 6 - Fall 2004
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. 6.13
CE 341/441 - Lecture 6 - Fall 2004
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. 6.14
CE 341/441 - Lecture 6 - Fall 2004
g ( 0.60 ) = – 0.509976
p. 6.15
CE 341/441 - Lecture 6 - Fall 2004
• 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 ≤ ξ ≤ x N
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. 6.16
CE 341/441 - Lecture 6 - Fall 2004
0 1 2 3 4 5
p. 6.17
CE 341/441 - Lecture 6 - Fall 2004
• 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 ≤ x N x0 ≤ x ≤ x N
p. 6.18
CE 341/441 - Lecture 6 - Fall 2004
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. 6.19
CE 341/441 - Lecture 6 - Fall 2004
• 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. 6.20
CE 341/441 - Lecture 6 - Fall 2004
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. 6.21
CE 341/441 - Lecture 6 - Fall 2004
V0 V1 V2
0 1 2
g( x) = f oV o( x) + f 1V 1( x) + f 2V 2( x)
f0
g(x) f2
f1
p. 6.22
CE 341/441 - Lecture 6 - Fall 2004
• Error estimates can be derived but depend on knowing f ( N + 1 ) ( x m ) (or at some point in
the interval).
( N + 1)
e( x) = L( x) f (ξ) xo ≤ ξ ≤ x N
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. 6.23