انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Interpolation and Extrapolation

Share |
الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 2
أستاذ المادة سماح عبد الهادي عباس الهاشمي       26/03/2017 14:22:59
Interpolation
2-Lagrange Approximation
Interpolation means to estimate amassing function value by taking a
weighted average of known function value of neighboring point.
Linear Interpolation
Linear Interpolation uses a line segment passes through two distinct
pointes (x0 , y0) and (x1, y1) is the same as approximating a function f for
which f(x0) = y0 ,and f(x1) = y1 by means of first-degree polynomial
interpolation.
The slope between (x0, y0) and (x1, y1) is
Slope =m=
1 0
1 0
x x
y y
?
?
The point-
The point- slope formula for the line
y = m( x-x0 ) + y0
(x1, y1)
!!
!!
!!
P(x)
!!
(x0 , y0)
67
y =P(x) = m( x-x0 ) + y0 =
1 0
1 0
x x
y y
?
?
( x-x0 ) + y0
= y0 +(y1 - y0)
1 0
0
x x
x x
?
?
P1(x) = y0
0 1
1
x x
x x
?
?
+ y1
1 0
0
x x
x x
?
?
…………………… (4)
Each term of the right side of (4) involve a linear factor hence the sum is
a polynomial of degree ?1.
L1,0(x) =
0 1
1
x x
x x
?
?
, and L1,1(x) =
1 0
0
x x
x x
?
?
…………………… (5)
When x= x0, L1,0(x0)=1 and L1,1(x0)=0. When x= x1, L1,0(x1)=0 and
L1,1(x1)=1.
In terms L1,0(x) and L1,1(x) in Eq (5) called Lagrange coefficient of
polynomial hazed on the nodes x0 and x1,
P1(x0) = y0 =f(x0) ,and P1(x1) = y1 = f(x1) .
Using this notation in Eq (4), can be write in summation
P1(x) = y0 L1,0(x)+ y1 L1,1(x)
P1(x) =?
?
1
0
1 ( )
k
yk L k x .
Suppose that the ordinates
yk = f(xk).
If P1(x) is uses to approximante f(x) over intervalle [x0 x1].
Example 2
Consider the graph y = f(x) =cos(x) on (x0 = 0.0, and x1=1.2 ), to find the
linear interpolation polynomial.
Sol
Now y0 =f(x0) = f(0.0) = cos (0.0)= 1.0000, and
y1 =f(x1) = f(1.2) = cos (1.2)=0.3624,
L1,0(x) =
0 1
1
x x
x x
?
?
=
0.0 1.2
1.2
?
x ? =
1.2
? 1.2
? x , and
L1,1(x) =
1 0
0
x x
x x
?
?
=
1.2 0.0
0.0
?
x ? =
1.2
x .
P1(x) =?
?
1
0
1 ( )
k
yk L k x .
P1(x) = y0 L1,0(x)+ y1 L1,1(x)
P1(x) = -(1.0000)
1.2
x ? 1.2 + (0.3624)
1.2
x
P1(x) = -0.8333( x- 1.2) + 0.3020 x.
Quadratic Lagrange Interpolation
68
Interpolation of given pointes (x0 , y0), (x1, y1) and (x2, y2) by a second
degree polynomial P2(x), which by Lagrange summation as
P2(x) = y0 L1,0(x)+ y1 L1,1(x) + y2 L1,2(x).
P2(x) =?
?
2
0
1 ( )
k
k k x L y =?
?
2
0
1 ( ) ( )
k
k k f x L x .
L1,0(x) =
( )( )
( )( )
0 1 0 2
1 2
x x x x
x x x x
? ?
? ?
,
L1,1(x) =
( )( )
( )( )
1 0 1 2
0 2
x x x x
x x x x
? ?
? ?
L1,2(x)=
( )( )
( )( )
2 0 2 1
0 1
x x x x
x x x x
? ?
? ?
approximating a function f for which f(x0) = y0 ,and f(x2) = y2 by means
of second -degree polynomial interpolation.
Example 3
Using the nodes (x0 =2, x1=2.5 and x2 =4), to find the second interpolation
polynomial for f(x) =
x
1
.
Sol
We must find
L1,0(x) =
(2 2.5)(2 4)
( 2.5)( 4)
? ?
x ? x ?
= (x-6.5)x+10,
L1,1(x) =
(2.5 2)(2.5 4)
( 2)( 4)
? ?
x ? x ?
=
3
(?4x ? 24)x ? 32
L1,2(x)=
(4 2)(4 2.5)
( 2)( 2.5)
? ?
x ? x ?
=
3
(x ? 4.5)x ? 5
.
Now f(x0) = f(2) = 0.5, f(x1) = f(2.5) = 0.4, and f(x2) = f(4) = 0.25, and
P2(x) =?
?
2
0
1 ( )
k
k k x L y =?
?
2
0
1 ( ) ( )
k
k k f x L x .
P2(x) = y0 L1,0(x)+ y1 L1,1(x) + y2 L1,2(x)
= 0.5[x-6.5)x+10]+ 0.4[
3
(?4x ? 24)x ? 32
] +0.25 [
3
(x ? 4.5)x ? 5
];
P2(x) =[0.05 x-0.425]x +1.15
f(3)=
3
1
P2(3) = 0.325.
f(3)= P2(3) = 0.325.
Cubic Lagrange Interpolation
69
Interpolation of given pointes (x0 , y0), (x1, y1), (x2, y2) and (x3, y3) by a
third degree polynomial P3(x), which by Lagrange summation as
P3(x) = y0 L1,0(x)+ y1 L1,1(x) + y2 L1,2(x) + y3 L1,3(x),
P3(x) =?
?
3
0
1 ( )
k
k k x L y =?
?
3
0
( ) 1 ( )
k
f xk L k x .
L1,0(x) =
( )( )( )
( )( )( )
0 1 0 2 0 3
1 2 3
x x x x x x
x x x x x x
? ? ?
? ? ?
,
L1,1(x) =
( )( )( )
( )( )( )
1 0 1 2 1 3
0 2 3
x x x x x x
x x x x x x
? ? ?
? ? ?
L1,2(x)=
( )( )( )
( )( )( )
2 0 2 1 2 3
1 2 3
x x x x x x
x x x x x x
? ? ?
? ? ?
,
L1,3(x)=
( )( )( )
( )( )( )
3 0 3 1 3 2
1 2 3
x x x x x x
x x x x x x
? ? ?
? ? ?
Approximating a function f for which f(x0) = y0 ,and f(x3) = y3 by means
of third -degree polynomial interpolation.
Example 4
Consider the graph y = f(x) =cos(x) on (x0 = 0.0, x1= 0.4 , x2= 0.8 and x3
= 1.2), to find the cubic interpolation polynomial.
Sol
Now y0 =f(x0) = f(0.0) = cos (0.0)= 1.0000,
y1 =f(x1) = f(0.4) = cos (0.4)=0.9210,
y2 =f(x2) = f(0.8) = cos (0.8)=0.6967, and
y3 =f(x3) = f(1.2) = cos (1.2)=0.3624,
L1,0(x) =
( )( )( )
( )( )( )
0 1 0 2 0 3
1 2 3
x x x x x x
x x x x x x
? ? ?
? ? ?
=
(0.0 0.4)(0.0 0.8)(0.0 1.2)
( 0.4)( 0.8)( 1.2)
? ? ?
x ? x ? x ? ,
y0 L1,0(x) = -2.6042( x- 0.4)( x- 0.8)( x- 1.2),
y1 L1,1(x)= 7.1958( x- 0.0)( x- 0.8)( x- 1.2),
y2 L1,2(x)= -5.4430( x- 0.0)( x- 0.4)( x- 1.2)
y3L1,3(x)= 0.9436( x- 0.0)( x- 0.4)( x- 0.8).
P3(x) = y0 L1,0(x)+ y1 L1,1(x) + y2 L1,2(x) + y3 L1,3(x),
P3(x) =?
?
3
0
1 ( )
k
k k x L y =?
?
3
0
( ) 1 ( )
k
f xk L k x .
P3(x) = y0 L1,0(x)+ y1 L1,1(x) + y2 L1,2(x) + y3 L1,3(x),
P3(x) = -2.6042( x- 0.4)( x- 0.8) ( x- 1.2)+ 7.1958( x- 0.0)( x- 0.8)( x-
1.2)+ -5.4430( x- 0.0)( x- 0.4)( x- 1.2)+ 0.9436( x- 0.0)( x- 0.4)( x- 0.8).
, In general case we construct, for each k= 0, 1…n, we can write
70
= 1 if k = i
Ln,k(xi)
= 0 if k ? i
Where
Ln,k(x)=
( )( )...( )( )...( )
( )( )...( )( )...( )
0 1 1 1
0 1 1 1
k k k k k k k n
k k n
x x x x x x x x x x
x x x x x x x x x x
? ? ? ? ?
? ?

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم