Interpolation
Interpolation
Walter
Mudzimbabwe
Chapter 5
Interpolation
Walter Mudzimbabwe
Interpolation
Interpolation
Walter
Mudzimbabwe
Chapter 5
Motivation:
ti , time 1 1.3 1.6 1.9 2.2
V (ti ), Volume 0.7652 0.6201 0.4554 0.2818 0.1104
Interpolation
Walter
Mudzimbabwe
Chapter 5
Linear interpolation
Interpolation Given only 2 points (x0 , f (x0 )) and (x1 , f (x1 )) the interpolating
Walter function is a straight line passing through them.
Mudzimbabwe
Let P1 (x) = a0 + a1 x = f (x).
Chapter 5
The polynomial has to pass through these two points so
P1 (x0 ) = a0 + a1 x0 = f (x0 )
P1 (x1 ) = a0 + a1 x1 = f (x1 )
Therefore
f (x0 )x1 − f (x1 )x0 f (x1 ) − f (x0 )
a0 = , a1 =
x1 − x0 x1 − x0
Therefore:
f (x1 ) − f (x0 )
P1 (x) = f (x0 ) + (x − x0 )
x1 − x0
which is a linear interpolating formula.
Example
Interpolation
Walter
Mudzimbabwe Question: Estimate ln(2) using linear interpolation given
Chapter 5
x0 = 1 and x1 = 6.
Solution: Data: (x0 , f (x0 )) = (1, ln(1)) and
(x1 , f (x1 )) = (6, ln(6)).
So
f (x1 ) − f (x0 )
P1 (x) = f (x0 ) + (x − x0 )
x1 − x0
ln 6 − ln 1
ln(2) = P1 (2) = ln 1 + (2 − 1)
6−1
= 0.3583519.
Interpolation
Walter Given 3 points (x0 , f (x0 )), (x1 , f (x1 )) and (x2 , f (x2 )), a
Mudzimbabwe
parabola
Chapter 5
P2 (x) = a0 + a1 (x − x0 ) + a2 (x − x0 )(x − x1 )
Interpolation
Walter
Substituting x = x2 in P2 (x) results in
Mudzimbabwe
Chapter 5
P2 (x2 ) = f (x2 ) = a0 + a1 (x2 − x0 ) + a2 (x2 − x0 )(x2 − x1 )
f (x1 ) − f (x0 )
= f (x0 ) + (x2 − x0 ) + a2 (x2 − x0 )(x2 − x1 )
x1 − x0
..
.
..
.
..
.
Finally,
f (x2 )−f (x1 ) f (x1 )−f (x0 )
x2 −x1 − x1 −x0
a2 = .
x2 − x0
Example
Interpolation
Walter
Mudzimbabwe
Chapter 5
Interpolation
Walter
Mudzimbabwe Suppose we want to determine a first degree polynomial that
Chapter 5
passes through two points (x0 , y0 ) and (x1 , y1 ). Let such a
polynomial have the form:
(x − x1 ) (x − x0 )
P(x) = y0 + y1
(x0 − x1 ) (x1 − x0 )
= L0 (x)y0 + L1 (x)y1 .
Note that
1. P(x0 ) = y0 and P(x1 ) = y1 .
2. When x = x0 , L0 (x0 ) = 1 and L1 (x0 ) = 0.
3. When x = x1 , L0 (x1 ) = 0 and L1 (x1 ) = 1.
Lagrange Interpolating Polynomials
Interpolation
Walter
Mudzimbabwe
The lagrange interpolating polynomial is thus
Chapter 5
P(x) = Ln,0 (x)f (x0 ) + Ln,1 (x)f (x1 ) + . . . + Ln,n (x)f (xn )
Solution:
n
Y x − xi
Lk (x) =
xk − xi
i=0,i̸=k
Example
Interpolation For n = 1:
(x−x1 ) (x−x0 )
Walter P1 (x) we have L0 (x) = (x0 −x1 ) and L1 (x) = (x1 −x0 )
Mudzimbabwe
Chapter 5
xi 1 1.3 1.6 1.9 2.2
f (xi ) 0.765198 0.620086 0.455402 0.281819 0.110362
which gives,
P4 (1.5) = 0.508939.
Newton’s Divided Differences
Interpolation
0. The zeroth divided difference of f w.r.t. xi is
Walter
Mudzimbabwe
f [xi ] = f (xi ) = fi .
1. The first divided difference of f w.r.t. xi and xi+1 is:
Chapter 5
Interpolation
We fit a Pn (x) to the n + 1 data points
Walter
Mudzimbabwe (xi , f (xi )), i = 0, 1, · · · , n in the form:
Chapter 5
Pn (x) = a0 + a1 (x − x0 ) + a2 (x − x0 )(x − x1 ) + · · ·
+ an (x − x0 )(x − x1 ) · · · (x − xn−1 )
Interpolation Suppose:
Walter
Mudzimbabwe P3 (x) = a0 + a1 (x − x0 ) + a2 (x − x0 )(x − x1 )
Chapter 5 + a3 (x − x0 )(x − x1 )(x − x2 ).
We know that a0 = f [x0 ], a1 = f [x0 , x1 ], a2 = f [x0 , x1 , x2 ] and
a3 = f [x0 , x1 , x2 , x3 ]
xi f [xi ] f [xi , xi+1 ] f [xi , xi+1 , xi+2 ] f [xi , xi+1 , xi+2 , xi+3 ]
x0 f [x0 ]
f [x0 , x1 ]
x1 f [x1 ] f [x0 , x1 , x2 ]
f [x1 , x2 ] f [x0 , x1 , x2 , x3 ]
x2 f [x2 ] f [x1 , x2 , x3 ]
f [x2 , x3 ]
x3 f [x3 ]
Example
Interpolation Find a polynomial satisfied by (−4, 1245), (−1, 33), (0, 5), (2, 9)
Walter
Mudzimbabwe
Chapter 5
xi f [xi ] f [xi , xi+1 ] f [xi , xi+1 , xi+2 ] f [xi , xi+1 , xi+2 , xi+3 ]
-4 1245
-404
-1 33 94
-28 -14
0 5 10
2
2 9