ch-3

advertisement
Chapter 3
INTERPOLATION
1
WHAT IS INTERPOLATION?
Given (x0,y0), (x1,y1), …, (xn,yn), finding the value of ‘y’ at a
value of ‘x’ in (x0, xn) is called interpolation.
2
INTERPOLANTS
Polynomials are the most common choice
of interpolants because they are easy to:
Evaluate,
Differentiate, and
Integrate.
3
LAGRANGIAN INTERPOLATION
Lagrangian interpolating polynomial is given by
n
f n ( x ) =  Li ( x ) f ( xi )
i =0
where ‘ n ’ in f n (x ) stands for the n th order polynomial that approximates the function y = f (x )
given at (n + 1) data points as (x 0 , y 0), (x1 , y1),..., (x n -1 , y n -1) , (x n , y n) , and
n
Li ( x ) = 
j =0
j i
x - xj
xi - x j
Li (x ) is a weighting function that includes a product of (n - 1) terms with terms of j = i
omitted.
4
Example
A manufacturer of thermistors makes the following observations
on a thermistor. Determine the temperature corresponding to
754.8 ohms using the Lagrangian method for interpolation.
R
T
Ohm
C
1101.0 25.113
911.3
30.131
636.0
40.120
451.1
50.128
5
Solution
We are interpolating using a cubic polynomial
3
T ( R) =  Li ( R)T ( Ri )
i =0
= L0 ( R)T ( R0 ) + L1 ( R)T ( R1 ) + L2 ( R)T ( R2 ) + L3 ( R)T ( R3 )
6
Solution
Ro = 1101.0, T (Ro ) = 25.113
R1 = 911.3, T (R1 ) = 30.131
R2 = 636.0, T (R2 ) = 40.120
R3 = 451.1, T (R3 ) = 50.128
3
L0 ( R) = 
j =0
j 0
3
L1 ( R) = 
j =0
j 1
3
L2 ( R) = 
j =0
j 2
R - Rj
50.128
 R - R1  R - R2  R - R3 



= 
R0 - R j  R0 - R1  R0 - R2  R0 - R3 
R - Rj
 R - R0
= 
R1 - R j  R1 - R0
 R - R2

 R1 - R2
R - Rj
 R - R0
= 
R2 - R j  R2 - R0
50
45
 R - R3 


R
R
3 
 1
ys
f ( range)
(
40
)
f x desired
35
 R - R1  R - R3 



R
R
R
R
1  2
3 
 2
30
25.113
R - Rj
 R - R0
L3 ( R) = 
= 
j =0 R3 - R j
 R3 - R0
j 3
3
 R - R1  R - R2


 R - R  R - R
1  3
2
 3
55




25
400
451.1
500
600
700
800
900
1000
1100
x s  range x desired
1.10110
55
50
7
45
y
1200
3
Solution
 R - R1  R - R2  R - R3 
 R - R0  R - R2  R - R3 


T ( R0 ) + 

T ( R1 )

T ( R) = 
 R0 - R1  R0 - R2  R0 - R3 
 R1 - R0  R1 - R2  R1 - R3 
 R - R0  R - R1  R - R3 
 R - R0  R - R1  R - R2 






T ( R3 )


+
T ( R2 ) + 





 R2 - R0  R2 - R1  R2 - R3 
 R3 - R0  R3 - R1  R3 - R2 
T (754.8) =
(754.8 - 911.3)(754.8 - 636.0)(754.8 - 451.1)
(25.113)
(1101.0 - 911.3)(1101.0 - 636.0)(1101.0 - 451.1)
(754.8 - 1101.0)(754.8 - 636.0)(754.8 - 451.1)
+
(30.131)
(911.3 - 1101.0)(911.3 - 636.0)(911.3 - 451.1)
(754.8 - 1101.0)(754.8 - 911.3)(754.8 - 451.1)
+
(40.120)
(636.0 - 1101.0)(636.0 - 911.3)(636.0 - 451.1)
(754.8 - 1101.0)(754.8 - 911.3)(754.8 - 636.0)
+
(50.128)
(451.1 - 1101.0)(451.1 - 911.3)(451.1 - 636.0)
= (-0.098494)(25.113) + (0.51972)(30.131) + (0.69517)(40.120) + (-0.11639)(50.128)
= 35.242°C
8
NEWTONS DIVIDED DIFFERENCE
 What is divided difference?
f[x0,x1] =
f[x1] – f[x0]
f[x0,x1,x2] =
x1 – x0
f[x1,x2] – f[x0,x1]
f[x0, x1, …, xk-1, xk] =
for k = 3, 4, ….. n.
x2 – x1
f[x1,x 2 - xk ] - f[x 0 ,...,xk-1]
xk - x 0
These Ist, IInd... and kth order differences are denoted
by f, 2f, …, kf.
9
INTERPOLATION USING DIVIDED
DIFFERENCE
 The divided difference interpolation
polynomial is:
P(x) = f(x0) + (x – x0) f [x0, x1] + L + (x – x0) L
(x – xn-1) f[x0, x1, …, xn]
10
Example
 For the data
x:
–1
0
2
5
f(x) :
7
10
22
235
 Find the divided difference polynomial and estimate
f(1).
11
Solution
X
-1
f
7
f
 2f
 3f
3
0
10
1
2
6
2
22
5
235
13
71
P(x) = f(x0) + (x – x0) f[x0, x1] + (x – x0) ( x – x1) f [x0, x1, x2] +
(x – x0) (x – x1) (x – x2) f [x0, x1, x2, x3]
= 7 + (x +1)  3 + (x +1) (x – 0)  1 + (x +1) (x –0) (x – 2)  2
= 2x3 – x2 + 10
P (1) = 11
12
INTERPOLATION FOR
EQUALLY SPACED POINTS
Let (X0,,Y0), (X1,,Y1), …, (Xn,,Yn) be the given points with
Xi+1 = Xi +h,i = 0,1,2,…, (n-1).
 Finite Difference Operators
●
Forward difference operator
f(xi) = f (xi + h) – f (xi)
●
Backward difference operator
f(xi) = f (xi) – f (xi – h)
●
Central difference operator

f(xi) = f
h-f

 xi + 
2

h

 xi - 
2

13
INTERPOLATION FOR
EQUALLY SPACED POINTS
●
Shift operators
E f(xi) = f(xi +h)
Er f(xi) = f (xi +rh)
●
Averaging operator
1
 f(xi) =
2
[
h
h


f  xi +  + f  xi - 
2
2


]
14
RELATION BETWEEN OPERATORS
 fi
 
 
 
= fi+1 = dfi+ ½
= E – 1,  = 1 – E-1
= E½ – E-½
= ( E½ + E- ½)
15
NEWTON GREGORY FORWARD
INTERPOLATION
For convenience we put p = x - x 0 and f0 = y0. Then we have
h
P(x 0 + ph) = y o + pDy 0 +
p(p – 1) 2
p(p - 1)(p - 2) 3
D y0 +
D y0 +
2!
3!
+
p(p - 1)(p - 2) L (p - n + 1) n
D y0
n!
16
Example
Estimate f (3.17)from the data using Newton
Forward Interpolation.
x: 3.1
f(x): 0
3.2
0.6
3.3
1.0
3.4
1.2
3.5
1.3
17
Solution
First let us form the difference table
x
3.1
y
0
y
2y
3y 4y
0.6
3.2 0.6
- 0.2
0.4
3.3 1.0
0
- 0.2
0.2
3.4 1.2
0.1
0.1
-0.1
0.1
3.5 1.3
Here x0 = 3.1, x = 3.17, h = 0.1.
18
Solution
p=
x - x0
h
=
0.07
0 .1
= 0.7
Newton forward formula is:
P(x)
= y0 + py0+
p ( p - 1)
2!
P(3.17)=0+0.70.6+
2y0+
0.7(0.7 - 1)
2
p(p - 1)( p - 2)
3!
(-0.2)+
3y0+
p(p - 1)( p - 2)( p - 3)
4!
0.7(0.7 - 1)( 0.7 - 2)
6
0+
4y0
0.7(0.7 - 1)( 0.7 - 2)( 0.7 - 3)
24
 0.1
= 0.4384
Thus f(3.17) = 0.4384.
19
NEWTON GREGORY BACKWARD
INTERPOLATION FORMULA
Taking p =
x - xn
h
, we get the interpolation formula as:
p(p + 1) 2
p(p + 1)(p + 2) 3
 yn +
 yn
2!
3!
p (p + 1) (p + 2)  (p + n - 1) n
 yn
n!
P(xn+ph) = y0 + pyn +
+L +
20
Example
Estimate f(42) from the following data using newton
backward interpolation.
x:
f(x):
20
354
25
332
30
291
35
260
40
231
45
204
21
Solution
The difference table is:
x
f
20 354
f
2f
3f 4f 5f
and p = - 0.6
- 22
25 332
Here xn = 45, h = 5, x = 42
- 19
- 41
30 291
29
10
- 31
35 260
-37
-8
2
- 29
40 231
45
8
0
2
- 27
45 204
22
Solution
Newton backward formula is:
P(x) = yn+pyn+
p(p + 1)(p + 2) 3
p(p + 1)(p + 2)(p + 3) 4
p(p + 1) 2
 yn+
 y n+
 yn +
3!
4!
2!
p(p + 1)(p + 2)(p + 3)(p + 4) 5
 yn
5!
P(42)=204+(-0.6)(-27)+
(-0.6)(0.4)(1.4)(2.4)(3.4)
120
Thus,
(-0.6)(0.4)
(-0.6)(0.40(1.4)
(-0.6)(0.4)(1.4)(2.4)
2+
0+
2
6
24
8+
 45 = 219.1430
f(42) = 219.143
23
INTERPOLATION USING CENTRAL
DIFFERENCES

Suppose the values of the function f (x) are known at the points a -3h, a
– 2h, a – h, a, a +h, a + 2h, a + 3h, ... etc. Let these values be y-3, y-2,
y-1, y0, y1, y2, y3 ..., and so on. Then we can form the central difference
table as:
x
f(x)
a-3h
y-3
f
2f
3f
4f
5f
6f
y-3
a-2h
2y-3
y-2
3y-3
y-2
a-h
2y-2
y-1
3y-2
y-1
a
2y-1
y0
y2
a+3h
y3
y2
6y-3
5y-2
4y-1
3y0
y1
a+2h
4y-2
2y0
y1
5y-3
3y-1
y0
a+h
4y-3
2y1
We can relate the central difference operator  with  and E using the operator
24
relation  = E½.
GAUSS FORWARD
INTERPOLATION FORMULA
p
p 2
 p + 1 3
 p + 1 4
  y-1+ 
  y-2 +
P(x) = y0+   y0+    y-1+ 
1
2
3
4
 
 




p=
p + 2 5

  y-2 + L where
5


x - x0
p = p(p - 1)(p - 2)(p - r +1)
and
r
h
r!
()
25
GAUSS FORWARD
INTERPOLATION FORMULA
• The value p is measured forwardly from the origin and
0<p<1.
• The above formula involves odd differences below the
central horizontal line and even differences on the line.
This is explained in the following figure.
2y-1
y0
y0
4y-2
3y-1
6y-3
5y-2
26
Example
Find f(30) from the following table values using Gauss
forward difference formula:
x:
21
25
29
33
37
F(x):
18.4708
17.8144
17.1070
16.3432
15.5154
27
Solution
The difference table is
f
x
f
21
18.4708
2f
3f
4f
-0.6564
25
17.8144
- 0.0510
-0.7074
29
17.1070
- 0.0054
0.0564
-0.7638
33
16.3432
- 0.0022
- 0.0076
- 0.0640
-0.8278
37
15.5154
p
P(x) = y0 +   y0 +
1
p 2
   y-1 +
 2
 p + 1 3

  y-1 +
3


 p + 1 4

  y-2 + L
4


f (30) = 16.9217
28
GAUSS BACKWARD
INTERPOLATION FORMULA
This formula is used to interpolate the value of the
function for a negative value of p and – 1<p<0. By
substituting for y0, 2y0, 3y0, ....... in terms of central
difference in the Newton Forward Difference formula, we
get
P(x) = y0 +
p
  y-1
 1
+
 p + 1 2

  y-1
 2 
+
 p + 1 3

  y-2 +
 3 
 p + 2 4

  y-2
 4 
+…
29
GAUSS BACKWARD
INTERPOLATION FORMULA
 This formula involves odd differences above the central
horizontal line and even differences on the central line.
y-1
y0
3y-2
2y-1
5y-3
4y-2
6y-3
30
Example
Estimate cos 51 42' by Gauss backward
interpolation from the following data:
x:
cos x:
50
51
52
53
54
0.6428 0.6293 0.6157 0.6018 0.5878
31
Solution
x0 = 52, x = 51 42' = 51.7, h = 1
x - x0
h
P=
=
51.7 - 52
1
= -0.3
The difference table is
X
y
50
0.6428
y
2y
3y
4y
- 0.0135
51
0.6293
- 0.0001
- 0.0136
x0 = 52
0.6157
- 0.0002
- 0.0003
- 0.0139
53
0.6018
0.0004
- 0.0002
- 0.0001
- 0.0140
54
0.5878
32
Solution
The Gauss backward formula is:
P(x) = y0 +
p
  y-1
1
+
 p + 1 2

  y-1
2


+
 p + 1 3

  y-2
3


+
 p + 2 4

  y-2
3


P(51.7) = 0.6198
33
STIRLING’S FORMULA
 This formula gives the average of the values obtained by
Gauss forward and backward interpolation formulae. For
using this formula we should have – ½ < p< ½.
We can get very good estimates if - ¼ < p < ¼.
The formula is:
P(x) =
  y 0 +  y -1  p 2
y0+p  2  +

 2!
 y-1+
2
p(p 2 - 1)
3!
 3 y -1 + 3 y - 2  p 2 (p - 1) 4

 +
 y-2
2
4
!


+ ...
34
Example
 Using Sterling Formula estimate f (1.63) from the
following table:
x: 1.50
1.60
1.70
1.80
1.90
f(x):17.609 20.412 23.045 25.527 27.875
Solution
X0 = 1.60, x = 1.63, h = 0.1
p=
1.63 – 1.60
= 0.3
0.1
35
Solution
 Difference table
x
y
1.50 17.609
y
 2y
 3y
 2y
2.803
x0= 1.60 20.412
1.70 23.045
1.80 25.527
2.633
2.482
2.348
-0.170
-0.151
0.019
0.017
-0.02
-0.134
1.90 27.875
36
BESSELS’ INTERPOLATION
FORMULA
 This formula involves means of even difference on and
below the central line and odd difference below the line.
 The formula is
P(x) =
+
y 0 + y1 æ 1 ö
p (p – 1)
+ çp – ÷ Dy 0 +
è
2
2ø
2!
1ö
æ
p
ç
÷ p (p – 1)
è
2ø
3!
3y-1 +
æD2 y- 1 + D2 y0 ö
ç
÷
2
è
ø
(p + 1) (p – 1) (p – 2)
4!
æD4 y –2 + D4 y –1 ö
ç
÷
2
è
ø
37
BESSELS’ INTERPOLATION
FORMULA
Note
 When p = 1/2 , the terms containing odd differences vanish.
 Then we get the formula in a more simple form:
y 0 + y1 p (p – 1) æD2 y- 1 + D2 y0 ö
P(x) =
+
ç
÷
2
2!
2
è
ø
(p + 1) p(p – 1)(p – 2) æD4 y –2 + D4 y –1 ö
+
+
ç
÷
4!
2
è
ø
38
Example
Use Bessels’ Formula to find (46.24)1/3 from the
following table of x1/3.
X:
X1/3:
41
45
49
53
3.4482 3.5569 3.6593 3.7563
39
Solution
x0 = 45,
x = 46.24,
Difference table is:
x
Y
y
h = 4 p = 0.31
 2y
 3y
41 3.4482
0.1087
x0 =
45 3.5569
-0.0063
0.1024
49 3.6593
-0.00091
-0.0054
0.0970
53 3.7563
Applying Bessels’ formula, we get
(46.24)1/3 = 3.5893
40
Download