Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Interpolation &

Extrapolation
• In many engineering practice, data are available at discrete points and
we are required to fit a smooth and continuous function or curve to
this data.
• There are two ways of doing this: by collocation and by use of least
squares
• Collocation: the curve is made to pass through all the data points. This
is used when the data are known to be accurate or when they are
generated by evaluating a complicated function at a discrete set of
points.
• Least-squares: the curve is made to represent the general trend of the
data. This mean the curve does not necessarily pass through all the
data points.
• Interpolation is the process of estimating the value of a function f
corresponding to a particular value of the independent variable x,
when f(x) is described by a set of tabular data.

Collocation-Polynomial Fit
• Consider a polynomial of order n, passing through (n+1) data points
with no restriction on the spacing of data: i.e.
etc.
• Let the polynomial be of the form,
(1)
where x is the independent variable, y is the dependent variable and ,
are the unknown coefficients.
• Now let the data points be given by .
• If the polynomial passes through the point , then Eq. (1) will be
become
(2)
• Eq. (2) represents (n+1) algebraic equations linear in term of the
coefficients . These equations can be written in matrix form as:
(3)
where
This is known as a Vandermonde matrix.
• Since the assumed polynomial Eqn. (1) is applied to every point ,
fitting the polynomial to the data implies solving Eq. (3) for the ,s that
satisfy this equation.

• When the order of the polynomial is high, the number of algebraic


equations that need to be solved is also high, leading to ill-
conditioning of the Vandermonde matrix and round-off error.

• Several approximation methods that do not require the solution of a


set of linear equation exist, and one of these is the Lagrange
Interpolation method.
Lagrange Interpolation Formula
Consider fitting a quadratic function through three data points , with i
=0, 1, 2. Instead of writing the quadratic in the usual manner, i.e.

we express it in a form known as the Lagrange polynomial, in this case,


of order 2, as:
(4)
where as usual , are to be determined by making the function
pass through the three data points.
By setting x equal to , or in Eq. (4), we get
and

which can be solved for the coefficients as:

By substituting for in Eq. (4) gives:

(5)
• In compact form, Eq. (5) can be written as

• In general, for (n+1) data points, , with i =0, 1, 2.. n, an nth-order


Lagrange interpolation polynomial is written as:
(6)
or (7)
where
Consider the following data:
i 0 1 2 3
1 2 4 8
1 3 7 11

Interpolate for y(7).


Solution
Using Eq. (7):
-1.5

0.53571

Note:
• The error in Lagrange interpolation is given by

where is estimated and f are the actual values respectively


• An estimate of the error in Lagrange Interpolation polynomial is given
by
,
where
and
is the (n+1)st derivative.
Some advantages of Lagrange Interpolation
• It is easy to implement and understand
• It does not require solving a system of equations or derivatives
• It can be used for non-equally spaced points

Some disadvantages
• If the number of data points is to be increased or decreased, the
results of the previous calculations cannot be used
• Computation effort required is more for a single interpolation
• Estimation of error is not easy
Newton’s Divided-Difference Interpolation
This procedure overcomes the limitations of the Lagrange interpolating
polynomial listed above.

a) Linear interpolation:
Consider two data points on a f(x) vrs x graph, and

Consider the similar triangles ADE and ABC in the diagram,


𝐵
𝑓 (𝑥 1)
𝐷
𝑓 1 (𝑥)
𝑓 (𝑥 0 ) 𝐸 𝐶
𝐴

𝑥 0 𝑥 𝑥1
Now,

i.e.
Hence,

For and
(finite difference approx. of 1st
derivative)
Quadratic Interpolation
• Consider three data points , and to be fit by a quadratic polynomial of the
from

where denotes the order of the polynomial.


• For

• For

• For
Substituting for and , can be solved for as:

In general the nth-order Newton’s divided-difference interpolating


polynomial is given by:
Exercise
Develop the 3rd order Newton’s divided-difference interpolating
polynomial.
Hence find using
a) ,
b) , ,
c) , , ,
Newton’s Interpolation Polynomials for Uniformly Spaced Data
• If the data are equally spaced along the x-axis, the formula for
Newton’s interpolation can be simplified.
• Let h denote the interval between two consecutive values
j = 1, 2, 3….n
then
In general

This is known as the Newton-Gregory Interpolating method.


Therefore for a second order polynomial, a quadratic, the function:

becomes,

In general,

… (1)
Eq. (1) is known as the Gregory-Newton forward interpolation formula.
There is also the backward interpolation formula which can be written
as

… (2)
The choice of formula depends on the value of x at which the function
value f(x) is to be determined and its closeness to the known data.
1) Forward difference of f at j:

0 -7 4 5 5 3 1
1 -3 9 10 8 4
2 6 19 18 12
3 25 37 30
4 62 67
5 129
2) Backward difference of f at j:

0 -7
1 -3 4
2 6 9 5
3 25 19 10 5
4 62 37 18 8 3
5 129 67 30 12 4 1
Chebyshev Interpolation
• Instead of choosing equi-spaced values on the abscissa of a polynomial
interpolation formula like the Lagrange polynomial, the roots of a known
polynomial are taken as interpolating points. Such a polynomial which is known to
have a better minimization.
• The Chebyshev polynomial are defined by
(1)
• In power series, these polynomials are defined by :

and
In general

with x defined over .


The equivalence between the trigonometric formula and the algebraic
can be derived. For

Now, where ;
so,
• Due to the cosine nature of the function, their values lie within
• The zeros of the function are those values of that make the cosine
zero, i.e.

• For example for n=3


• Although the Chebyshev polynomial are defined for . , other ranges,
[a, b] can be mapped onto this defining range.
• The necessary transformation is given by:
; ,
or
Interpolation Using Splines
• A spline is a piecewise polynomial of low order.
• Instead of using one polynomial to represent the entire data points,
splines are used to link adjacent data points.
a) Step function spline
b) Linear spline
Linear or first-order spline represents a straight line between the data
points (knots). Equation of the straight line joining two neighbouring
data points and is

c) Quadratic spline
The second-order spline represents a quadratic equation between
any two consecutive data points or knots. The equation between two
consecutive points is given by
,

where and are unknown coefficients. Thus for n data points, 3n


constants are needed.
These are determined with the following conditions:
1) The function value at the interior knot, must be equal to
whether it is computed using the quadratic or :

and

If no. of intervals is n, then number of points of knots is n+1, and


number of interior knots is n-1. Example, take 4 knots,

Number of equations = 2(n-1) = 2n-2


2) The first and last functions and must pass through end
points:

and

No. of equations: 2
3) First derivative or slope at each interior knot must be continuous:
=
i.e.
No. of equations: n-1
4) Several options can be used for the last remaining equation. For
example, assume that 2nd derivative (curvature) to be zero at the
final point. i.e.
c) Cubic splines
Here, intervals are fitted with cubic polynomials:

There are 4n coefficients to be determined with 4n conditions.


1) Interior knots must give the same value using adjacent polynomials,
or 2n-2 equations
2) First and last functions nd must pass through and respectively 2
equations
3) First derivative must be continuous at each point (n-1) equations
4) Second derivative at each interior knot must be continuous, i.e. =
(n-1) equations
5) Two final conditions again present a number of options. Assume 2nd
derivative (curvature) to be zero at the endpoints

• To avoid having to solve 4n equations, a simpler procedure is


adopted.
• The first-order Lagrange Interpolation formula is used for two
consecutive second derivatives and :
Lagrange formula
(A)
• The approach is to integrate Eq. (A) twice and eliminating the
constant of integration using the condition that and must be equal
at and respectively.
• If in addition we impose the condition that the first derivative is
continuous at interior knots,
i=1, 2, …n-1
we are able to evaluate the unknown second derivatives appearing in
Eq. (A) to get

(B)
Giving n+1 unknown derivatives at n+1 points. Eq. (B) gives n-1
conditions and so two more are needed. Several options exists. The
most common is
natural cubic spine

You might also like