0% found this document useful (0 votes)
28 views25 pages

MATA2754 Interpolation

Uploaded by

Phiwokwakhe Pho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views25 pages

MATA2754 Interpolation

Uploaded by

Phiwokwakhe Pho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Introduction to 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

There is a unique 2nd degree


polynomial that can pass
through the 3 data points. [the
blue parabola]

However, there are infinitely


many polynomials of degree 3
that can pass through these
same 3 data points.
[the pink, red and yellow
curves]
Polynomial Interpolation
Methods
 Lagrange Interpolation Polynomial - A
straightforward, but computational awkward
way to construct an interpolating polynomial.

 Newton Interpolation Polynomial - there is


no difference between the Newton and
Lagrange results. The difference between
the two is the approach to obtaining the
coefficients.
The Interpolation Problem

Given a set of n+1 points:

x0 , f ( x0 ) , x1, f ( x1 ) , ...., xn , f ( xn ) 


Find an nth order polynomial: f n (x)
that passes through all points, such that:

f n ( xi )  f ( xi ) for i  0,1, 2,..., n

8
Lagrange Interpolation
Problem: xi x0 x1 …. xn
Given
yi y0 y1 …. yn

Find the polynomial of least order f n (x) such that:

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

i ( x) are called the cardinals.


The cardinals are n th order polynomials :
0 i  j
i ( x j )  
1 i  j

10
1st Order Lagrangian

f1 (x)  L1 f x1   L2 f x2 


x  x2 x  x1
L1  , L2 
x1  x2 x2  x1
x  x2 x  x1
f1 (x)  f x1   f x2 
x1  x2 x2  x1
Lagrange Interpolation Example

P2 ( x)  f ( x0 )0 ( x)  f ( x1 )1 ( x)  f ( x2 )2 ( x) x 1/3 1/4 1

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) 116( x  1 / 3)( x  1)
 72( x  1 / 3)( x  1 / 4)

12
Example

Find a polynomial to interpolate: x y

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  31  22  53  44

( x  1) ( x  2) ( x  3) ( x  4) ( x  1)( x  2)( x  3)( x  4)


0  
(0  1) (0  2) (0  3) ( 0  4) 24
( x  0) ( x  2) ( x  3) ( x  4) x ( x  2)( x  3)( x  4)
1  
(1  0) (1  2) (1  3) (1  4) 6
( x  0) ( x  1) ( x  3) ( x  4) x ( x  1)( x  3)( x  4)
2  
( 2  0) ( 2  1) ( 2  3) ( 2  4) 4
( x  0) ( x  1) ( x  2) ( x  4) x ( x  1)( x  2)( x  4)
3  
( 3  0) (3  1) (3  2) ( 3  4) 6
( x  0) ( x  1) ( x  2) ( x  3) x ( x  1)( x  2)( x  3)
4  
( 4  0) ( 4  1) ( 4  2) ( 4  3) 24

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

1.5 10 th order interpolating polynomial

0.5

true function

-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5

16
Newton Interpolation

The Newton interpolation uses a divided difference


method. The technique allows one to add
additional points easily.
P x   a0
 a1 x  x1 
 a2 x  x1 x  x2 

Newton Interpolation
For given set of data points: (x1,y1), (x2,y2), & (x3,y3)

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

The method works for quadratic and cubic


polynomials. As you add additional points, the
degree of the polynomial increases. So if you have
n points it will fit a (n-1)th degree polynomial. The
method is set up to show a pattern for combining
values computed in a table and provide for the
addition of new points at the bottom of the table.
Example of Newton
Interpolation

What are the coefficients of the polynomial and


what is the value of P4(2.3)?
X Y
0 1
1 2 The true function of
2 4 the points is f(x) = 2x
3 8
4 16
Example of Newton
Interpolation

X Y d dd ddd dddd
0 1
y 2  y1 2  1
  1
x 2  x1 1  0
d 2  d1 21
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 21

d3  d2 4  2 ddd  ddd 0 . 33  0 . 167


2 4   1 2 1
  0 . 04167
x4  x2 31 x 5  x1 4  0
y4  y3 8  4 dd 3  dd 2 1
  4 2
  0 . 3333
x4  x3 3  2 x5  x2 4 1
d4  d3 8  4
3 8   2
x5  x3 4 2
y 5  y 4 16  8
  8
x5  x4 4  3

4 16
Example of Newton
Interpolation

The coefficients are the top row of the chart:

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  1x  2 
 0.04167 * x  0 x  1x  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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy