Dse 1 Unit 3
Dse 1 Unit 3
Lagrange’s Interpolation:
Let the function f(x) is approximated by a straight line P1(x) between two points x0
and x1 (i.e. P1(x) ≈ f(x)). Let x be a point in between x0 and x1. Now the equation of
the straight line with two point form can be written as
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 1 of 10
f(x0)(x1 – x) + f(x1)(x – x0)
P1(x) =
(x1 – x0)
f(x0)(x1 – x) f(x1)(x – x0)
P1(x) = +
(x1 – x0) (x1 – x0)
f(x0)(x - x1) f(x1)(x- x0)
P1(x) = +
(x0 – x1) (x1 – x0)
or P1(x) = L0f0 + L1f1
Where L0 = (x - x1) / (x0 - x1), L1 = (x - x0 ) / (x1 - x0), f0 = f(x0), and f1 = f(x1)
So, for n+1 points (x0, y0),..................., (xn, yn), pn(x) can be written as
...
Example-1: Using Lagrange’s interpolation formula find y(10) from the following
table:
x 5 6 9 11
y 12 13 14 16
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 2 of 10
Solution: Here the intervals are unequal. By Lagrange’s interpolation formula we
have
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 3 of 10
So if f(x) is approximated with a linear polynomial then the function value at any
point x can be calculated by using f(x) ≈ P1(x) = f(x0) + (x – x1) f [x0, x1]
where f [x0, x1] is the first divided difference of f relative to x0 and x1.
Similarly if f(x) is a second degree polynomial then the secant slope defined above
is not constant but a linear function of x. Hence we have
f [x1, x2] – f [x0, x1]
x2 – x 0
is independent of x0, x1 and x2. This ratio is defined as second divided difference
of f relative to x0, x1 and x2. The secind divided difference are denoted as
f [x1, x2] – f [x0, x1]
f [x0, x1, x2] =
x2 – x 0
Now again since f [x0, x1,x2] is independent of x0, x1 and x2 we have f [x1, x0, x] = f
[x0, x1, x2]
f [x0, x] – f [x1, x0]
= f [x0, x1, x2]
x - x1
f [x] – f [x0]
= f [x0, x1] + (x – x1) f [x0, x1, x2]
x – x0
f [x] = f [x0] + (x – x0) f [x0, x1] + (x – x0) (x – x1) f [x0, x1, x2]
f(x) ≈ Pn(x) = f [x0] + (x – x0) f [x0, x1] + (x – x0) (x – x1) f [x0, x1, x2]
+ . . . + (x – x0) (x – x1) . . . (x – xn-1) f [x0, x1, . . ., xn]
This formula is called Newton's Divided Difference Formula. Once we have the
divided differences of the function f relative to the set of points then we can use the
above formula to compute f(x) at any non in between the first and last point.
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 4 of 10
Computing divided differences using divided difference table: Let us consider the
points (x1, f1), (x2, f2), (x3, f3) and (x4, f4) where x1, x2, x3 and x4 are not necessarily
equi-distant points then the divided difference table can be written as
xi fi f [xi, xj] f [xi, xj, xk ] f [xi, xj, xk, xl]
x0 f0
f1 - f 0
f [x0,x1] =
x1-x0
f[x1, x2] - f[x0,x1]
x0 f1 f[x0, x1,x2] =
x2 - x0
f2-f1 f[x1, x2,x3]-f[x0,x1,x2]
f[x1,x2] = f[x0,x1,x2,x3] =
x2-x1 x3 - x0
f[x2, x3]-f[x1, x2]
x1 f2 f [x1,x2,x3] =
x3 - x1
f3 - f 2
f[x2, x3] =
x3 - x 2
x2 f3
Example: Compute f(0.3) using Newton's divided difference formula for the following
data.
x 0 1 3 4
f(x) 1 3 49 129
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 5 of 10
Gregory Newton forward differences Interpolation: This interpolation
formula is applicable when the points are equidistance with respect to x-axis
x
i.e xi+1 – xi = h (constant).
(1)
Similarly we can get
(2)
By the definition of second order forward difference ∆2f0, we get
(3)
(4)
For ,
(5)
From Newton’s divided difference we know,
f(x) ≈ Pn(x) = f [x0] + (x - x0) f [x0, x1] + (x - x0) (x - x1) f [x0, x1, x2]
+ . . . + (x - x0) (x - x1) . . . (x - xn-1) f [x0, x1, . . ., xn]
Let x - x0 = rh or r = (x - x0)/h
f(x) ≈ Pn(x) = f [x0] + rh f [x0, x1] + rh(r-1)h f [x0, x1, x2]
+ . . . + rh(r-1)h . . . (r – (n-1))h f [x0, x1, . . ., xn]
f(x) ≈ Pn(x) = f [x0] + rh f [x0, x1] + r(r-1)h2 f [x0, x1, x2]
+ . . . + r(r-1) . . . (r – n+1)hn f [x0, x1, . . ., xn]
f(x) ≈ Pn(x) = f [x0] + rh∆f0/h + r(r-1)h2 ∆2f0/(h22!)
+ . . . + r(r-1) . . . (r – n+1)hn ∆nf0/(hnn!)
r(r-1)∆2f0 r(r-1) . . . (r – n+1)∆nf0
f(x) ≈ Pn(x) = f0 + r∆f0 + +...+
2! n!
OR
n
r
Pn(x) = ∑ (
k
) ∆kf0 where
k=0
Constructing ∆kf0:
Example: If f(x) is known at the following data points, then find f(0.5) using Newton's
forward difference formula.
xi 0 1 2 3
fi 1 7 23 55
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 7 of 10
Solution : The Forward difference table can be constructed as follows:
xi fi ∆fi ∆2fi ∆3fi
0 1
6
1 7 10
16 6
2 23 16
32
3 55
By Newton's forward difference formula
r(r-1) 2 r(r-1)(r-2) 3
f(x) = f0 + r∆f0 + ∆ f0 + ∆ f0
2! 3!
at x = 0.5, r = (x - x0) / h = (0.5 - 0) / 1 = 0.5
0.5(0.5 - 1) x 10 0.5(0.5 - 1)(0.5 - 2) x 6
f(0.5) = 1 + 0.5 x 6 + +
2 6
= 1 + 3 + 2.5 x (-0.5) + 0.5(-0.5)(-1.5)
= 3.125
In this case the reference point is xn and therefore we can derive the Newton-
Gregory backward difference interpolation polynomial as:
Where r = (x – xn)/h
For constructing Pn(x) using the abve formula, it will be easier if we first generate
backward-difference table. The backward difference table for the data (xi, fi), i = 0, 1,
2, 3, 4 is given below:
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 8 of 10
Example: Given the following data estimate f(4.12) using Newton-Gregory
Newton
backward difference interpolation polynomial:
xi 0 1 2 3 4 5
fi 1 2 4 8 16 32
Solution: Here
(1)
=17.39135