



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




















Interpolation
L. Olson
Department of Computer Science
University of Illinois at Urbana-Champaign
October 11, 2006
(^1) Interpolation: Approximating a function f (x) by a polynomial p n(x).
(^2) Differentiation: Approximating the derivative of a function f (x).
(^3) Integration: Approximating an integral
b a f (x) dx
How do we approximate f (x) by g(x)? In what sense?
(^1) Interpolation: g(x) must have the same values of f (x) at set of given
points.
(^2) Least-squares: g(x) must deviate as little as possible from f (x) in the
sense of a 2-norm: minimize
b a |f (t) โ g(t)|
2 dt
(^3) Chebyshev: g(x) must deviate as little as possible from f (x) in the sense
of the โ-norm: minimize maxtโ[a,b] |f (t) โ g(t)|.
Given n + 1 distinct points x 0 ,... , xn, and values y 0 ,... , yn, fina polynomial
p(x) of degree n so that
p(xi) = yi i = 0 ,... , n
A polynomial of degree n has n + 1 degree-of-freedom:
p(x) = a 0 + a 1 + ยท ยท ยท + anx
n
n + 1 constraints determine the polynomial uniquely:
p(xi) = yi, i = 0 ,... , n
1 x 1 x
2 1
... x
n 1 1 x 2 x
2 2
... x
n 2 . . .
1 xn x
2 n...^ x
n n
a 0
a 1
. . .
cn
y 1
y 2
. . .
yn
Is this a โgoodโ system to solve?
from Recktenwald
Consider Gas prices (in cents) for the following years:
x year 1986 1988 1990 1992 1994 1996
y price 133.5 132.2 138.7 141.5 137.6 144.
1 year =[1986 1988 1990 1992 1994 1996 ]โ;
2 price =[133.5 132.2 138.7 141.5 137.6 144.2] โ;
3
4 M = vander (year);
5 a = M\price;
6
7 x= linspace (1986 ,1996 ,200);
8 p= polyval (a,x);
9 plot(year ,price ,โoโ,x,p,โ-โ);
What have we done? Weโve written p(x) as
p(x) =
x โ x 1
x 0 โ x 1
y 0 +
x โ x 0
x 1 โ x 0
y 1
the sum of two linear polynomials
the first is zero at x 1 and 1 at x 0
the second is zero at x 0 and 1 at x 1
these are the two linear Lagrange basis functions:
` 0 (x) =
x โ x 1
x 0 โ x 1
` 1 (x) =
x โ x 0
x 1 โ x 0
Write the Lagrange basis functions for
x 1 3
1 4
y 2 -1 7
Directly
` 0 (x) =
(x โ
1 4 )(x โ 1 )
1 3
1 4
1 3
` 1 (x) =
(x โ
1 3
)(x โ 1 )
1 4
1 3
1 4
` 2 (x) =
(x โ
1 3 )(x โ
1 4
1 3
1 4
Find the equation of the parabola passing through the points (1,6), (-1,0), and
(2,12)
x 0 = 1 , x 1 = โ 1 , x 2 = 2 ; y 0 = 6 , y 1 = 0 , y 2 = 12 ;
` 0 (x) =
(xโx 1 )(xโx 2 ) (x 0 โx 1 )(x 0 โx 2 )
(x+ 1 )(xโ 2 ) ( 2 )(โ 1 )
` 1 (x) =
(xโx 0 )(xโx 2 ) (x 1 โx 0 )(x 1 โx 2 )
(xโ 1 )(xโ 2 ) (โ 2 )(โ 3 )
` 2 (x) =
(xโx 0 )(xโx 1 ) (x 2 โx 0 )(x 2 โx 1 )
(xโ 1 )(x+ 1 ) ( 1 )( 3 )
p 2 (x) = y 0 0 (x) + y 1 1 (x) + y 2 ` 2 (x)
= โ 3 ร (x + 1 )(x โ 2 ) + 0 ร
(x โ 1 )(x โ 2 )
= (x + 1 )[ 4 (x โ 1 ) โ 3 (x โ 2 )]
= (x + 1 )(x + 2 )
Monomials: p(x) = a 0 + a 1 x + ยท ยท ยท + anx n results in poor conditioning
Monomials: but evaluating the Monomial interpolant is cheap (nested
iteration)
Lagrange: p(x) = 0 (x)y 0 + ยท ยท ยท +n(x)yn is very well behaved.
Lagrange: but evaluating the Lagrange interpolant is expensive (each
basis function is of the same order and the interpolant is not easily
reduced to nested form)
Back to the gas price example. Suppose we use a better basis like
(x โ ยฏx)
k
instead of
x
k
For example, ยฏx = average(xi), i = 0 ,... , n.
Newton Polynomials are of the form
pn(x) = a 0 + a 1 (x โ x 0 ) + a 2 (x โ x 0 )(x โ x 1 ) + a 3 (x โ x 0 )(x โ x 1 )(x โ x 2 ) +...
The basis used is thus
function order
1 0
x โ x 0 1
(x โ x 0 )(x โ x 1 ) 2
(x โ x 0 )(x โ x 1 )(x โ x 2 ) 3
More stable that monomials
More computationally efficient (nested iteration) than using Lagrange and
shifted monomials
Or in matrix form:
๏ฃฎ
1 x 1 โ x 0 0
1 x 2 โ x 0 (x 2 โ x 0 )(x 2 โ x 1 )
a 0
a 1
a 2
y 0
y 1
y 2
โ lower triangular
โ only O(n
2 ) operations
Using Forward Substitution to solve this lower triangular system yeilds:
a 0 = y 0 = f (x 0 )
a 1 =
y 1 โ a 0
x 1 โ x 0
f (x 1 ) โ f (x 0 )
x 1 โ x 0
a 2 =
y 2 โ a 0 โ (x 2 โ x 0 )a 1
(x 2 โ x 1 )(x 2 โ x 0 )
f (x 2 ) โ f (x 0 ) โ (x 2 โ x 0 )
f (x 1 )โf (x 0 ) x 1 โx 0
(x 2 โ x 1 )(x 2 โ x 0 )
f (x 1 )โf (x 0 ) x 1 โx 0
f (x 2 )โf (x 1 ) x 2 โx 1
x 2 โ x 0