You are on page 1of 22

Interpolation and Polynomial Approximation

•Problem: Let x0, x1,…xn be (n+1) distinct points


on the real axis. We wish to construct a
polynomial P(x) of degree <= n. that is satisfies
P(xk) = wk for k= 0,1, 2,…n.

Dr. Ghaddar mghaddar@ul.edu. 1


lb
• Existence and uniqueness of solution
Let P(x) = a0.xn + a1.xn-1 +…+an-1.x + an
• Linear system (n+1) equations in (n+1) unknown:

n 1
a0 .x  a1.x
n
0 0  ...  a( n 1) .x0  an  w0
n 1
a0 .x  a1.x
n
1 1  ...  a( n 1) .x1  an  w1
. . . . . . . . . . . . . .
n 1
a0 .x  a1.x
n
n n  ...  a( n 1) .xn  an  wn

Dr. Ghaddar mghaddar@ul.edu. 2


lb
• The linear system has a solution if :

 x0n x0n 1 . x0 1
 n 
 x1 x1n 1 . x1 1
det V ( x0 , x1 ,.., xn )   . . . . .  0
 
. . . .
xn x n 1
. xn 1
 n n

• The determinant is called determinant Van der


Monde.

Dr. Ghaddar mghaddar@ul.edu. 3


lb
Verify

n ( n 1) n j 1
det V ( x0 , x1 ,..., xn  (1) 2
 ( x
j 1 i  0
j  xi )

  (x
0i  j  n
j  xi )

Dr. Ghaddar mghaddar@ul.edu. 4


lb
• Lagrange Formula:
The polynomial P(x) of degree at most n that passes
through the (n+1) points (x0,w0), (x1,w1),…(xn,wn) and
has the form:

n
P( x)   wi .Li ( x) with
i 0
n x  xj ( x  x0 )...( x  xi 1 )( x  xi 1 )...( x  xn )
Li ( x)   
j 0 x  x ( xi  x0 )...( xi  xi 1 )( xi  xi 1 )...( xi  xn )
i j i j

Dr. Ghaddar mghaddar@ul.edu. 5


lb
• Example: P(-1) = 3 ; P(1) =1 ; P(2) = 3 et P(3) = 7

( x  x1 )( x  x2 )( x  x3 ) ( x  1).( x  2).( x  3)
l0  
( x0  x1 )( x0  x2 )( x0  x3 ) ( 2).( 3).( 4)
( x  x0 )( x  x2 )( x  x3 ) ( x  1)( x  2)( x  3)
l1  
( x1  x0 )( x1  x2 )( x1  x3 ) ( 2)( 1)( 2)
( x  x0 )( x  x1 )( x  x3 ) ( x  1)( x  1)( x  3)
l2  
( x2  x0 )( x2  x1 )( x2  x3 ) (3)(1)(1)
( x  x0 )( x  x1 )( x  x2 ) ( x  1)( x  1)( x  2)
l3  
( x3  x0 )( x3  x1 )( x3  x2 ) ( 4)(2)(1)
P ( x )  w0 .l0 ( x )  w1.l1 ( x )  w2 .l2 ( x )  w3 .l3 ( x )
P( x)  x 2  x  1
Dr. Ghaddar mghaddar@ul.edu. 6
lb
• Newton Interpolation Polynomial
n
p( x)   D01... j . j ( x)
j 0

 0 ( x)  1

with  j 1

 j ( x)   ( x  xi )  ( x  x0 )( x  x1 )...( x  x j 1 )
 i 0

 D0  w0 , Di  Wi

 D  D1  D0 , D  D j  Di
 01 x1  x0 ij
x j  xi
and 
D D jk ...n  Di j ...( n 1)
 ijk ...n  xn  xi



Dr. Ghaddar mghaddar@ul.edu. 7


lb
• The Divided Difference table:

x0 w0  Do
D01
x1 w1  D1 D012
. . . . D12 .
. . . . . . D01.. n
. . . . Dn  2 , n 1, n
xn wn  Dn

Dr. Ghaddar mghaddar@ul.edu. 8


lb
• Example: p(1) = 2, P(3)=-1, P(4)=5, P(5) =1

1 2  D0
3
 D01
2
5
3 1  D012
2
 15
6  D0123
8
4 5 5
4
5 1
Dr. Ghaddar mghaddar@ul.edu. 9
lb
3
P( x)   D01... j . j  D0 0  D011  D012 2  D0123 3
j 0

0  1
1  ( x  x0 )  x  1
 2  ( x  x0 ).( x  x1 )  ( x  1)( x  3)
 3  ( x  x0 )( x  x1 )( x  x2 )  ( x  1)( x  3)( x  4)

15 3 35 2 377 67
P( x)   x  x  x
8 2 8 2
Dr. Ghaddar mghaddar@ul.edu. 10
lb
15 3 35 2 377 67
P( x)   x  x  x
8 2 8 2

Dr. Ghaddar mghaddar@ul.edu. 11


lb
Algorithm for interpolation with a Lagrangian polynomial
• To interpolate for f(x), given x and a set of N+1 data
pairs, (xi, fi), I = 0,…,N:
• Set SUM = 0.
DO For I = 0 to N:
SET P = 1.
DO FOR J = 0 to N:
IF J ≠ I:
SET P = P*(x - x(J) )/ (x(I) - x(J)).
ENDO (J).
SET SUM = SUM + P*fi
ENDO (I).
SUM is the interpolated value.
Dr. Ghaddar mghaddar@ul.edu. 12
lb
The Error of the interpolating polynomial
• Let x0, x1,.. ,xn be (n+1) distinct points on the real axis
and let f(x) be a real-valued function defined on some
interval [a, b] containing these points, we wish to
construct P(x) of degree <= n which interpolates f(x) at
the points x0, x1,.. ,xn that is satisfies

f ( xi )  P( xi ) for i  0,1,..n.
and
f ( x)  P ( x)  R ( x) for x  xi

• R(x) is the interpolation error


R(x) = 0 if x = xk k=0,1,…,n

Dr. Ghaddar mghaddar@ul.edu. 13


lb
 n

 Lagrange : P ( x)   f ( xi )li ( x)
 i 0
 n
 Newton : P ( x ) 


i 0
D01..i i ( x )

with P ( xk )  f ( xk ) k  0,1..n
P ( x)  f ( x)  R ( x) x  xk

Dr. Ghaddar mghaddar@ul.edu. 14


lb
Interpolation Error

• f(x) = 1/x, x0 = 2, x1 = 2.5, x2 = 4


• f(2) = 0.5, f(2.5) = 0.4, f(4) = 0.25
• P(x) = 0.05x2 - 0.425x + 1.15
• P(3) = 0.325 f(3) = 0.333
• |R(3)|= 0.008
• x  x0 x  x1 x  x2
R ( x)  f (3) (t )
(3)!
 1 ( 3) 1 6
R(3)  f (t )  . 4  0.031
12 12 2
Dr. Ghaddar mghaddar@ul.edu. 15
lb
Comparison between f(x) and P(x)

Dr. Ghaddar mghaddar@ul.edu. 16


lb
The Error of the interpolating polynomial
• Cauchy Th. : Let f(x) be a real-valued function defined on [a,b]
and (n+1) times differentiable on [a,b]. If P(x) is the polynomial
of degree <= n which interpolates f(x) at the (n+1) distinct
points x0, x1,..,xn, in [a,b], there exists t between [a,b] such that:

( x  x0 )( x  x1 )..( x  xn ) ( n 1)
R( x)  .f (t )
(n  1)!
with a  t  b
Maximize the error
x  x0 x  x1 ... x  xn ( n 1)
R( x)  . Max f (t )
(n  1)! t a ,b 
Dr. Ghaddar mghaddar@ul.edu. 17
lb
Interpolation in a function based on equally
spaced points

• Note : xk = x0 + k.h K= 0,1,…,n h: step


and x = x0 +s.h s : variable

s  s  s.( s  1)..(s  j  1)


Note    1 ;   
 0  j j!
s  s  s.( s  1)
   s ;   
1   2 2
s.h( s  1).h...(s  n).h ( n 1) ( n 1)  s  ( n 1)
R( s)  f (t )  h .  f (t )
(n  1)!  n  1

Dr. Ghaddar mghaddar@ul.edu. 18


lb
Lagrange Formula
n
P ( x)   f ( xi )li ( x)
i 0
n
 s  n  s 
 P ( s )   f ( xi )  
i 0  i  n  i 
with x  x0  s.h

Dr. Ghaddar mghaddar@ul.edu. 19


lb
Newton Formula
Note f ( x)  f ( x  h)  f ( x)
f ( x0 )  f ( x1 )  f ( x0 )
Define :
 f ( x j ) i0
 f ( x j )   i 1
i

  i 1 i 1
  f ( x j )   f ( x j 1 )   f ( x j ) for i  0
we find
n
s i
n
P( x)   D01..i i ( x)    . f ( x0 )
i 0 i 0  i 

Dr. Ghaddar mghaddar@ul.edu. 20


lb
• Let f(x) = x.e-x

1) Find the interpolation polynomial p(x)


which interpolates f(x) at x0 = 3, x1=4
and x2= 5
2) Find a bound for the interpolating
error at point x = 3.5

Dr. Ghaddar mghaddar@ul.edu. 21


lb
• Let f(x) = ex
1) Find the interpolation polynomial p(x)
which interpolates f(x) at x0 = 1, x1=2,
x2= 3 and x3=4.
2) Find a bound for the interpolating
error at point x = 2.5
Where:
e1 = 2.7183,
e2 = 7.389,
e3 = 20.085,
e4 = 54.598,
Dr. Ghaddar mghaddar@ul.edu. 22
lb

You might also like