Upload
others
View
11
Download
0
Embed Size (px)
Citation preview
SSCE2393NUMERICALMETHODS
CHAPTER3INTERPOLATION
FarhanaJohar,DepartmentofMathematicalSciences,FacultyofScience,[email protected]
2
OverviewofChapter3
3.1 Whatisinterpolation
3.2 LagrangeInterpolation
3.3 Newton’sdivideddifference
3.4 Newton’sforwarddifference
3.5 Newton’sbackwarddifference
3
3.1 WhatisInterpolation• Istheprocessofestimatinganintermediatevalueofasetdata.
• Suppose{ )},(...),,(),,( 1100 nn yxyxyx bethesetof( 1+n )givenpoints.Theprocessoffindingthevalueofycorrespondingtoanyvalueof ixx = between 0x and nx ,iscalledinterpolation.
• Oneofsimplestapproachtointerpolationisbasedonpolynomial.
• Ideabehindinterpolationistofindapolynomialwhichagreeswithspecifieddatapoints.
• Weseekapolynomialinterpolation )(xPn ofdegree n≤ suchthat:
.,...,2,1,0,)( niyxP iin ==
• Thispolynomialcanthenbeusedtogenerateapproximatevaluesatotherpointsbetween 0x and nx
4
( )( )11, xfx
( )( )22 , xfx
( )( )33 , xfx
Aim:Tofindafunction )(xPn thatexactlyrepresentsacollectionofdata.
(a)
(b)n 0 1 ..nx .. .. ..( )nxf .. .. ..
(c) ( ) ( ) ,.., 10 bxfaxf ==
( )( )00 , xfx
10 5 0 5 10
10
5
5
10
5
3.2 LagrangePolynomialInterpolationGeneralformulaforLagrangepolynomialInterpolationwhichpassingthroughallthepoints
))(,(...,)),(,()),(,( 1100 nn xfxxfxxfx ,
isgivenas:
)()(..)()()()()( 1100 nnn xfxLxfxLxfxLxP +++=
@
nnn yxLyxLyxLxP )(..)()()( 1100 +++= where
( ) ∏
≠= −
−=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
n
ijj jxix
jxxxiL
0
istheLagrangecoefficientthatsatisfies
( )∑=
=n
ixiL
01
6
Example1
FindtheLagrangepolynomialinterpolatingfordata1)4(,1)2(,1)0( −=−== fff and 1)6( =f .Henceevaluate )3(f
and )5(f .Example2a) Estimatelog4betweenlog3andlog5byusinglinear
Lagrangeinterpolation.Thencomparetheresultwiththeexactsolution.
b) Thedensityofachemicalmaterialatthreedifferent
temperaturesisgivenbelow:Temperature( C0 ) 90 200 300
Density( 3/ cmkg ) 950 900 850
i) WritethesuitableLagrangeformulafortheabovedata.ii) Estimatethedensityofabovechemicalmaterialwhen
temperatureis250 C0 .
7
3.3 Newton’sdivided-differenceformulaGeneralFormulaforNewton’sdivided-differencethatpassingthroughallthepoints
))(,(...,)),(,()),(,( 1100 nn xfxxfxxfx ,
isgivenas:
( ) ( ) ( )( )( )( ) ( )110
102010...... −−−−++
−−+−+=
nn
nxxxxxxaxxxxaxxaaxP
Thecoefficient naaa ..,,, 10 ,àNewton’sdivided-difference. Thevalueofdivided-differencefor
( ){ }niii fx 0, = isdefinedas:
1,..,2,1]1[]1[
1][
]0[
, −=+
−−+
−−
=
=
njiji
ji
jij
i
ii
xxfff
ff
([ ]jif isdefineasj-thdivided-difference),andgiveninthetable
below:
8
TableforNewton’sdivided–difference
I ix ⎥⎦⎤
⎢⎣⎡0if ⎥⎦
⎤⎢⎣⎡1if ⎥⎦
⎤⎢⎣⎡2if …
⎥⎦⎤
⎢⎣⎡ −1nif [ ]n
if
0 0x 0f [ ]10f
[ ]20f [ ]1
0−nf
[ ]nf0
1 1x 1f [ ]11f
[ ]21f [ ]1
1−nf
! !
2−n 2−nx 2−nf [ ]12−nf
[ ]22−nf
1−n 1−nx 1−nf [ ]11−nf
n nx nf Given FromNewton’s divided-differenceformulaWealsocanwrite;
[ ]
[ ] [ ][ ]
[ ] [ ] [ ] [ ]
[ ] [ ][ ]20
02
10
11
02
01
00
01
12
01
02
02
01
01
12
12
2
10
01
00
01
01
011
0000
fxxff
xxxxff
xxff
xxxxff
xxff
a
fxxff
xxffa
ffa
=−
−=
−
−−
−−−
=−
−−
−−−
=
=−
−=
−
−=
==
9
Therefore,theNewton’sdivided-differencepolynomial
interpolationfor ( ){ }2 0, =iii fx (quadraticpolynomial)canbewrittenas:
( ) [ ] [ ]( ) [ ]( )( )102
0010
002 xxxxfxxffxP −−+−+=
Generally,Newton’sdivided-differenceformula,withdegreen≤ isgivenby;
( ) [ ] [ ]( ) [ ]( )( )[ ]( )( ) ( )1100
102
0010
00
...
...
−−−−
+−−+−+=
nn
n
xxxxxxf
xxxxfxxffxP
or
( ) [ ] ( )⎟⎟⎠
⎞⎜⎜⎝
⎛−= ∏∑
−
==
1
000
j
kk
n
j
jn xxfxP
10
Example1Giventhat 0 0.5 11, 1.6487, 2.7183e e e= = = ,useNewton’sDivideddifferenceformulatoestimatethevalueof 0.25e .Then,computetheabsoluteerror.Example2Forafunctionf,theDividedDifferencetableisgivenby: 0 0x = 0[ ] ?f x = 0 1[ , ] ?f x x = 1 0.4x = 1[ ] ?f x =
70 1 250[ , , ]f x x x =
1 2[ , ] 10f x x = 2 0.7x = 2[ ] 6f x = Determinethemissingentries,thenapproximatef(0.3).
11
3.4 InterpolationforuniformdataUniformdatameansthestepsize,hfor ix areallsameie;
hxxxxxx nn =−==−=− − )(..)()( 11201 Thereseveralmethodstotreatuniformdatasuchas;a) Newton’sforward-differenceandb) Newton’sbackward-difference
3.4.1Newton’sforwarddifferenceNewton’sforward-differenceformula
( ) ( ) ( )( )
( )( ) ( )0
03
02
00
!...21
...!3
21!21
fn
nrrrr
frrrfrrfrfxP
n
n
Δ−−−
+
+Δ−−
+Δ−
+Δ+=
hxxr 0 where −
=
12
TableforNewton’sforward-difference
i ix if ifΔ if2Δ …
ifn 1−Δ if
nΔ
0 0x 0f 0fΔ 02 fΔ
0
1 fn−Δ 0fnΔ
1 1x 1f 1fΔ 12 fΔ
1
1 fn−Δ
! !
2−n 2−nx 2−nf 2−Δ nf 22
−Δ nf
1−n 1−nx 1−nf 1−Δ nf
n nx nf
Given fromNewton’sforward-differenceformula
ik
ik
ik fff 1
11 −
+− Δ−Δ=Δ
13
Example1ByusingNewton’sForwardDifferenceformula,showthatthepolynomialinterpolatingthefollowingdatahasdegree3.
x -2 -1 0 1 2 3f(x) 1 4 11 16 13 -4
Example2Newtonforwarddifferenceformulaorderthreecanbewrittenas( ) ( ) 320 CxBxAxfxf +++= .Findthecoefficients , and A B C ifyouaregiventhefollowingdata:( ) ( ) ( ) ( ) ( ) ( )0 3, 1 2, 2 7, 3 24, 4 59 and 5 118f f f f f f= = = = = = .
Thenestimatethevalueof ( )0.1f byusingtheaboveformula.CanyougettheNewtonforwarddifference’sformulaforthefourthorderfromthegivendata?Explainyouranswer.
14
3.4.2Newton’sbackward-differenceNewton’sbackward-differenceformula
( ) ( ) ( )( )
( )( ) ( )n
n
nnnnn
fn
nrrrr
frrrfrrfrfxP
∇+++
+
+∇++
+∇+
+∇+=
!...21
...!3
21!21 32
hxxr n−
= where
TableforNewton’sbackward-differencei ix if if∇ if
2∇ …i
n f1−∇ in f∇
0 0x 0f
1 1x 1f 1f∇
2 2x 2f 2f∇ 22 f∇
! !
1−n 1−nx 1−nf 1−∇ nf 12
−∇ nf
1
1−
−∇ nn f
n nx nf nf∇ nf2∇ n
n f1−∇ nn f∇
Given fromNewton’sbackward-
differenceformula
111
−−− ∇−∇=∇ ik
ik
ik fff
15
Example1Given
x 1.0 1.2 1.4 1.6 1.8)(xf 0.0000 0.1823 0.3365 0.4700 0.5878
Findanapproximationof ( )7.1f usingtheNewton’sbackward-differenceformula.Dothecalculationusing4decimalplaces.Example2Giventhefollowingdata;
x 1 1.2 1.4 1.6 1.8 2.0( )xf 0.6570 0.9039 0.9985 0.9407 0.7344 0.4121
Bychoosingthesuitabledata,estimatethevalueof ( )5.1f usingcubicinterpolation’sformulaof:
a) Newtonforwarddifference,b) Newtonbackwarddifference