01 Interpolation 1
01 Interpolation 1
●
In the mathematical field of numerical
analysis, interpolation is a method of
constructing new data points within the
range of a discrete set of known data points.
●
In engineering and science, one often has
a number of data points, obtained by sampling
or experimentation, which represent
the values of a function for a limited number
of values of the independent variable.
It is often required to interpolate (i.e., estimate) the value of that function for
an intermediate value of the independent variable.
2 / 14
Example
●
Polynomial interpolation – the order of the polynomial depends on the
number of input points (support points). If n is the number of points then the
order polynomial is n-1.
3 / 14
Types of interpolation
●
Linear interpolation (the interpolating function depend linearly on the
parameters ai)
– a) polynomial interpolation
b) trigonometric interpolation
●
Rational interpolation
●
Exponential interpolation
4 / 14
Polynomial interpolation (Vandermonde matrix)
●
Let we denote the polynomial P(x)
●
This allows us to construct a system of n linear
equations with n unknowns
for i = 1:length(xdense)
ydense(i) = myvandermonde( xdense(i), xin, yin);
end
●
Let we denote the polynomial p(x)
●
To find this polynomial we will construct p(x)
explicitly with the help of polynomials Li(x) for
which:
●
The following Lagrange polynomials satisfy this
condition
7 / 14
Example
●
Find Lagrange interpolating polynomial
●
Answer
8 / 14
Example MATLAB code
x = [0 1 2 4]
y = [1 2 2 3]
n = length(x);
end
yd; % just to print the contents of vector yd to
% the screen
plot(x,y, 'or', xd, yd, 'b') % plot x,y with circles,
9 / 14
Newton interpolation
●
Earlier presented Lagrange interpolation has the following limitations:
●
The Newton’s divided-difference (difference quotient) overcomes these
limitations.
●
The Newton’s polynomial is of the following form:
10 / 14
Newton interpolation – difference quotient
●
Let we define a set of difference quotients (divided differences)
●
Now let we construct the table with difference quotients of growing order as
the column index grow
11 / 14
Example
●
Find Newton interpolating polynomial
●
Answer
12 / 14
MATLAB code
function L04_newton function a = newton_coeffs(xp, yp)
xp = [0 1 2 4]; n = length(xp);
yp = [1 2 2 3]; A = zeros(n, n+1);
A(:,1) = xp;
xd = linspace( min(xp), max(xp), 50); A(:,2) = yp;
yd = zeros(length(xd), 1); for c = 3:n+1
for r = c-1:n
A(r,c)=(A(r,c-1)-A(r-1,c-1))/(A(r,1)-A(rc+2,1));
%for i=1:length(xd) end
% x = xd(i); end
% yd(i) = 1 + 1*(x-0) - 1/2*(x-0)*(x-1) + 1/6*(x-0)*(x- a = zeros(n,1);
1)*(x-2);
for i = 1:n
%end
a(i) = A(i, i+1);
a = newton_coeffs(xp, yp);
end
yd = newton_polyval(a, xp, xd);
end
13 / 14
Thank you
Homework
14 / 14