INTERPOLATION
Introduction
- The process of estimating intermediate values between given data points is called Interpolation .
- The most common method used for this purpose is Polynomial Interpolation.

Find the functional value for π₯ = 2.5 , i.e. π 2.5 = ? Is this a problem of Interpolation or extrapolation??
π₯ | 1 | 3 | 4 | 6 | 9 |
π(π₯) | 4 | 16 | 43 | 67 | 23 |
Solution:
Step 1: Obtain the polynomial equation using tabular data points.
Suppose we got our polynomial as,
π π₯ = 4π₯
4 + 3π₯
2 + 2
Step 2 : Now, put π₯ = 2.5 in the above expression of π π₯ which gives the desired answer
Note: The number of data points minus one defines the order of interpolation. If n number of data points are given, the order of the polynomial will be n-1.
Linear Interpolation
- Connecting two data points with a straight line.
- Suppose we are given two data points (π₯1, π π₯1 ) and (π₯2, π π₯2 ) .
- We are going to derive the formula which helps to calculate π π₯ for the given π₯ where π₯1 β€ π₯ β€ π₯2 .

Let us find the equation of straight line from the given two points (π₯1, π π₯1 ) and (π₯2, π π₯2 ) .

Demerits of Linear Interpolation
- Linear Interpolation uses first order polynomial (i.e. straight line) to approximate the function.
- To reduce this error, we need to use higher order polynomial.

Lagrange Interpolation Polynomial
- Let π₯0, π0 , π₯1, π1 , and π₯2, π2 are the given data points.
x | π₯0 | π₯1 | π₯2 |
f | π0 | π1 | π2 |
Here, number of data points = 3 , so the polynomial will be of the order 2.
- Let us consider a second order polynomial of the form π2 π₯ = π1 π₯ β π₯0 π₯ β π₯1 + π2 π₯ β π₯1 π₯ β π₯2 + π3 π₯ β π₯2 π₯ β π₯0 β¦β¦β¦β¦β¦β¦..[1] where π1, π2 πππ π3 πππ π‘βπ ππππππππππ‘π ππ ππππ¦ππππππ.
- Given points π₯0, π0 , π₯1, π1 , and π₯2, π2 should satisfy the equation 1.
- At π₯ = π₯π, π2 π₯0 = ππ,

Similarly, for π₯ = π₯1, π2 π₯1 = π1 Β


Example 2.1
For the following data ,use Lagrange interpolation polynomial to find π¦ ππ‘ π₯ = 3.2.
x | 1 | 2 | 4 | 5 |
y | 4 | 9 | 61 | 120 |
Solution: Here, π₯0 = 1, π₯1 = 2, π₯2 = 4, π₯3 = 5 , π0 = 4, π1 = 9, π2 = 61, π3 = 120
Now,

Newton Interpolation Polynomial
- The Newton form of polynomial is ππ (π) = ππ+ πππ β ππ + ππ π β ππ π β ππ + ππ π β ππ π β ππ π β ππβ¦ β¦ β¦ β¦ β¦ . . +ππ π β ππ π β ππ β¦ . . (π β ππβπ)
- For given π₯0, π0 , π₯1, π1 , π₯2, π2 β¦ β¦ β¦ (π₯π, ππ), we need to find the value of coefficients π0, π1, π2, π3 β¦ β¦ β¦ . . ππ.
β If only two data points π₯0, π0 , π₯1, π1 are given, ππ π = ππ+ ππ π β ππ β πππ πππ
ππ ππππππππππ β If three data points π₯0, π0 , π₯1, π1 , π₯2, π2 are given ππ π = ππ + ππ π β ππ + ππ π β ππ π β ππ β πππ πππ ππ ππππππππππ β Similarly, for four data points π₯0, π0 , π₯1, π1 , π₯2, π2 π₯3, π3 , ππ π = ππ + ππ π β ππ + ππ π β ππ π β ππ + ππ(π β ππ)(π β ππ)(π β ππ) β πππ πππ ππ ππππππππππ |
- For π₯ = π₯0, ππ (π₯0 )= π0 , we will get π0 = π0 . π0 = π0
- For π₯ = π₯1, ππ (π₯1 ) = π1
or, π1 = π0 + π1 π₯1 β π₯0
or, π1 = π0 + π1 π₯1 β π₯0 [since π0 = π0]

π2 = π0 + π1 π₯2 β π₯0 + π2(π₯2 β π₯0)(π₯2 β π₯1) which gives

Newton Divide Difference Table
The alternative way of finding the coefficients (π0, π1, π2 πππ π π ππ) value is to use Newton divided difference table. For given π₯0, π0 , π₯1, π1 , π₯2, π2 , π₯3, π3 πππ (π₯4, π4)

Example 2.2
Find the functional value for π₯ = 7 using Newton interpolation polynomial.
x | 5 | 6 | 9 | 11 |
π(π₯) | 12 | 13 | 14 | 16 |
Solution: Since 4 data points are given, the required polynomial will be of the order 3.
ππ (π) = ππ + ππ π β ππ + ππ π β ππ π β ππ + ππ π β πππ β ππ π β ππ
To get the value of π0, π1, π2, π3 πππ π4 , we are going to use Newton divided difference table.


Newton Forward Difference /Newton Backward Difference [Interpolation with equidistant points]
- Particularly used when the functional values are given at a sequence of equally spaced points.
- Also called as Newton Gregory technique.
Scenario 1:
x | 5 | 6 | 9 | 11 |
π(π₯) | 12 | 13 | 14 | 16 |
π»πππ, π₯1 β π₯0 = 6 β 5 = 1 π€βπππππ , π₯2 β π₯1 = 9 β 6 = 3 Not equally spaced. We canβt use Newton Forward/Backward Difference. Rather, we need to rely on Lagrange or Newton Interpolation polynomial.
Scenario 2:
x | 10 | 20 | 30 | 40 | 50 |
π(π₯) | 0 | 7 | 26 | 63 | 124 |
Here, π values are equally spaced. In this case we can use Newton forward difference or Newton backward difference.
π π‘ππ π ππ§π β = 10
- If required point is close to the start of the table, use Newton forward difference. π΄π‘ π₯ = 15, π (π₯) = ? ππ π΄π‘ π₯ = 25, π π₯ = ? [ First value of π (π’. π. π₯0) acts as a reference point ]
- If required point is close to the end of the table , use Newton backward difference. π΄π‘ π₯ = 48, π π₯ =? ππ π΄π‘ π₯ = 35, π₯ = ? [ Last value of π (π’. π. π₯π) acts as a reference point ]
- Simple difference is used here rather than divided difference which was used in Newton divided difference table. π1 β π0 = 1π π‘ πππππ π πππππ ππππππππππ

Newton Forward Difference
Let us create a forward difference table for given π₯0, π0 , π₯1, π1 , π₯2, π2 , π₯3, π3 πππ (π₯4, π4)

Then, the Newton forward difference formula is given by,

Example 2.3:
Estimate the value of π πππ ππ‘ π = 250 using Newton-Gregory forward difference formula.
π | 10 | 20 | 30 | 40 | 50 |
sin(π) | 0.1736 | 0.3420 | 0.5000 | 0.6428 | 0.7660 |
Solution: Let us draw a Newton forward difference table to find the value of coefficients

ππ = π. ππππ , βππ = π. ππππ, β πππ = βπ. ππππ , β πππ = βπ. ππππ, β πππ = π. πππ4
Newton forward difference formula is given by,

= 0.422665625
Newton Backward Difference
Let us create a forward difference table for given π₯0, π0 , π₯1, π1 , π₯2, π2 , π₯3, π3 πππ (π₯4, π4)

Then, the Newton backward difference formula is given by,

Example 2.4
Estimate the value of π πππ ππ‘ π = 45 0using Newton-Gregory backward difference formula.
π | 10 | 20 | 30 | 40 | 50 |
sin(π) | 0.1736 | 0.3420 | 0.5000 | 0.6428 | 0.7660 |
Solution: Let us draw a Newton backward difference table to find the value of coefficients

From table, π4 = 0. 7660, π»π4 = 0.1232, π» 2 π4 = β0. 0196, π» 3 π4 = β0.0044, πππ π» 4 π4 = 0.0004
Newton backward difference formula is given by

= 0.707509
NUMERICAL DIFFERENTIATION
Numerical Differentiation
- Numerical differentiation is the process of computing the value of the derivative of an explicitly unknown function, with given discrete set of points(π₯π , ππ) .
- To differentiate a function numerically, we first determine an interpolating polynomial and then compute the approximate derivative at the given point.
- If π₯π βs are equispaced use Newton’s forward/backward interpolation formula to find the derivative.
- If π₯π βs are not equispaced, we may find using Newtonβs divided difference method or Lagrangeβs interpolation formula and then differentiate it as many times as required.
Problem Scenario: The following table gives the displacement, x (cm) of an object at various of time ,t(seconds). Find the velocity and acceleration of the object at t=1.2 sec. Use suitable interpolation method. t 1.0 1.2 1.4 1.6 1.8 x 9.0 9.5 10.2 11.0 13.2 |
Numerical Derivatives using Newton Forward Interpolation
Newton forward interpolation formula is given by,

Numerical Derivatives using Newton Backward Interpolation
For given π₯0, π0 , π₯1, π1 , π₯2, π2 , π₯3, π3 πππ (π₯4, π4) , Newton backward interpolation formula is given by

Example 2.5

x | 0 | 1 | 2 | 3 |
y | 5 | 6 | 3 | 8 |
Solution:
Newton difference table,

Formula for Newton forward interpolation is given by,


Example 2.6 Following table gives the census population of a state for the 1961 to 2001.
Year | 1961 | 1971 | 1981 | 1991 | 2001 |
Population(million) | 19.96 | 36.65 | 58.81 | 77.21 | 94.61 |
Find the rate of growth of the population in the year 2001.
Solution: since given table is equi-spaced (h=10) and rate of growth is asked for 2001, we have to
use Newton backward interpolation.

π4 = 94.61, β π4 = 17.40, β 2 π4 = β1, β 3 π4 = 2.76, β 4 π4 = 11.99
Newton Backward Interpolation formula is give by,

Example 2.7 Compute f β(3.5) and f ββ(4) given that f(0)=2, f(1)=3, f(2)=12, and f(5)=147
Solution:
x | 0 | 1 | 2 | 5 |
y | 2 | 3 | 12 | 147 |
Since π₯π β²s values are not equally spaced, we have to use either Lagrange or Newton divided difference formula.
Let us draw Newton divide difference table,

From table, π0 = 2, π1 = 1, π2 = 4, π3 = 1
Newton interpolation formula is given by,
π( π₯) = π3( π₯ )= π0 + π1 π₯ β π₯0 + π2 π₯ β π₯0 π₯ β π₯1 + π3(π₯ β π₯0)(π₯ β π₯1)(π₯ β π₯2)
Substituting the value of coefficients,
π( π₯) = 2 + 1 π₯ β 0 + 4 π₯ β 0 π₯ β 1 + 1(π₯ β 0)(π₯ β 1)(π₯ β 2)
Β π (π₯) = π₯ 3 + π₯ 2 β π₯ + 2

REGRESSION

Regression : Introduction
β’Interpolation: If we’re provided with various scattered data points then we try to find a curve
such that all the data points will exactly pass through it.(Perfect match)
β’Regression: Here we try to fit a specific form of curve to the given data points. So, it may be
possible that all the points might not pass through the curve.(Generalizes the data)

Linear Regression
Fitting straight line to the given data points.

For given data points we need only one straight line (linear) which best fits the data.
The general form of equation:
π = π + ππ
Value of coefficients a, b will be calculated with the help of given data points.
Linear Regression : Best Fitting Techniques


πππππ = π‘ππ’π π£πππ’π β π£πππ’π πππ‘πππππ ππππ πππ‘π‘ππ πππ’ππ‘πππ
π0 = π¦0 β (π + ππ₯0)
π1 = π¦1 β (π + ππ₯1)
π2 = π¦2 β (π + ππ₯2)
π3 = π¦3 β (π + ππ₯3) π¦ = π + ππ₯
Β In General, ππ = π¦π β π + ππ₯π = π¦π β π β ππ₯i
Least Square Regression
I. Fitting Linear Equation of the form π = π + πx
Error for each data point can be expressed as ,
ππ = π¦π β π + ππ₯π = π¦π β π β ππ₯π
In least squared approach, we use sum of square of errors, i.e
Total Error π = π1 2 + π2 2 + π3 2 + π4 2 + β¦ β¦ β¦ . . +ππ 2


We have to choose π πππ π such that total error π is minimum. Since π depends on π πππ π , a necessary
condition for π to be minimum is,



Example 2.8 Fit a straight line for the following data
x | 1 | 2 | 3 | 4 | 5 |
y | 3 | 4 | 5 | 6 | 8 |
Solution:

We have to fit straight line of the form
π¦ = π + ππ₯
Normal equations for the above equation is,

n = 5 (number of data points given in table)
Now,
26 = 5π + 15π
90 = 15π + 55π
Upon solving these two equations, we get
π = 1.60, π = 1.20
Hence, the required straight line is, π¦ = π + ππ₯ = π. π + π. πx
Example 2.9: If P is pull required to lift a load W by means of a pulley, find a linear law of the form π =
ππ + π using the following data. Also, find the value of P for W =30.
P 12 15 21 25
W 50 70 100 120
Hint: In π = ππ + π, π πππ π are the coefficients whose value is to be determined with the help of given
data.



II. Fitting Power Equation of the form π = ππ π
The power equation π¦ = ππ π₯ is non linear in the form. First of all, we need to represent it into linear form.
π¦ = ππ₯ π
Taking ππ on both sides,
ln π¦ = ln(ππ₯ π )
ln π¦ = ln π + π ln(π₯)
Β Let us suppose, π = ln π¦ , π΄ = ln π΄ , π = ln π₯ . We get, π = π΄ + π π (Linear Form )





References :
- Balagurusamy, E. Numerical Methods. New Delhi: Tata McGraw-Hill Publishing Company Limited, 2008.
- Sastry, S.S. Introductory Methods of Numerical Analysis. New Delhi: PHI Learning Pvt. Ltd., 2012.
- Steven C. Chopra, Raymond P. Canale. Numerical Methods for Engineers. Newyork: MCGraw Hill Education,
2015.