Professional Documents
Culture Documents
Sec 4-1 PDF
Sec 4-1 PDF
x1 = ,
x0 = 0,
4
and
yi = cos xi,
x2 =
2
i = 0, 1, 2
,
1
4 sqrt(2)
, 0
2
i = 0, 1, 2
The graph of this polynomial is shown on the accompanying graph. We later give an explicit formula.
y = cos(x)
y = p (x)
2
/4
/2
PURPOSES OF INTERPOLATION
1. Replace a set of data points {(xi, yi)} with a function given analytically.
Purpose #2 for interpolation is to approximate functions f (x) by simpler functions p(x), perhaps to make
it easier to integrate or dierentiate f (x). That will
be the primary reason for studying interpolation in this
course.
As as example of why this is important, consider the
problem of evaluating
Z 1
dx
0 1 + x10
This is very dicult to do analytically. But we will
look at producing polynomial interpolants of the integrand; and polynomials are easily integrated exactly.
I=
LINEAR INTERPOLATION
The simplest form of interpolation is probably the
straight line, connecting two points by a straight line.
Let two data points (x0, y0) and (x1, y1) be given.
There is a unique straight line passing through these
points. We can write the formula for a straight line
as
P1(x) = a0 + a1x
In fact, there are other more convenient ways to write
it, and we give several of them below.
x x1
x x0
y0 +
y1
x0 x1
x1 x0
(x1 x) y0 + (x x0) y1
=
x1 x0
x x0
= y0 +
[y1 y0]
x x0
1
!
y1 y0
(x x0)
= y0 +
x1 x0
Check each of these by evaluating them at x = x0
and x1 to see if the respective values are y0 and y1.
P1(x) =
x1 = 1.2
y=tan(x)
1
1.3
y = tan(x)
y = p (x)
1
1.1
1.2
QUADRATIC INTERPOLATION
i = 0, 1, 2
for given data points (x0, y0) , (x1, y1) , (x2, y2). One
formula for such a polynomial follows:
P2(x) = y0L0(x) + y1L1(x) + y2L2(x)
()
with
(xx )(xx )
L0(x) = (x x1)(x x2 ) ,
0
1
0
2
(xx )(xx )
L1(x) = (x x0)(x x2 )
1
0
1
2
(xx )(xx )
L2(x) = (x x0)(x x1 )
2
0
2
1
The functions
(xx )(xx )
L0(x) = (x x1)(x x2 ) ,
0
1
0
2
(xx )(xx )
L1(x) = (x x0)(x x2 )
1
0
1
2
(xx )(xx )
L2(x) = (x x0)(x x1 )
2
0
2
1
are called Lagrange basis functions for quadratic interpolation. They have the properties
Li(xj ) =
1, i = j
0, i =
6 j
UNIQUENESS
Can there be another polynomial, call it Q(x), for
which
deg(Q) 2
Q(xi) = yi,
i = 0, 1, 2
Thus, is the Lagrange formula P2(x) unique?
Introduce
R(x) = P2(x) Q(x)
From the properties of P2 and Q, we have deg(R)
2. Moreover,
R(xi) = P2(xi) Q(xi) = yi yi = 0
for all three node points x0, x1, and x2. How many
polynomials R(x) are there of degree at most 2 and
having three distinct zeros? The answer is that only
the zero polynomial satisfies these properties, and therefore
R(x) = 0
Q(x) = P2(x)
for all x
for all x
SPECIAL CASES
Consider the data points
(x0, 1), (x1, 1), (x2, 1)
What is the polynomial P2(x) in this case?
Answer: We must have the polynomial interpolant is
P2(x) 1
for all x
()
In the formula
(x x0) ..(x xk1)(x xk+1).. (x xn)
Lk (x) =
(xk x0) ..(xk xk1)(xk xk+1).. (xk xn)
1, k = i
0, k =
6 i
EXAMPLE
+
x
x
0
f0 1
f [x0, x1]
2
is quite an accurate approximation of the derivative
(see 5.4).
EXAMPLE
x1 + x0
0
f
= sin (1.05) = .86742
2
1 00
1
f (x1) = cos (1.1) = .22680
2
2
EXAMPLE
The following table gives divided dierences for the
data in
1
1.1
1.2
1.3
1.4
x
cos x .54030 .45360 .36236 .26750 .16997
For the column headings, we use
Dk f (xi) = f [xi, ..., xi+k ]
i
0
1
2
3
4
xi
1.0
1.1
1.2
1.3
1.4
f (x0)
f [x0, x1, x2] =
(x0 x1) (x0 x2)
f (x1)
f (x2)
+
+
(x1 x0) (x1 x2) (x2 x0) (x2 x1)
We can show
f [x0, ..., xn] = f [xi0 , ..., xin ]
for any permutation (i0, i1, ..., in) of (0, 1, ..., n).
COINCIDENT NODES
We therefore define
1
f [x0, x0, x0] = f 00(x0)
2
{x1,...,xn}x0
1 (n)
f (x0)
n!
and we define
1 (n)
f [x
, ..., x ] = f (x0)
| 0 {z 0}
n!
n+1 times
1, j = i
0, j =
6 i
i = 0, 1, ..., n
we have
deg(Pn) n
Pn(xi) = yi,
i = 0, 1, , n
xi
1.0
1.1
1.2
1.3
1.4
=
=
=
=
k = 1, 2, 3, 4. Then
.5403 .8670 (x 1)
P1(x) .2270 (x 1) (x 1.1)
P2(x) + .1533 (x 1) (x 1.1) (x 1.2)
P3(x)
+.0125 (x 1) (x 1.1) (x 1.2) (x 1.3)
Using this table and these formulas, we have the following table of interpolants for the value x = 1.05.
The true value is cos(1.05) = .49757105.
n
1
2
3
.49752
.49758
Pn(1.05) .49695
6.20E4 5.00E5 1.00E5
Error
4
.49757
0.0
Let
d1 = f [x0, x1]
d2 = f [x0, x1, x2]
..
dn = f [x0, ..., xn]
Then the formula
Pn(x) = f (x0) + f [x0, x1] (x x0)
+f [x0, x1, x2] (x x0) (x x1)
+f [x0, x1, x2, x3] (x x0) (x x1) (x x2)
+
+f [x0, ..., xn] (x x0) (x xn1)
can be written as