Chapter Four
Chapter Four
1
4.2 Finite Differences
2
3
Example:-
4
Example:-
5
Divided Differences
6
Table of Divided Differences
Example:- Construct the divided difference table for the following Data
7
4.3 Interpolation for Equally Spaced Data
8
Example
9
Exercises ( From Lecture)
Determine the value of sin 38 0 ( Hint:- Construct the difference table and Newton’s Backward
difference interpolation formula) Ans. 0.6156614
Write a Mathlab program for Newton’s forward difference formula and Newton’s backward
difference formula and solve the above problems using it.
10
4.4 Interpolation with Unequally Spaced data
4.4.1 Lagrange interpolation
11
Example:-
12
Example
13
Exercise
14
N N
ei ( yi c0 c1 xi c2 xi . . . cn xi ) 2 where N 1 n
i 1
2
i 1
2 n
From Calculus of functions of several variables, S will be minimum when its partial
derivatives with respect to the C’s are equal to zero, that is
S N
2( y i c0 c1 xi c 2 xi ...)(1) 0
2
c0 i 1
S N
2( y i c0 c1 xi c 2 xi ...)( xi ) 0
2
c1 i 1
S N
2( y i c0 c1 xi c 2 xi ...)( xi ) 0
2 2
c 2 i 1
S N
2( y i c0 c1 xi c 2 xi ...)( xi ) 0
2 n
c n i 1
i 1 i 1 i 1 i 1
N N N N
c0 xi c1 xi . . . cn xi xi yi
2 3 n2 2
i 1 i 1 i 1 i 1 (*)
N N N N
c0 xi c1 xi . . . cn xi xi yi
n n 1 nn n
i 1 i 1 i 1 i 1
The above equation (*) is a system of n+1 linear equations and it is called a normal
equation.
Example :- consider the data (1,2.1), (2,2.9), (5,6.1) and (7,8.3) . Then determine the
linear line which best fit the above data points by using least square method.
Solution.
Here we need to find a function f ( x) c0 c1 x which best fit o the above data points. i.e,
we need to determine c0 and c1 .So let us construct the following table ( here our N=4)
which mean we have 4 sets of data points)
15
2
xi yi xi xi y i
1 2.1 1 2.1
2 2.9 4 5.8
5 6.1 25 30.5
7 8.3 49 58.1
x i 15 y i 19 .4 x i
2
79 x i y i 96 .5
i 1 i 1 i 1
Solving this simultaneous equations we got c0=0.9352 and c1=1.0440. So that the
required line is f ( x) c0 c1 x 1.0440 x 0.9352 .
Fitting a polynomial of degree n, we need to determine c0 , c1 , c2 , ..., cn from the normal
equation. Using Matlab, we can see the line together with the set of data points.
6 y=1.0440x+0.9352
5
y
1
1 2 3 4 5 6 7
x
16