MATA2754 Interpolation
MATA2754 Interpolation
MATA2754
Interpolation Methods
Why would we be interested in interpolation
methods?
Interpolation methods are the basis for other
procedures:
– Numerical differentiation
– Numerical integration
– Solution of ODE (ordinary differential
equations) and PDE (partial differential
equations)
Model fitting vs. Interpolation
With a model, the modeller accepts some differences
between the model values and the data, as the
assumption is that the model is (at least to some sense)
explaining the underlying relationship between the input
and the output variables.
With only data, and then interpolation, the modeler
needs the curve to match up at all collected data points
in order to have more confidence about predictions in
between data points. No value is put on the curve itself.
In essence, explicative models are theory driven
whereas predictive models are data driven.
Model vs Interpolation
Interpolating polynomials
To interpolate means to estimate the values of data
or a function between two known values.
With polynomial interpolation we have polynomials
passing through each point in a data set in order to
use the polynomial’s formula to calculate unknown
values between known values.
The data set used for the interpolation must be
such that for every value of the independent
variable, there must be a single observation (‘y’-
value).
1 2
4 13
9 7
8
Lagrange Interpolation
Problem: xi x0 x1 …. xn
Given
yi y0 y1 …. yn
f n ( xi ) f ( xi ) for i 0,1,..., n
n
Lagrange Interpolation Formula:
f n ( x) f xi i ( x)
i 0
x x
n
i ( x) x x
j 0, j i
j
i j
9
Lagrange Interpolation
10
1st Order Lagrangian
0 ( x)
x x1 x x2 x 1 / 4 x 1 y 2 -1 7
x0 x1 x0 x2 1 / 3 1 / 4 1 / 3 1
1 ( x)
x x0 x x2 x 1 / 3 x 1
x1 x0 x1 x2 1 / 4 1 / 3 1 / 4 1
2 ( x )
x x0 x x1 x 1 / 3 x 1 / 4
x2 x0 x2 x1 1 1 / 3 1 1 / 4
P2 ( x) 2 18( x 1 / 4)( x 1) 116( x 1 / 3)( x 1)
72( x 1 / 3)( x 1 / 4)
12
Example
0 1
1 3
2 2
3 5
4 4
13
Interpolating Polynomial Using
Lagrange Interpolation Method
f4 ( x)
i 0
f ( xi ) i 0 31 22 53 44
14
Advantages and Disadvantages of
high-order polynomials
Positives
Easy to
differentiate
Easy to
integrate
Negatives
Vertical
asymptotes are
very difficult to
approximate
Higher order
polynomials tend
to oscillate quite
a bit near the
endpoints of the
interval
Can have large
errors
10th Order Polynomial Interpolation
2
0.5
true function
-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
16
Newton Interpolation
d 0 y1
y 2 y1 y3 y 2
d1 , d2
x2 x1 x 3 x 2
y3 y 2 y 2 y1
x3 x2 x2 x1 d 2 d1
dd1
x3 x1 x3 x1
Newton Interpolation
The function can be defined as:
Pn 1 x y1 d1 x x1
dd1 x x1 x x 2 ...
dddd n -1 x x1 x x 2 ...x x n 1
Newton Interpolation
X Y d dd ddd dddd
0 1
y 2 y1 2 1
1
x 2 x1 1 0
d 2 d1 21
1 2 0 .5
x 3 x1 2 0
dd dd 1 0 .5
y3 y2 4 2 2 1
0 . 1667
2 x 4 x1 3 0
x3 x2 21
4 16
Example of Newton
Interpolation
P4 x y1 c1 * x x1 c2 * x x1 x x2
c3 * x x1 x x2 x x3
c4 * x x1 x x2 x x3 x x4
P4 x 1 1* x 0 0.5 * x 0 x 1
0.1667 * x 0 x 1x 2
0.04167 * x 0 x 1x 2 x 3
Example of Newton
Interpolation
The values are
evaluated Newton Interpolation
P(x) = 1 + (x-0)
18
+ 0.5*(x-0)(x-1) 16
14
0.1667*(x-0)(x-1)(x-2) 12
Y Values
10
+ 0.04167*(x)(x-1)(x-2) 8
6
(x-3) 4
P(2.3) = 1 + (2.3) 2
0
+ 0.5*(2.3)(1.3) 0 1 2 3 4
+ 0.1667*(2.3)(1.3)(0.3) X Values
+ 0.04167*(2.3)(1.3)(0.3)(-
Pseudocode