Vous êtes sur la page 1sur 10

INTERPOLATION

Interpolation
Lecture’s Goals
1. Interpolation methods:
– Lagrange’s Interpolation
– Newton’s Interpolation
– Hermite’s Interpolation
– Rational Function Interpolation
– Spline (Linear,Quadratic, & Cubic)

2. Interpolation of 2-D data


Interpolation Methods
Why would we be interested in interpolation methods?

 Interpolation method are the basis for other procedures that we


will deal with:
 Numerical differentiation
 Numerical integration
 Solution of ODE (ordinary differential equations) and PDE
(partial differential equations)

 These methods demonstrate some important theory about


polynomials and the accuracy of numerical methods.
 The interpolation of polynomials serve as an excellent
introduction to some techniques for drawing smooth curves.

Interpolation uses the data to approximate a function, which will fit


all of the data points. All of the data is used to approximate the
values of the function inside the bounds of the data.

We will look at polynomial and rational function interpolation of the


data and piece-wise interpolation of the data.

1
INTERPOLATION
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.

 Lagrange Interpolation
This method is generally the easiest to work. The data does not
have to be equally spaced and is useful for finding the points
between quadratic and cubic methods. However, it does not
provide an accurate model for large sets of terms.

P  x   L1  x  y1  L2  x  y 2  

The function can be defined as:

Pn1x   L1 x  y1  L2 x  y2    Ln x  yn

where:

Lk  x  
x  x1 x  x2  x  xn1 x  xn 
xk  x1 xk  x2  xk  xn1 xk  xn 

2
INTERPOLATION
The function can be defined as:

Pn1  x   C1  x  x2  x  x3   x  xn 
 C2  x  x1  x  x3   x  xn 

 Cn  x  x1  x  x2   x  xn1 

where, the coefficients are defined as:

Ck  x  
yk
xk  x1 xk  x2  xk  xk 1 xk  xk 1  xk  xn1 xk  xn 
The method works for quadratic and cubic polynomials. As you
add additional points in the degree of the polynomial increases.
So if you have n points it will fit a (n-1)th degree polynomial.

Example of Lagrange Interpolation:

What are the coefficients of the polynomial and what is the value of
P2(2.3)?

x y
1.1 10.6
1.7 15.2
3 20.3

3
INTERPOLATION
y1 10.6
C1    9.298
x1  x2 x1  x3  1.1  1.7 1.1  3.0
15.2
C2   19.4872
1.7  1.11.7  3.0
20.3
C3   8.2186
3.0  1.13.0  1.7 
The values are evaluated

P(x) = 9.2983*(x-1.7)(x-3.0) - 19.4872*(x-1.1)(x-3.0) +


8.2186*(x-1.1)(x-1.7)

P(2.3) = 9.2983*(2.3-1.7)(2.3-3.0) - 19.4872*(2.3-1.1)(2.3-3.0) +


8.2186*(2.3-1.1)(2.3-1.7) = 18.3813

Lagrange Interpolation

25

20
y values

15

10

0
1 1.5 2 2.5 3
x values

4
INTERPOLATION
What happens if we increase the number of data points?

x y Ci
1.1 10.6 28.1765
1.7 15.2 129.9145
3 20.3 6.4208
1.4 13.4 -116.3194
2.2 18.7 -53.125

Coefficient for 2 is:


y2
C2 
x2  x1 x2  x3 x2  x4 x2  x5 

Lagrange Interpolation

25

20
Y Values

15

10

0
1 1.5 2 2.5 3
X Values

Note: that the coefficient creates a P4(x) polynomial and


comparison between the two curves. The original value P2(x) is
given. The problem with adding additional points will create
“bulges” in the graph.

5
INTERPOLATION
Lagrange Interpolation Program
The Lagrange interpolation is broken up into two programs to
evaluate the new polynomial.

• C = Lagrange_coef(x,y), which evaluates the coefficients of the


Lagrange technique
• P(x) = Lagrange_eval(t,x,c), which uses the coefficients and x
values to evaluate the polynomial
• Plottest(x,y),which will plot the Lagrange polynomial

 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 


For given set of data points: (x1,y1), (x2,y2), & (x3,y3)

d 0  y1
y2  y1
d1 
x2  x1 
 y3  y2    y2  y1 
x  x  x2  x1   d 2  d1
dd1  3 2
x3  x1  x3  x1 
The function can be defined as:

6
INTERPOLATION

Pn1x   d 0  d1 x  x1 
 dd1x  x1 x  x2   
 ddddn-1x  x1 x  x2  x  xn1 

The method works for quadratic and cubic polynomials. As you


add additional points in the degree of the polynomial increases.
So if you have n points it will fit a (n-1)th degree polynomial. The
method is setup to show the a pattern for combining a table
computation and provide additional points.

Example of Newton Interpolation:

What are the coefficients of the polynomial and what is the value of
P2(2.3)?

X Y
0 1
1 2
2 4
3 8
4 16

The true function of the points is f(x) = 2x

7
INTERPOLATION
X Y d dd ddd dddd
0 1
y2  y1 2  1
 1
x2  x1 1  0
d 2  d1 2  1
1 2   0.5
x3  x1 2  0
dd2  dd1 1  0.5
y3  y2 4  2   0.1667
 2 x4  x1 30
x3  x2 2 1

d3  d 2 4  2 ddd2  ddd1 0.33  0.167


2 4  1   0.04167
x4  x2 3  1 x5  x1 40
y4  y3 8  4 dd3  dd2 2  1
 4   0.3333
x4  x3 3  2 x5  x2 4 1
d 4  d3 8  4
3 8  2
x5  x3 4  2
y5  y4 16  8
 8
x5  x4 43

4 16

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

8
INTERPOLATION

The values are evaluated

P(x) = 1 + (x-0) + 0.5*(x-0)(x-1) 0.1667*(x-0)(x-1)(x-2) + 0.04167*


(x)(x-1)(x-2)(x-3)

P(2.3) = 1 + (2.3) + 0.5*(2.3)(1.3) + 0.1667*(2.3)(1.3)(0.3) + 0.04167*


(2.3)(1.3)(0.3)(-0.7) = 4.9183 (4.9246)

Newton Interpolation

18
16
14
12
Y Values

10
8
6
4
2
0
0 1 2 3 4
X Values

9
INTERPOLATION

Newton Interpolation Program

The Newton interpolation is broken up into two programs to


evaluate the new polynomial.

 C = Newton_coef(x,y), which evaluates the coefficients of the


Newton technique
 P(x) = Newton_eval(t,x,c), which uses the coefficients and x
values to evaluate the polynomial
 Plottest_new(x,y),which will plot the Newton polynomial

10

Vous aimerez peut-être aussi