Numerical LectureNote Chap4
Numerical LectureNote Chap4
Interpolation
Mikiyas G.
Department of Mathematics
College of Natural Sciences
Arba Minch University
[email protected]
Abstract
Module Summary: The purpose of this module is to show you how to
interpolate a given data set using Newton, Lagrange and Spline
interpolations.
Table of Contents
1 Interpolation
Finite Difference Operators
Finite Differences and Interpolating Polynomials
Interpolation with Equal Interval
Interpolation with unequal interval
References
∇2 fi = ∇(∇fi )
1. Shift operator (E):
= ∇(fi − fi−1 )
Efi = fi+1 = ∇fi − ∇fi−1
E 2 fi = E(Efi ) = (fi − fi−1 ) − (fi−1 − fi−2 ) (second order at xi ) .
= Efi+1 ... ...
= fi+2 ∇ fi = ∇n−1 fi − ∇n−1 fi−1 (nth order at xi ) .
n
In general,
Remark:
E n fi = fi+n . ∇fi = ∆fi−1 and
∇n fi = ∆n fi−n .
2. Forward Difference Operator (∆):
4. Central Difference operator (δ):
∆fi = Efi − Ifi 1 −1
δ = E2 − E 2
= fi+1 − fi (first order at xi ) . 1 −1
2 δfi = E 2 fi − E 2 fi
∆ fi = ∆(∆fi )
= fi+ 1 − fi− 1 (first order at xi ) .
= ∆(fi+1 − fi ) 2 2
where h is the step size. Let pn (x) be a polynomial of the nth degree in x ∆y0 ∆2 y0
f (x) ≈ pn (x) =y0 + (x − x0 ) + (x − x0 )(x − x1 )
taking the same values as y corresponding to x = xi , then, pn (x) represents h 2!h2
the continuous function y = f (x) such that f (xi ) = pn (xi ) for ∆3 y0
+ (x − x0 )(x − x 1 )(x − x2 ) + ...
i = 0, 1, 2, ..., n and at all other points f (x) = pn (x) + R(x) where R(x) is 3!h3
called the error term (Remainder term) of the interpolation formula. ∆n y0
+ n
(x − x0 )(x − x1 )(x − x2 )...(x − xn−1 ). (3)
Ignoring the error term let us assume n!h
x−x0
f (x) ≈ pn (x) ≈a0 + a1 (x − x0 ) + a2 (x − x0 )(x − x1 ) + . . . Writing u = h , we get
+an (x − x0 )(x − x1 ) . . . (x − xn−1 ) (2) x − x0 = uh
the constants a0 , a1 , ..., an can be determine as: x − x1 = x − x0 + x0 − x1
Putting x = x0 in Eq., (2) we get = x − x0 − (x1 − x0 )
= uh − h
f (x0 ) ≈p0 (x0 ) = a0
= h(u − 1)
⇒y0 = a0
Similarly
Putting x = x1 in Eq., (2) we get x − x2 = h(u − 2)
x − x3 = h(u − 3)
f (x1 ) ≈p1 (x1 ) = a0 + a1 (x1 − x0 ) = y0 + a1 h
...
⇒y1 = y0 + a1 h
x − xn−1 = h(u − n + 1)
y1 − y0 ∆y0
⇒a1 = = .
h h Now, Eq., (3) can be written as
Putting x = x2 in Eq., (2) we get
∆y0 ∆2 y0
pn (x) =y0 + u + u(u − 1)
f (x2 ) ≈p2 (x2 ) = a0 + a1 (x2 − x0 ) + a2 (x2 − x0 )(x2 − x1 ) 1! 2!
∆ n y0
∆y0 + ... + u(u − 1)...(u − n + 1) . (4)
⇒y2 = y0 + (2h) + a2 (2h)(h). n!
h
⇒y2 = y0 + 2(y1 − y0 ) + a2 (2h2 ) The above formula is called Newton’s forward interpolation formula.
y2 − 2y1 + y0 ∆ 2 y0 Note: Newton forward interpolation formula is used to interpolate the values of y
⇒a2 = = . near the beginning of a set of tabular values.
2h2 2!h2
∇3 yn ∇ 4 yn ∇ n yn x f (x) ∇y ∇2 y ∇3 y ∇4 y
an−3 = , an−4 = , ..., a0 =
3!h3 4!h4 n!hn 80 5026
648
putting the values of a0 , a1 , ..., an in Eq., (5) we get
85 5674 40
∇yn ∇ 2 yn 688 -2
f (x) ≈ pn (x) =yn + (x − xn ) + (x − xn )(x − xn−1 ) 90 6362 38 4
h 2!h2
∇ 3 yn 726 2
+ 3
(x − xn )(x − xn−1 )(x − xn−2 ) + ... 95 7088 40
3!h
∇ n yn 766
+ (x − xn )(x − xn−1 )(x − xn−2 )...(x − x1 ). (6) 100 7854
n!hn
x−xn Here we have, xn = 100, x = 105, h = 5.
Writing u = h , we get
yn = 7854, ∇yn = 766, ∇2 yn = 40, ∇3 yn = 2, ∇4 yn = 4.
x − xn = uh Therefore, u = x−x
h
n
= 105−100
5 = 1.
x − xn−1 = x − xn + xn − xn−1 Now on applying Newton’s backward difference formula, we have
= x − xn − (xn−1 − xn ) ∇yn ∇ 2 yn
= uh + h f (105) =yn + u + u(u + 1)
1! 2!
= h(u + 1) ∇ 3 yn ∇4 yn
+ u(u + 1)(u + 2) + u(u + 1)(u + 2)(u + 3) .
Similarly 3! 4!
40
x − xn−2 = h(u + 2) f (105) ≈7854 + 1 × 766 + 1(1 + 1)
2
x − xn−3 = h(u + 3) 2
+ 1(1 + 1)(1 + 2)
... 6
x − x1 = h(u + (n + 1)) 4
+ 1(1 + 1)(1 + 2)(1 + 3)
24
Now, Eq., (6) can be written as = 7854 + 766 + 40 + 2 + 4 = 8666
⇒ f (105) ≈8666
∇yn ∇ 2 yn
pn (x) =yn + u + u(u + 1)
1! 2! c. Error in the Interpolation Formula
∇ n yn
+ ... + u(u + 1)...(u + (n − 1)) . (7) If R(x) denotes the error in the formula then R(x) = f (x) − Pn (x). Show that error in the
n! forward interpolation formula is:
The above formula is called Newton’s backward interpolation formula.
∆n+1 y0
Note: R(x) = u(u − 1)(u − 2)...(u − n)
(n + 1)!
It is useful for interpolating near the end of the tabular values.
Example 1. Calculate the value of f (105) for the table: and the error in the Newton backward interpolation formula is:
∇n+1 yn
x 80 85 90 95 100 R(x) = u(u + 1)(u + 2)...(u + n), where , uh = x − xn .
f (x) 5026 5674 6362 7088 7854 (n + 1)!
proof (exercise!)
sol: 105 is near to the end of the table, we use Newton’s backward formula to find f (105).
si (xi ) = ai (xi − xi )3 + bi (xi − xi )2 + ci (xi − xi ) + di . The final relationship involving the coefficients is obtained by
when x = xi+1 , we have: By substituting the values of ai−1 , bi−1 and ci−1 in the above equation we have
Ni+1 = s00i (xi+1 ) By substituting the values of ai−1 , bi−1 , ci−1 and ci in Eq. (16), we have:
= 6ai (xi+1 − xi ) + 2bi
si (xi+1 ) − si (xi ) Ni+1 + 2Ni
= 6ai hi + Ni ci−1 = + hi
hi 6
Ni+1 − Ni si−1 (xi ) − si−1 (xi−1 ) 2Ni + Ni−1
⇒ai = = + hi−1 . (17)
6hi hi−1 6
Now substituting the values of ai , bi &di to Eq. 15, we have:
for every i = 1, 2, ..., n.