interpolation technique
interpolation technique
The process of finding the value of y corresponding to any value of x=𝑥𝑖 between 𝑥0 and
𝑥𝑛 is called interpolation.
The process of finding the value of y for any value of x that lies outside the interval [𝑥0 , 𝑥𝑛 ] is called
extrapolation.
It is difficult to find out the exact value of the function f(x) for any known value of x when it is given in
tabular form. In such cases we find out a interpolating function say g(x) satisfying the property that
f(𝑥𝑖 )=g(𝑥𝑖 ). It may be noted that g(x) is also known smoothing function. Once the function g(x) is
established, one can find the approximate value of f(x) for any value of x from g(x) to the required
degree of accuracy.
Finite differences
Let y=f(x) be the function with certain values 𝑦0 , 𝑦1 , . . . 𝑦𝑛 corresponding to equally spaced values
𝑥0 , 𝑥0 + ℎ, 𝑥0 + 2ℎ, . . . 𝑥0 + 𝑛ℎ. The value of the independent variable x is usually called the
argument and the corresponding functional value is known as entry.
Argument x 𝑥0 𝑥1 = 𝑥0 + 𝒉 𝑥𝑛 = 𝑥0 + 𝒏𝒉
Entry y=f(x) 𝑦0 = 𝒇(𝑥0 ) 𝑦1 = 𝒇(𝑥0 + 𝒉) 𝑦𝑛 = 𝒇(𝑥0 + 𝒏𝒉)
Finite differences are useful in determining the values of f(x) and its derivatives 𝑓 ′ (𝑥), 𝑓 ′′ (𝑥) for some
intermediate value of argument x. although there are many types of finite differences but we shall
discuss only the following. They are
Forward difference operator of first order is usually denoted by ∆ and is defined as follows
∆𝑦0 = 𝑦1 − 𝑦0
∆𝑦1 = 𝑦2 − 𝑦1
∆𝑦𝑛 = 𝑦𝑛+1 − 𝑦𝑛
∆2 𝑦0 = ∆𝑦1 − ∆𝑦0
∆2 𝑦0 = (𝑦2 − 𝑦1 ) − (𝑦1 − 𝑦0 )
= 𝑦2 − 2𝑦1 + 𝑦0
∆2 𝑦𝑛 = ∆𝑦𝑛+1 − ∆𝑦𝑛
∆2 𝑦0 = ∆∆(𝑦0 )
= ∆(𝑦1 − 𝑦0 )
= ∆𝑦1 − ∆𝑦0
= (𝑦2 − 𝑦1 ) − (𝑦1 − 𝑦0 )
= 𝑦2 − 2𝑦1 + 𝑦0
= 𝑦3 − 3𝑦2 + 3𝑦1 − 𝑦0
The coefficients on RHS are same as those of binomial coefficients. Moreover, the terms appear with
alternating signs. Thus,
Y 7 9 11 15 17
X Y ∆𝒚 ∆2 𝑦 ∆3 𝑦 ∆4 𝑦
0 7
1 9 0
2 2
2 11 2 -6
4 -4
3 15 -2
4 17
This table is known as forward difference table. The following code produces this table.
Backward Difference Operator
Backward difference operator of first order is usually denoted by (Nebla) and is defined as:
∇𝑦1 = 𝑦1 − 𝑦0
∇𝑦2 = 𝑦2 − 𝑦1
∇𝑦𝑛 = 𝑦𝑛 − 𝑦𝑛−1
∇2 𝑦2 = ∇𝑦2 − ∇𝑦1
∇2 𝑦3 = ∇𝑦3 − ∇𝑦2
∇2 𝑦𝑛 = ∇𝑦𝑛 − ∇𝑦𝑛−1
∇2 𝑦0 = ∇∇(𝑦0 )
= ∇(𝑦1 − 𝑦0 )
= ∇𝑦1 − ∇𝑦0
= (𝑦2 − 𝑦1 ) − (𝑦1 − 𝑦0 )
= 𝑦2 − 2𝑦1 + 𝑦0
= 𝑦3 − 3𝑦2 + 3𝑦1 − 𝑦0
An Important Note: if f(x) is a polynomial of degree n then nth finite difference of it is always constant
and the difference higher than n are always zero.
Shift Operator
The effect of E is to shift or increase the functional value of 𝑦𝑟 or (𝑓(𝑥𝑟 ) by one interval to the next
higher value 𝑦𝑟+1 . The higher order operation of may be similarly defined by
∈2 𝑦𝑟 =∈ (∈ 𝑦𝑟 ) =∈ 𝑦𝑟+1 = 𝑦𝑟+2
𝑜𝑟
∈3 𝑦𝑟 = 𝑦𝑟+3
𝑜𝑟
∈𝑛 𝑦𝑟 = 𝑦𝑟+𝑛
This is equivalent to
δ𝑦1 = 𝑦1 − 𝑦0
2
or
δ𝑦 1 = 𝑦𝑟+1 − 𝑦𝑟
𝑟+
2
silimarly,
𝛿 2 𝑦1 = 𝛿(𝛿𝑦1 ) =
The average or mean difference operator is usually denoted by and defined as:
𝜇𝑦𝑟 = 1⁄2 [𝑦 1 +𝑦 1]
𝑟+ 𝑟−
2 2
Or
1 1
𝜇[𝑓(𝑥𝑟 )] = 1⁄2 [𝑓(𝑥𝑟 + ) + 𝑓(𝑥𝑟 − )]
2 2
We may observe that averaging operator 𝜇 denoites the average or mean value at r of two adjacent
1 1
values at 𝑟 + and 𝑟 −
2 2
Interpolation with equally spaced data values
Let y=f(x) be the function with certain values 𝑦0 , 𝑦1 , . . . 𝑦𝑛 corresponding to equally spaced values
𝑥0 , 𝑥0 + ℎ, 𝑥0 + 2ℎ, . . . 𝑥0 + 𝑛ℎ. Where 𝑥𝑛 = 𝑥0 + 𝑛ℎ Now by definition
∆𝑦0 = 𝑦1 − 𝑦0
𝑦1 = 𝑦0 + ∆𝑦0
𝑦1 = (1 + ∆)𝑦0 (𝑎)
∆𝑦1 = 𝑦2 − 𝑦1
𝑦2 = ∆𝑦1 + 𝑦1
= (1 + ∆)𝑦1
= (1 + ∆)(1 + ∆)𝑦0
𝑦2 = (1 + ∆)2 𝑦0
Similarly,
𝑦3 = (1 + ∆)3 𝑦0
And
∆𝑦𝑛−1 = 𝑦𝑛 − 𝑦𝑛−1
𝑦𝑛 = 𝑦𝑛−1 + ∆𝑦𝑛−1
𝑦𝑛 = (1 + ∆)𝑦𝑛−1
𝑦𝑛 = (1 + ∆)𝑛 𝑦0
By binomial theorem,
The following data shows the volume V of gas for various temperature T. estimate v when t=2.5 from
the given data by using newton forward interpolation formula. Also compute the interpolating
polynomial
0 1 2 3 4 5
1 2 5 10 17 26
Solution
𝑡−𝑡0 2.5−2
Here h=1 hence, 𝑛 = ℎ
= 1
= 0.5
T V v v 2 v 3
0 1
1
1 2 2
3 0
2 5 2
5 0
3 10 2
7 0
4 17 2
9
5 26
= 1 + 𝑡 + 𝑡(𝑡 − 1)
= 1 + 𝑡 + 𝑡2 − 𝑡
= 𝑡2 + 1
Newton Backward Interpolation Formula
Let y=f(x) be the function with certain values 𝑦0 , 𝑦1 , . . . 𝑦𝑛 corresponding to equally spaced values
𝑥0 , 𝑥0 + ℎ, 𝑥0 + 2ℎ, . . . 𝑥0 + 𝑛ℎ. Where 𝑥𝑛 = 𝑥0 + 𝑛ℎ Now by definition
∇𝑦1 = 𝑦1 − 𝑦0
𝑦0 = 𝑦1 − ∇𝑦1
𝑦0 = (1 − ∇)𝑦1
𝑦0
𝑦1 =
(1 − ∇)1
𝑦1 = (1 − ∇)−1 𝑦0 (𝑎)
∇𝑦2 = 𝑦2 − 𝑦1
𝑦1 = 𝑦2 − ∇𝑦2
𝑦1 = (1 − ∇)𝑦2
𝑦1
𝑦2 =
(1 − ∇)
= (1 − ∇)−1 𝑦1
= (1 − ∇)−1 (1 − ∇)−1 𝑦0
𝑦2 = (1 − ∇)−2 𝑦0
Similarly,
𝑦𝑛 = (1 − ∇)−𝑛 𝑦0
By binomial theorem,
Example
Using Newton’s Backward Difference Interpolation Formula, compute f(11.8) from the given tabulated
data
X 2 4 6 8 10 12 14
F(x) 23 93 259 569 1071 1813 2843
X F(x) ∇𝑦 ∇2 𝑦 ∇3 𝑦 ∇4 𝑦
2 23
70
4 93 96
166 48
6 259 144 0
310 48
8 569 192 0
502 48
10 1071 240 0
11.8 742 48
X012 1813 288
1030
14 2843
𝑦−𝑦0 11.8−10
Here h=2 hence, 𝑛 = ℎ
= 2
= 0.9
= 𝟏𝟕𝟐𝟔. 𝟔𝟑𝟐
Newton forward and backward interpolation formulae posses the disadvantages that they only are
applicable when the data points are equally spaced. However, in practice, the data values may not be
equally spaced. We therefore develop new interpolation formulae for unequally spaced values of
independent variable.
𝑜𝑟
𝑦0
𝑎0 =
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) . . . (𝑥0 − 𝑥𝑛 )
𝑜𝑟
𝑦1
𝑎1 =
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) . . . (𝑥1 − 𝑥𝑛 )
𝑜𝑟
𝑦𝑛
𝑎𝑛 =
(𝑥𝑛 − 𝑥0 )(𝑥𝑛 − 𝑥1 ) . . . (𝑥𝑛 − 𝑥𝑛−1 )
Example
The following table shows breaking strength (BS) against the force applied (F). Use lagrange’s
interpolation formula to find BS at F=7 from the following data given below
F 1 3 4
BS 4 12 19
Solution
Let F=x and BS=y As we see that there are three points of interpolation, hence Lagrange polynomial of
degree two is employed
2
𝑓(𝑥) = ∑ 𝐿𝑖 𝑦𝑖
𝑖=0
= 𝐿0 𝑦0 + 𝐿1 𝑦1 + 𝐿2 𝑦2
Here
= 2 × 4 − 9 × 12 + 8 × 19
= 8 − 108 + 152
= 52
𝑥 2 − 7𝑥 + 12 𝑥 2 − 5𝑥 + 4 𝑥 2 − 4𝑥 + 3
= 4+ 12 + 19
−2 × −3 2 × −1 3×1
Simplifying, we get
𝑦 = 𝑓(𝑥) = 𝑥 2 + 3
𝑟2 − 𝑟 2 (𝑟 3 − 3𝑟 2 + 2𝑟) 3 (𝑟 4 − 6𝑟 3 + 11𝑟 2 − 6) 4
𝑦(𝑥0 + 𝑟ℎ) = 𝑦0 + 𝑟∆𝑦0 + ∆ 𝑦0 + ∆ 𝑦0 + ∆ 𝑦0 + . . .
2! 3! 4!
2𝑟 − 1 2 3𝑟 2 − 6𝑟 + 2 3 4𝑟 3 − 18𝑟 2 + 22𝑟 4
𝑦 ′ (𝑥0 + 𝑟ℎ)ℎ = ∆𝑦0 + ∆ 𝑦0 + ∆ 𝑦0 + ∆ 𝑦0 + . . .
2 6 24
1 2𝑟 − 1 2 3𝑟 2 − 6𝑟 + 2 3 2𝑟 3 − 9𝑟 2 + 11𝑟 4
𝑦 ′ (𝑥0 + 𝑟ℎ) = [∆𝑦0 + ∆ 𝑦0 + ∆ 𝑦0 + ∆ 𝑦0 + . . .
ℎ 2 6 12
1 6𝑟 − 6 3
𝑦 ′′ (𝑥0 + 𝑟ℎ)ℎ = [0 + ∆2 𝑦0 + ∆ 𝑦0 + . . .]
ℎ 6
1 2
𝑦 ′′ (𝑥0 + 𝑟ℎ) = 𝑦 ′′ (𝑥𝑟 ) = [∆ 𝑦0 + (𝑟 − 1)∆3 𝑦0 + . . .]
ℎ2
Example
The table below shows the tabulated values of an unknown function y=f(x). Using Newton's formula of
numerical differentiation, find the first and second derivatives of f(x) at x=2. also develop these formula
in terms of independent variable x.
X 0 1 2 3 4
Y 1 3 7 13 21
X Y ∆𝑦 ∆2 𝑦 ∆3 𝑦
0 1
3-1=2
1 3 2
7-3=4 0
2 7 2
13-7=6 0
3 13 2
21-13=8
4 21
𝑥𝑟 = 𝑥0 + 𝑟ℎ
𝑥𝑟 − 𝑥0 2 − 1
𝑟= = =1
ℎ 1
1 2𝑟 − 1 2 3𝑟 2 − 6𝑟 + 2 3
𝑦 ′ (𝑥0 + 𝑟ℎ) = [∆𝑦0 + ∆ 𝑦0 + ∆ 𝑦0
ℎ 2 6
1 2(1) − 1 1
𝑦 ′ (0 + 2) = [6 + (2)] = 1 {6 + (2)} = 6 + 1 = 7
1 2 2
1 2
𝑦 ′′ (𝑥0 + 𝑟ℎ) = [∆ 𝑦0 ] = 2
ℎ2
Putting n=p
𝑦(𝑥𝑝 = 𝑥0 + 𝑝ℎ)
𝑝2 + 𝑝 2 (𝑝3 + 3𝑝2 + 2𝑝) 3
= 𝑦0 + 𝑝∇𝑦0 + ∇ 𝑦0 + ∇ 𝑦0
2! 3!
𝑝4 + 6𝑝3 + 11𝑝2 + 6𝑝 4
+ ∇ 𝑦0 . . .
4!
1 2 2 6𝑝 + 6 3
𝑦 ′′ (𝑥0 + 𝑝ℎ)ℎ = { ∇ 𝑦0 + ∇ 𝑦0 + . . . }
ℎ 2! 6
1 2
𝑦 ′′ (𝑥0 + 𝑝ℎ) = {∇ 𝑦0 + (𝑝 + 1)∇3 𝑦0 + . . . }
ℎ2
Example the deflection f(x) measured at various distance x from one end of a cantilever is given in the
following table
X Y ∇𝑦 ∇2 𝑦 ∇3 𝑦 ∇4 𝑦 ∇5 𝑦
0.0 0.000
0.0456
0.2 0.0456 0.0366
0.0822 0.1028
0.4 0.1278 0.1394 -0.4105
0.2216 -0.3077 0.9130
0.6 0.3494 -0.1683 0.5025
0.0533 0.1948
0.8 0.4027 0.0265
0.0798
1.0 0.4825
𝑦(0.8 + 0.25(0.2))
1 2(0.25) + 1 3(0.25)2 + 6(0.25) + 2
= {0.0533 + (−0.1683) + (−0.3077)
0.2 2! 3!
2(0.25)3 + 9(0.25)2 + 11(0.25) + 3
+ (−0.4105) }
12
= 5(−0.370525) = −1.85