Lec 4 Interpolation
Lec 4 Interpolation
Interpolation
Given the set of tabular values (x 0, y0), (x1, y1), (x2, y2),... ... ... (xn, yn), satisfying the
relation y = f(x) where the explicit nature of f(x) is not known, it is requested to find a
simpler function say φ(x), such that f(x) and φ(x) agree at the set of tabulated points.
Such a process is called interpolation.
If φ(x) is a polynomial, then the process is called polynomial interpolation and φ(x) is
called the interpolating polynomial.
Similarly, different types of interpolation arise depending on whether φ(x) is a finite
trigonometric series, series of Bessel functions, etc.
Application of interpolation:
1. Analyzing experimental data
2. Plotting smooth curves to represent experimental data
3. Derive many different formulas
The justification for replacing a given function by a polynomial or by a trigonometric
series relies on two theorems proved by Weierstrass (1885).
1. If f(x) is continuous in an interval (a, b) (i.e. a ≤ x ≤ n), then given any ε > 0,
there exits a polynomial p(x) such that
| f(x) – p(x) | < ε for all x in (a, b)
2. Every continuous function of period 2л can be represented by a finite
trigonometric series of the form g(x) = a0 + a1 sin x + a2 sin 2x + ... ... ... … +
an sin nx + b1 cos x + b2 cos 2x +... ... ... bn cos nx
where, | f(x) – g(x) | < δ for all values of x in the interval considered and δ
represents any pre assigned positive quantity.
This means that it is possible to find a polynomial p(x) whose graph remain within
the regain bounded by y = f(x) + ε and y = f(x) - ε for all x between a and b, however
small ε may be.
y = f(x)+ ε
y=f(x)
y = f(x) - ε y=p(x)
x=a x=b
Page 1 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
Finites Differences
Assume that we have a table of values (x i, yi), i = 0, 1, 2, …, n of any function y = f(x),
the values of x being equally spaced, i.e. xi = x0 + ih, i = 0,1,2, ...,n. Suppose that we are
required to recover the values of f(x) for some intermediate values of x, or to obtain the
derivative of f(x) for some x in the range x 0 ≤ x ≤ xn. The methods for solution of these
problems are based on the concept of the differences of a function which is discussed
below.
Forward Differences
If y0, y1, y2, ... ..., yn denote a set of values of y, then y 1 - y0, y2 - y1, ... ... ... , yn - yn-1 are
called the differences of y. Denoting these differences by Δy 0, Δy1, Δy2,... ... ... , Δyn-1
respectively, we have,
Δy0 = y1 – y0, Δy1 = y2 – y1, .... ...., Δyn-1 = yn – yn-1
General form: Δyi = yi+1 – yi, where i = 0, 1, 2, 3, ….., n-1
where Δ is called the forward difference operator and Δy0, Δy1, Δy2, ..., Δyn-1 are called
first forward differences.
The difference of the first forward differences are called second forward differences and
denoted by Δ2y0, Δ2y1, Δ2y2, ... .… Similarly, one can define third forward differences,
fourth forward differences, etc.
Δ2y0 = Δy1 – Δy0 = (y2 – y1) – (y1 – y0) = y2 - 2y1 + y0
Δ3y0 = Δ2y1 – Δ2y0 = (y3 – 2y2 + y1) - (y2 - 2y1 + y0) = y3 - 3y2 + 3y1 - y0
Any higher order difference can easily be expressed in terms of the ordinates, since
the coefficients occurring on the right side are the binomial coefficients.
Δr yi = Δr-1 yi+1 - Δr-1 yi
n
Δny0 = ∑ (-1)k ck yn-k
Δ y0 = yn – nc1 k=0
n
yn-1 + nc2 yn-2 - nc3 yn-3 ... ...+ (-1)n yo
Forward Difference Table
The following table shows how the forward differences of all orders can be formed:
x y Δ Δ2 Δ3 Δ4
x0 y0
Δy0
x1 y1
Δ2y0
Δy1 Δ3y0
x2 y2
Δ2y1 Δ4y0
Δy2 Δ3y1
x3 y3
Δ2y2
Δy3
x4 y4
The above table is called a diagonal difference table. The first term in the table is y0. It is
called the leading term. The difference Δy0, Δ2y0, Δ3y0... are called the leading
differences.
There is another type of difference table called horizontal difference table.
Example:
Page 2 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
A convenient check may be obtained by noting the sum of the entries in any column
x y Δ Δ2 Δ3 Δ4
0 7
2
1 9 32
34 60
2 43 92 24
126 84
3 169 176
302
4 471
equals the differences between the first and last entries in preceding column.
Properties of the operator Δ
1. If c is a constant then Δc = 0.
2. Δ is distributive i.e. Δ [f(x) + g(x)] = Δf(x) + Δg(x)
3. If c is a constant then Δ[c f(x)] = c Δf(x)
4. If m and n are positive integers then Δm Δn f(x) = Δm+n f(x)
5. Δ [f1(x) + f2(x) + …. + fn(x)] = Δ f1(x) + Δ f2(x) + …. + Δ fn(x)
6. Δ [f(x) g(x)] = f(x) Δ g(x) + g(x) Δ f(x)
Theorem: The nth differences of a polynomial of the n th degree are constant when the
value of independent variables are at equal intervals.
Proof: Page-51 [G. Shanker Rao]
The converse of the above theorem is true i.e. if the nth differences of a tabulated
function are constant and the values of the independent variable are equally spaced
then the function is a polynomial of degree n.
Example 4: Page 52 [G. Shanker Rao]
Backward differences
The differences y1 – y0, y2 – y1 ...., yn – yn-1 are called first backward differences if they
are denoted by y1, y2, ... ... , yn respectively, so that y1 = y1–y0, y2 = y2 – y1, ... ...,
yn = yn – yn-1, where is called the backward difference operator.
The difference of the first backward differences are called second backward differences
and denoted by 2y0, 2y1, 2y2, ... .… Similarly, one can define third backward
differences, fourth backward differences, etc.
Page 3 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
δy7/2
x4 y4
The Averaging Operator (μ)
The averaging operator μ is defined as
μyi = ½(yi+1/2 + yi - 1/2)
Shift Operator (E)
The shift operator (also called displacement operator) E is defined by the equation
Eyi = yi+1 or E f(x) = f(x+h)
which shows that the effect of E is to shift the functional value yi to the next higher value yi+1.
E2yi = E(Eyi)
Eyi+1 = yi+2
So,
Enyi = yi+n
Eny0 = yn
Page 4 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
En f(x) = f(x+nh)
E-n f(x) = f(x-nh)
D Operator
The D operator is defined as
Dy(x) = d/dx y(x)
Df(x) = d/dx f(x) = f′(x)
D2f(x) = d2/dx2 f(x) = f″(x)
Page 5 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
9. - δ2
10. E1/2 + ½δ
11. (1+ )(1-) 1
12. E-1
13. δ E-1/2
Page 6 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
Page 7 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
∴ a2 = -----------------
2! h2
Similarly,
3 yn 4yn nyn
a3 = -----------------, a4 = -----------------, …., an = -----------------
3! h3 4! h4 n! hn
putting the values of a0,a1, ... ...an we get
f(x) ≈ φ(x) = yn + (yn/h)(x-xn) + (2yn / (2! h2)) (x-xn)(x-xn-1) + ... ...
... ... + (nyn/ (n! hn)) (x-xn)(x-xn-1) ... ... (x-x1)
writing u = ((x-xn)/h), we get
x-xn = uh
x-xn-1 = (x-xn) + (xn- xn-1) = (u + 1)h
Similarly, x-xn-2 = (u+2)h
x-xn-3 = (u+3)h
.... ... ... ... ...
x-x1 = (u + n -1)h
f(x) ≈ φ(x) = yn + u (yn /1!) + u (u+1) ( 2yn) / 2! + ... ...
Page 8 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
This process of finding the value of y for some value of x outside the given range is
called extrapolation and this example demonstrates the fact that if a tabulated function
is a polynomial then interpolation and extrapolation would give exact values.
If a tabulated function is other then a polynomial, then extrapolation very far from the
table limits would be dangerous - although interpolation can be carried out very
accurately. Example 3.8: Page-63 [S. S. Sastry]
Example 3.5: Page-63 [G. Shanker Rao]
Page 9 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
Page 10 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
xy ΔyΔ2yΔ3yΔ4yΔ5yΔ6yx-3x0-3hy-3Δy-3x-2x0-2hy-2Δ2y-3Δy-2Δ3y-3x-1x0-hy-1Δ2y-2Δ4y-3Δy-
1Δ y-2Δ y-3x0x0y0Δ y-1Δ y-2Δ y-3Δy0Δ y-1Δ y-2x+1x0+hy+1Δ y0Δ y-
3 5 2 4 6 3 5 2 4
Stirlings’s Formula
Taking the mean of the two Gauss’s formula (forward and backward), we obtain
u(Δy0+Δy-1) u2Δ2y-1 u(u2-1) Δ3y-1 + Δ3y-2 u2(u2-1) Δ4y-2
y = y0 + ----------------- + ------------ + ---------- . ----------------- + --------------------- + ... ... ...
2 2 3! 2 4!
u(u-1) u(u-1)(u-2)
y = y1 + (u-1)Δy0 + ------------ Δ2y0 + -------------- Δ3y-1+ ... ... ...
2! 3!
Taking the mean of the above formula and the Gauss’s forward interpolation formula, we obtain,
Gauss’s forward formula is used to interpolate the values of the function for the value
of u such that 0 < u < 1, and Gauss’s backward formula is used to for a negative
values of u which lies between –1 and 0 i.e. –1 < u < 0. Stirling’s formula gives the
most accurate result for –0.25 ≤ u ≤ 0.25. Bessel’s formula is most efficient for ¼ ≤ u
≤¾.
Page 11 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
Page 12 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
Divided Difference
The first divided difference of f(x) between x0 and x1 is denoted by f[x0,x1] and is defined as
f(x0) - f(x1)
f[x0,x1] = ---------------
x0 - x1
and similarly,
f(x1) - f(x2)
f[x1,x2] = --------------- etc.
x1 - x2
The second order divided difference between x0, x1 and x2
f[x0,x1] - f[x1,x2]
f[x0,x1,x2] = --------------------
x0 - x2
th
The (k+1) divided difference
f[x0,x1... ... xk] - f[x1,x2... ... xk+1]
f[x0,x1,... ...xk+1] = ------------------------------------------
x0 – xk+1
Divided Difference Table: Page-98 [G. Shanker Rao].
Example 2: Page-99 [G. Shanker Rao].
Properties of Divided differences
1. Divided differences are symmetric function of their arguments.
f(x0) - f(x1) f(x1) - f(x0)
f[x0,x1] = --------------- = -------------------- = f[x1,x0]
x0-x1 x1-x0
2. The divided difference of the product of a constant and a function is equal to the
product of the constant and the divided difference of the function i.e.
k f[x0,x1] = f k[x1,x0] where k is a constant.
3. The divided difference of the sum (or difference) of two functions is equal to the sum
(or difference) of the corresponding separate divided differences.
If f(x) = g(x) + h(x) then, f[x0,x1] = g[x0,x1] + h[x0,x1]
4. The nth order divided differences of a polynomial of nth degree are constants.
5. The (n+1)th order divided differences of a polynomial of nth degree will be zero.
Newton’s General Divided Difference Formula
Let y = f(x) be a function which assumes the values f(x0), f(x1), f(x2), …., f(xn)
corresponding to the values x = x 0, x1, x2, …, xn where the values of x are not necessarily
equispaced. From the definition of divided difference
f(x) - f(x0)
f[x,x0] = ----------------
x - x0
f(x) = f(x0) + (x-x0) f[x,x0] .... .... (1)
Again,
f[x,x0] - f[x0,x1]
f[x,x0,x1] = --------------------
x - x1
Page 13 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
We have f[x0] = 150, f[x0, x1] = 121, f[x0, x1, x2] = 24, f[x0, x1, x2, x3] = 1
f(6) = 150 + (6 - 5) (121) + (6 - 5) (6 - 7) (24) + (6 - 5) (6 - 7) (6 – 11) (1) + 0 + …
= 150 + 121 –24 + 5
= 252
Example 4: Page-104 [G. Shanker Rao].
Page 14 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
Page 15 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
Inverse Interpolation
Given a set of values of x and y for y = f(x), the process of finding the value of x for a
certain value of y is called inverse interpolation.
Lagrange’s Inverse Interpolation:
We know, the Lagrange interpolation formula is
(x-x1) (x-x2) ... ... (x-xn) (x-x0) (x-x2) ... ... (x-xn)
y = f(x) = -------------------------------- f(x0) + ------------------------------------ f(x1)
(x0-x1) (x0-x2) ... ... (x0-xn) (x1-x0) (x1-x2) ... ... (x1-xn)
Page 16 of 17
MSA / L-4 CSE-4745 - Numerical Methods February 1, 2021
If un denotes the interpolated value of u, then x = x0 + unh gives the required value of x
for a given value of y.
Similarly, we use same technique with Newton’s backward interpolation formula and
Central difference interpolation formula and interpolate x for a given y.
Example: Tabulate y = x3 for x = 2, 3, 4 and 5 and calculate the cube root of 10 correct to
3 decimal places.
Solution:
x y Δ Δ2 Δ3
2 8
19
3 27 18
37 6
4 64 24
61
5 125
Page 17 of 17