Professional Documents
Culture Documents
ME 361-Interpolation
ME 361-Interpolation
INTERPOLATION
1.00 In engineering and science, one often
has a number of data points, obtained
0.80
by sampling or experimentation, which
0.60 represent the values of a function, f(x),
for a limited number of values of
0.40
the independent variable, x. It is often
required to interpolate, i.e., estimate
0.20
the value of that function for an
f(x) = ?
0.00 intermediate value of the independent
0.0 2.0 4.0 6.0
x variable.
INTERPOLATION
INTERPOLATING POLYNOMIALS
Answer: Replace the data with a polynomial of some chosen, small degree, n,
Example:
xi 0 1 2 3 4 5 6
f(xi) 1 0.368 0.135 0.050 0.018 0.007 0.002
1.00
0.80
At x = 2.5
0.60
f(x) = f (2.5) = ?
Error = ?
0.40
0.20
0.00
0.0 1.0 2.0 3.0 4.0 5.0 6.0
Solution:
Forward
Answer: Use Newton-Gregory difference tables Backward
Central
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Newton-Gregory Formulae
Forward
Define f i = f i+1 - f i First forward difference at i
Differences
Backward
Differences f i f i - f i -1 First backward difference at i
n f i n1 f i - n1 f i - 1
x - x0 x - x0
Define s= = where h is constant
x h
s (s - 1) 2 s (s - 1) ... (s - n 1) n
Pn (x) f 0 s f 0 f 0 ... f0
2! n!
s (s - 1) (s - 2) ... (s - n) n 1 (n 1)
E (x) h f ( )
Error:
(n 1)!
(x - x 0 ) (x - x1 ) ... (x - x n ) (n 1)
E (x) f ( ) , x 0 x n
(n 1)!
To estimate the error, replace the (n+1)th derivative with (n+1)th divided difference.
1 0.367879441
2 0.135335283
3 0.049787068
4 0.018315639
5 0.006737947
6 0.002478752
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Find the constants of the polynomial: Use the difference table and the formula
How do you estimate the error? Use the difference table and the formula
x - x0 x-1
Define s = =x-1
h 1
s (s - 1) 2 s (s - 1) (s - 2) 3
P3 (s) f0 s f0 f0 f0
2! 3!
(x - 1) (x - 2) x - 3 (x - 4)
E (x) f (4) ( )
Error: 4!
(x - 1) (x - 2) x - 3 (x - 4) 4 f0
E (x)
4! h4
x f (x) f 2 f 3 f
0 0
1
1 1 2
3 0
2 4 2
5 0
3 9 2
7 0
4 16 2
9
5 25
x f (x) f 2 f 3 f
0 0
1
1 1 1.9
2.9 0.3
2 3.9 2.2
5.1 - 0.3
3 9 1.9
7 0.1
4 16 2
9
5 25
(x - x1 ) (x - x 2 ) ... (x - x n-1 ) (x - x n )
Pn (x) = f (x 0 )
(x 0 - x1 ) (x 0 - x 2 ) ... (x 0 - x n-1 ) (x 0 - x n )
(x - x 0 ) (x - x 2 ) ... (x - x n-1 ) (x - x n )
+ f (x1 )
(x1 - x 0 ) (x1 - x 2 ) ... (x1 - x n-1 ) (x1 - x n )
+ ...
(x - x 0 ) (x - x1 ) ... (x - x n-2 ) (x - x n )
+ f (x n-1 )
(x n-1 - x 0 ) (x n-1 - x1 ) ... (x n-1 - x n-2 ) (x n-1 - x n )
(x - x 0 ) (x - x1 ) ... (x - x n-2 ) (x - x n-1 )
+ f (x n )
(x n - x 0 ) (x n - x1 ) ... (x n - x n-2 ) (x n - x n-1 )
Divided differences:
f i 1 - f i
D fi First-order forward divided difference
x i 1 - x i
D f i1 - D f i
D2 fi Second-order forward divided difference
x i2 - x i
D n -1 f i 1 - D n -1 f i
D fi
n
n'th-order forward divided difference
x in - x i
x f (x)
0 1
1 0.367879441
3 0.049787068
6 0.002478752
x f (x) Df
0 1
-0.632120559
1 0.367879441
-0.159046186
3 0.049787068
-0.015769439
6 0.002478752
x f (x) Df D2 f
0 1
-0.632120559
1 0.367879441 0.157691457
-0.159046186
3 0.049787068 0.02865535
-0.015769439
6 0.002478752
x f (x) Df D2 f D3 f
0 1
-0.632120559
1 0.367879441 0.157691457
-0.159046186 -0.021506018
3 0.049787068 0.02865535
-0.015769439
6 0.002478752
n
f (n 1) ( )
Error: E (x) f (x) - Pn (x) (x - x i )
i 0 (n 1) !
n
E (x) (x
i 0
- x i ) D n 1
fi
How do you estimate the error? Use the divided difference table
and the related formula
(x - 1) (x - 2) x - 3 (x - 4)
E (x) f (4) ( )
Error: 4!
E (x) (x - 1) (x - 2) x - 3 (x - 4) D 4f0
Note that the fourth divided difference, D4f, does nor exists. So, what do you do?
Example: An object is suspended in a wind tunnel and the force is measured for
various levels of wind velocity. The results are tabulated below.
V, m/s 10 20 30 40 50 60
F, N 25 70 380 550 610 1220
1400
(a) Find the force at V = 32 1200
800
degree interpolating
600
polynomial, P2(V).
400
(b) Estimate the error. 200
0
0 20 40 60 80
The truncation error will decrease but round-off will increase as the degree of
the polynomial increases.