Document 15070660

advertisement
Matakuliah
Tahun
: S0262-Analisis Numerik
: 2010
Interpolation
Pertemuan 11
Material Outline
• Interpolation
– Linear interpolation
– Quadratic interpolation
– Lagrange interpolation

INTERPOLATION
•
As in the case of Curve Fitting, Interpolation is a tool to
estimate intermediate values between precise data
points.
One of the methods that frequently used is Polynomial
Interpolation.
nth order Polynomial  f(x)= a0 + a1x + a2x2 + …anxn
For n+1 data points, there is only one nth order
Polynomial that fit the data points.
In this slides, only the linear and quadratic
interpolations will be discussed.
•
•
•
•
4
LINEAR INTERPOLATION
•
•
This interpolation is the simplest method to estimate
the values between 2 data points. The estimation was
done by connecting the two points with a straight line:
Assume the coordinate of the two data points are :
(x1,y1), (x2,y2) then the intermediate values (f(x)) for
x1<x<x2 can be written as:
y2  y1
f ( x)  y1 
( x  x1 )
x2  x1
y2
f(x)
y1
x1 x x2
5
LINEAR INTERPOLATION
•
Example: Assume the population of a country in Africa
is given in the following table:
Year
1998
2000
2002
Population
72,4 million
75,1 million
77 million
Use a linear interpolation to estimate the
population of the country in the year of 1999 and
2001.
Solution:
6
LINEAR INTERPOLATION
Year
1998
2000
2002
Population
72,4 million
75,1 million
77 million
y2  y1
( x  x1 )
x2  x1
75,1  72,4
f (1999)  72,4 
(1999  1998)  73,75million
2000  1998
Solution: f ( x)  y1 
77  75,1
f (2001)  75,1 
(2001  2000)  76,05million
2002  2000
7
QUADRATIC INTERPOLATION
•
•
It is obvious that the weakness of linear interpolation is that the
method force the linear trend of Interpolate the intermediate
values.
To improve this obvious weakness, the quadratic interpolation will
be discussed:
y3
y2
f(x)
y1
x1 x x2
x3
8
•
Referring to the following figure, the formula to approximate the
intermediate values f(x) for x1<x<x3 is given below:
f ( x)  y1  b0 ( x  x1 )  b1 ( x  x1 )( x  x2 )
in which :
y2  y1
b0 
x2  x1
y3  y2 y2  y1

x3  x2 x2  x1
b1 
x3  x1
y3
y2
f(x)
y1
x1 x x2
x3
9
QUADRATIC INTERPOLATION
•
Example: Assume the population of a country in Africa is
given in the following table:
Year
1998
2000
2002
Population
72,4 million
75,1 million
77 million
Use a quaratic interpolation to estimate the population of the
country in the year of 1999 and 2001.
Solution:
10
QUADRATIC INTERPOLATION
Year
1998
2000
2002
Population
72,4 million
75,1 million
77 million
Solution: : x1=1998, x2= 2000, x3= 2002
y1=72.4
y2= 75.1
75.1  72.4
b0 
 1.35; b1 
2
y3= 77
7775.1
2
 75.172.4  2
 0.1
4
f (1999)  72.4  1.35  0.1(1)( 1)  73.85 million
f (2001)  
11
EXERCISE 1: Use a linear interpolation to fill in the missing
data from the following table:
x
2
3
4,5
5
6
7,5
9
y
7
……
9,5
….
8,5
….
10,5
EXERCISE 2: Use a quadratic interpolation to fill in the
missing data from the following table:
x
2
3
4,5
5
6
7,5
9
y
7
……
9,5
….
8,5
….
10,5
12
LAGRANGE INTERPOLATION
•
This interpolation is the reformulation of the Newton
Polynomials and can be written as:
n
f n ( x)   Li ( x) f ( xi )
i 0
Example :
x  x0
x  x1
for n  1  f1 ( x) 
f ( x0 ) 
f ( x1 )
x0  x1
x1  x0
x  x1 x  x2  f ( x ) 
x0  x1 x0  x2  0
x  x0 x  x2  f ( x )  x  x0 x  x1  f ( x )
x1  x0 x1  x2  1 x2  x0 x2  x1  2
for n  2  f 2 ( x) 
Li ( x) 
n
x  xj
j 0, j i
xi  x j

LAGRANGE INTERPOLATION
Example: Use Lagrange interpolation of 1st and 2nd order to
evaluate f(2) from the following data:
i
xi
F(x i)
0
1
0
1
4
1.3863
2
6
1.79176
Download