W12_Interpolation0
-
Upload
danny-manno -
Category
Documents
-
view
215 -
download
0
Transcript of W12_Interpolation0
-
8/2/2019 W12_Interpolation0
1/27
Centre for Computer Technology
ICT114Mathematics for
Computing
Week 12
Interpolation
-
8/2/2019 W12_Interpolation0
2/27
March 20, 2012 Copyright Box Hill Institute
Curve Fitting
A relation between two variables isexpressed mathematically by an equation
connecting both. Finding equations approximating curves
that fit the given set of data is called curve
fitting.
-
8/2/2019 W12_Interpolation0
3/27
March 20, 2012 Copyright Box Hill Institute
Objectives
Review week 11
Problem of Interpolation
Finite Differences Diagonal differencetable
Newtons Forward Interpolation
Newtons Backward Interpolation
Lagranges Interpolation
-
8/2/2019 W12_Interpolation0
4/27
March 20, 2012 Copyright Box Hill Institute
Method of Least Squares (1)
For the data points (x1, y1), (x2,y2),.(xn,yn)
Let y = a+bx is the least squares line a and b are determined by solving the
(normal) equations
y = an + b x xy = a x + b x2
-
8/2/2019 W12_Interpolation0
5/27
March 20, 2012 Copyright Box Hill Institute
Method of Least Squares (2)
( y) (x2)( x) (xy)
a = ---------------------------------------------
n x2(x)2
n xy ( x)( y)
b = ----------------------------------------------n x2(x)2
-
8/2/2019 W12_Interpolation0
6/27
Centre for Computer Technology
NewtonsForward/BackwardInterpolation
-
8/2/2019 W12_Interpolation0
7/27
March 20, 2012 Copyright Box Hill Institute
Problem of Interpolation
The following table givesthe value of logx for certain
values of x To determine the value of
logx for x = 96.45 (which is
not given in the table), weuse the method ofInterpolation.
x y=logx
9596
97
9899
1.97771.9823
1.9868
1.99121.9956
-
8/2/2019 W12_Interpolation0
8/27
March 20, 2012 Copyright Box Hill Institute
Finite Differences Diagonal
Difference TableIn the table in the next slide
a any argument (for x)h any positive constant
f(x) = f(x+h) f(x) = first difference
f(a) is called the leading termf(a),2f(a),3f(a) are called the leadingdifferences
-
8/2/2019 W12_Interpolation0
9/27
March 20, 2012 Copyright Box Hill Institute
Argument
x
Entry
f(x)
1st
Differencef(x)
2nd
Difference2f(x)
3rd
Difference3f(x)
a f(a)
f(a)
a+h f(a+h) 2f(a)
f(a+h) 3f(a)
a+2h f(a+2h) 2f(a+h)
f(a+2h)
a+3h f(a+3h)
-
8/2/2019 W12_Interpolation0
10/27
March 20, 2012 Copyright Box Hill Institute
Newton's Forward Interpolation
u = (x x0)/h
(x)= (x0+uh)= y0 + u.y0 + u(u-1)/2! .
2y0+ ..
.+ u(u-1)(u-2).(u-n+1)/n! .ny0
y0 = f(x0)
-
8/2/2019 W12_Interpolation0
11/27
March 20, 2012 Copyright Box Hill Institute
Newtons Backward Interpolation
u = (x xn)/h
(x)= (xn+uh)= yn + u.yn-1 + u(u+1)/2! .
2yn-2+ ..
.+ u(u+1)(u+2).(u+n-1)/n! .ny0
yn = f(xn)
-
8/2/2019 W12_Interpolation0
12/27
March 20, 2012 Copyright Box Hill Institute
Example
From the followingtable determine thevalue of e0.1245 and
e0.1895
The first step is toconstruct the diagonal
difference table
x y=ex
0.12
0.13
0.140.15
0.16
0.17
0.18
0.19
1.127497
1.138828
1.1502741.161834
1.173511
1.185305
1.197217
1.209250
-
8/2/2019 W12_Interpolation0
13/27
X y=ex y 2y
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
1.127497
1.138828
1.150274
1.161834
1.173511
1.185305
1.197217
1.209250
0.011331
0.011446
0.011560
0.011677
0.011794
0.011912
0.012033
0.000115
0.000114
0.000117
0.000117
0.000118
0.000121
-
8/2/2019 W12_Interpolation0
14/27
March 20, 2012 Copyright Box Hill Institute
To determine e0.1245 we have to interpolate at thebeginning of the table.
h = 0.01, x0 = 0.12, x = 0.1245
so, u = (0.1245 0.12)/0.01 = 0.45
therefore,f(0.1245) =y0 + u.y0 + u(u-1)/2! .
2y0
= 1.127497 + 0.45 x 0.011331
+ 0.45 x (0.45-1) /2! x 0.000115
= 1.13258172
Actual value = 1.13258202
-
8/2/2019 W12_Interpolation0
15/27
March 20, 2012Copyright Box Hill Institute
To determine e0.1895 we have to interpolate at theend of the table.
h = 0.01, xn = 0.19, x = 0.1895
so, u = (0.1895 0.19)/0.01 = -0.05
therefore,
(0.1895) =yn + u.yn-1+ u(u+1)/2! .2yn-2= 1.209250 + (-0.05) x 0.012033
+(-0.05)(-0.05+1) / 2! x 0.000121
= 1.20864548
Actual value = 1.208645124
-
8/2/2019 W12_Interpolation0
16/27
March 20, 2012Copyright Box Hill Institute
Question
Find the value of
log(96.45) and
log(98.75)using Newton's interpolation formulae fromthe table given in the second slide.
Compare them with the actual value.
-
8/2/2019 W12_Interpolation0
17/27
Centre for Computer Technology
Lagranges Interpolation
-
8/2/2019 W12_Interpolation0
18/27
March 20, 2012Copyright Box Hill Institute
Lagranges Interpolation
Newtons formulae can only be used for
equidistant values of the argument
But sometimes it is difficult to obtaintabulated values of a function forequidistant values of the argument.
To deal with such a situation we useLagranges interpolation formula
-
8/2/2019 W12_Interpolation0
19/27
March 20, 2012Copyright Box Hill Institute
The Lagranges Interpolation formula is given below
(x-x1)(x-x2)..(x-xn)(x) = --------------------------------- y0
(x0-x1)(x0-x2)(x0-xn)
(x-x0)(x-x2)..(x-xn)+ ---------------------------------- y1 +
(x1-x0)(x1-x2)(x1-xn)
(x-x0)(x-x2)..(x-xn-1)+ --------------------------------- yn
(xn-x0)(xn-x2)(xn-xn-1)
-
8/2/2019 W12_Interpolation0
20/27
March 20, 2012Copyright Box Hill Institute
Example
From the given table find the value of y for x = 3.743
x y
3.7428037
3.7428822
3.7429607
3.74303923.7431176
5531
5532
5533
55345535
x0 = 3.7428037, y0 = 5531
x1 = 3.7428822, y1 = 5532x2 = 3.7429607, y2 = 5533
x3 = 3.7430392, y3 = 5534
x4 = 3.7431176, y4 = 5535
x = 3.743
-
8/2/2019 W12_Interpolation0
21/27
March 20, 2012Copyright Box Hill Institute
(x-x1)(x-x2)(x-x3) (x-x4)(x) = ---------------------------------- y0 (0.0234250 x 5531)
(x0-x1)(x0-x2)(x0-x3)(x0-x4)
(x-x0)(x-x2)(x-x3)(x-x4)+ ------------------------------------ y1 + (-0.156157 x 5532)
(x1-x0)(x1-x2)(x1-x3)(x1-x4)
(x-x0
)(x-x1
)(x-x3
)(x-x4
)+ ------------------------------------ y2 + (0.702259 x 5533)
(x2-x0)(x2-x1)(x2-x3)(x2-x4)
(x-x0)(x-x1)(x-x2)(x-x4)+ ------------------------------------ y3 + (0.469666 x 5534)
(x3-x0)(x3-x1)(x3-x2)(x3-x4)
(x-x0)(x-x1)(x-x2)(x-x3)+ ------------------------------------ y4 (-0.0391929 x 5535)
(x4-x0)(x4-x1)(x4-x2)(x4-x3)
-
8/2/2019 W12_Interpolation0
22/27
March 20, 2012Copyright Box Hill Institute
y = (3.743)
= (0.0234250 x 5531)
+ (-0.156157 x 5532)
+ (0.702259 x 5533)+ (0.469666 x 5534)+ (-0.0391929 x 5535)
= 5533.501
-
8/2/2019 W12_Interpolation0
23/27
March 20, 2012Copyright Box Hill Institute
Question
From the given table find the value of y for x = 0.135
x y
0.12
0.13
0.14
0.15
1.127497
1.138828
1.150274
1.161834
-
8/2/2019 W12_Interpolation0
24/27
March 20, 2012Copyright Box Hill Institute
Summary
Newtons Forward Interpolation formula
u = (x x0)/h
(x) = (x0+uh)
= y0
+ u.y0
+ u(u-1)/2! .2y0
+ ..
.+ u(u-1)(u-2).(u-n+1)/n! .ny0
y0 = f(x0)
-
8/2/2019 W12_Interpolation0
25/27
March 20, 2012Copyright Box Hill Institute
Summary
Newtons Backward Interpolation formula
u = (x xn)/h
(x)= (xn+uh)= yn + u.yn-1+ u(u+1)/2! .
2yn-2+ ..
.+ u(u+1)(u+2).(u+n-1)/n! .ny0
yn = f(xn)
-
8/2/2019 W12_Interpolation0
26/27
March 20, 2012
Copyright Box Hill Institute
SummaryThe Lagranges Interpolation formula is given below
(x-x1)(x-x2)..(x-xn)(x) = --------------------------------- y0
(x0-x1)(x0-x2)(x0-xn)
(x-x0)(x-x2)..(x-xn)+ ---------------------------------- y1 +
(x1-x0)(x1-x2)(x1-xn)
(x-x0)(x-x2)..(x-xn-1)+ --------------------------------- yn
(xn-x0)(xn-x2)(xn-xn-1)
-
8/2/2019 W12_Interpolation0
27/27
March 20, 2012
Copyright Box Hill Institute
References
H L Verma and C W Gross : Introduction toQuantitative Methods,John Wiley
JB Scarborough : Numerical Mathematical
Analysis, Jon Hopkins Hall, New Jersey Gerald W. Recktenwald, Numerical Methods
with MATLAB, Implementation and Application,Prentice Hall
Murray Spiegel, John Schiller, Alu Srinivasan,Probability and Statistics, Schaums easyOutlines
http://mathworld.wolfram.com