Chapter 3 - Interpolation Curve Fitting With Tutorials
Chapter 3 - Interpolation Curve Fitting With Tutorials
1
3.1 Interpolation
10
(a) x3 , f x3
5 x2 , f x2
10 5 x10, f x1 5 10
x0 , f x0
5
10
(b)
n 0 1 ..
xn .. .. ..
f xn .. .. ..
2
3.2 Lagrange Polynomial Interpolation
( x0 , f ( x0 )), ( x1 , f ( x1 )),..., ( xn , f ( xn )) ,
is given as:
Pn ( x) L0 ( x) f ( x0 ) L1 ( x) f ( x1 ) .. Ln ( x) f ( xn )
where
n
x x
j
L x
i
j 0 x x
i j
j i
n
Li x 1
i0
3
Example 1
Example 2
4
3.3 Newton’s divided - difference formula
( x0 , f ( x0 )), ( x1 , f ( x1 )),..., ( xn , f ( xn )) ,
is given as:
Pn x a0 a1 x x0 a2 x x0 x x1
... an x x0 x x1 ... x xn1
The coefficient a0 , a1 , .., an , Newton’s divided-difference.
xi , fi in0
is defined as:
f i[ 0] f i
[ j 1] [ j 1]
f f
f i[ j ] i 1 i , j 1, 2,.., n 1
xi j xi
j
( fi is define as j-th divided - difference), and given in the table
below:
5
Table for Newton’s divided –difference
I x
i f 0 f 1 f 2 f n 1 f n
i i i i i
1 2 n 1 n
0 x0 f0 f0 f0 f0 f0
1 f1
2 n1
1 x1 f1 f1 f1
1 2
n2 xn 2 f n 2 f n2 f n2
1
n 1 xn1 f n1 f n1
n xn fn
6
We also can write;
0
a0 f 0 f 0
0 0
f1 f 0 f1 f 0 1
a1 f0
x1 x0 x1 x0
0 0 0 0
f 2 f1 f1 f 0 f 2 f1 f1 f 0
x2 x1 x1 x0 x2 x1 x1 x0
a2
x2 x0 x2 x0
1 1
f1 f 0 2
f0
x2 x0
P2 x f 0 f 0 x x0 f 02 x x0 x x1
0 1
7
Generally, Newton’s divided- difference formula, with degree
n is given by;
f 0 x x0 x x1 ...x xn 1
n
or
j
n j 1
Pn x f 0 x xk
j 0 k 0
Example 1
Example 2
8
3.4 Interpolation for uniform data
Uniform data means the step size, h for xi are all same ie;
( x1 x0 ) ( x2 x1 ) .. ( xn xn1 ) h
r r 1 2 r r 1r 2 3
Pn x f 0 rf 0 f0 f 0 ...
2! 3!
r r 1r 2...r n n
f0
n!
x x0
where r
h
9
Table for Newton’s forward -difference
x f 2 f i n 1 f i
i i f
i i n f i
0 x0 f0 f 0 2 f 0 n1 f 0 n f 0
1 x1 f1 f1 2 f1 n1 f1
n2 xn 2 f n 2 f n2 2 f n2
10
Example 1
x -2 -1 0 1 2 3
f (x) 1 4 11 16 13 -4
Example 2
11
3.4.2 Newton’s backward- difference
r r 1 2 r r 1r 2 3
Pn x f n rf n fn f n ...
2! 3!
r r 1r 2...r n n
fn
n!
x xn
where r
h
Table for Newton’s backward- difference
i xi fi f i 2 fi …
n 1 f i n f i
0 x0 f0
1 x1 f1 f 1
2 x2 f2 f 2 2 f2
n 1 xn1 f n1 f n1 2 f n1 n1 f n1
n xn fn f n 2 fn n1 f n n f n
12
Example 1
Given
Example 2
13
3.5 Least Square Curve Fitting
n n
S yi y xi yi A Bxi 2
2
i 0 i 0
14
S S
S is minimum when 0 and 0.
A B
These yield:
2 y
i 0
i A Bxi 1 0
n
2 y
i 0
i A Bxi xi 0
n n n
A1 B xi yi
i 0 i 0 i 0
n n n
A xi B xi xi yi
2
i 0 i 0 i 0
or in matrix form:
n n
n
1 x y i
i 0 i 0
i
A
i 0
n n
2 B n
xi xi i i
x y
i 0 i 0 i 0
15
Example 1
Given:
1 1.4
[ x] 5 , [ y] 1.1
7 0.2
Fit a linear least squares to the data.
Example 2
Find the normal equations which arise while fitting the least squares
method of the equation y = c1 + c2 sin x to the set points
(0,0), ( 6,1), ( 2,3), (5 6,2) . Solve them for c1 and c2.
16
b) Parabolic/Quadratic Least Squares
squares error:
n n 2
i 0 i 0
S S S
S is minimum if 0 , 0 and 0.
A B C
And we get,
n
2 yi A Bx i Cxi
2
1 0
i 0
n
2 yi A Bx i Cxi
2
x 0
i
i 0
n
2 yi A Bx i Cxi
2
x 0
i
2
i 0
Divide every equation with (-2) and expand it to get the normal
equations:
17
n n n n
A1 B xi C xi yi
2
i 0 i 0 i 0 i 0
n n n n
A xi B xi C xi xi yi
2 3
i 0 i 0 i 0 i 0
n n n n
A xi B xi C xi xi yi
2 3 4 2
i 0 i 0 i 0 i 0
xi xi i i
2
x i B x y
in0 i 0
n
i 0
n C in0
x2 xi x 2y
i x i i
3 4
i
i 0 i 0 i 0 i 0
Example 1
Given the six data points (0, 0.98), (0.1, 1.01), (0.2, 0.99),
(0.3,0.88), (0.4, 0.85), and (0.5, 0.77) which are represent by the
function y( x) a bx2 . Apply the least-squares method to find a
and b. Then, compute the total squares error, S.
18
3.5.2 Least Squares Power Function
Let say a set of data xi , yi i 0 is going to be fit into a power
n
n 2 n 2
S yi yxi yi Axi
B
i 0 i 0
S is minimum when
S
x 0
n
2 yi Axi
B B
0 i
A i 0
x
B
n n i yi
xi yi A xi 0 or A i 0
B 2B
n
i 0 i 0
x
2B
i
i 0
19
Example:
The higher the weight class, the greater the lift. Accordingly, it is
proposed that lift should be proportional to W 2/3 which arise the
equation L cW 2/3 . Determine the constant c by the least-squares
method.
20
3.5.3 Data Linearization
Let say a set of data xi , yi i 0 is going to be fit into a power
n
y Ce Dx
where C and D are constants. Apply ln to both sides to yield
ln y ln C Dx
Y A BX
linear form: Y = A + BX
Example 1:
21
SSE 2393 Numerical Methods
Instructions: Answer all questions. Use 4 decimal places for all calculation
Tutorial 3
Estimate the value of f 1.55 and f 1.85 by using the most suitable Newton
interpolation’s formula.
2. Given f x 1 x sin x
Get the straight line by the least square method. Then find the
approximation of y38 .
b) Fit a parabola by the least squares method to the points (0,0),
(1,1), (3,3) and (4,2). Find the value of total error squares, S for this fit.
If VT a b , a, b constants, then
determine the value of a and b by the least squares method.
i 1
5· a) 0 '81 Sl>
Go. V\ £1 0+ .
~. ~) D·~~I
,. 10 ) i) o· CJ~O 2
7· f C4 · Z)-= lo4'4-S'1)V'
to .
b) A:;.. '2. .DO l -; I IS ~ o· 9111
~O.s) -;;<. 3'~o .