Sie sind auf Seite 1von 49

Interpolation

AH: lagrange polynomial

What is interpolation?
Interpolation is the process of fitting a curve through a given set of data points Interpolation refers to determining a f function ti that th t exactly tl represents t a collection of data

AH: lagrange polynomial

What is Interpolation ?
Given (x0,y0), (x1,y1), (xn,yn), find 1. a curve that passes through all these points 1 2. the value of y at a value of x that is not given in the data set. set

AH: lagrange polynomial

Polynomial interpolations
In this course, we are interested in polynomial interpolations because: Polynomials P l i l are easy t to evaluate, l t differentiate and integrate. The derivatives & the indefinite i t integrals l of f any polynomial l i l are again i polynomials
AH: lagrange polynomial 4

There are many y types yp of polynomial interpolations like


Lagrange interpolation Newtons interpolation p Hermite interpolation We are going to discuss only one of them, namely Lagrange interpolation interpolation.

AH: lagrange polynomial

Lagrange polynomials

AH: lagrange polynomial

Definition of a polynomial
A polynomial is an expression of the form

an x + an 1 x
n

n 1

+ an 2 x

n2

+ ... + a1 x + a0

where the ais s are real numbers numbers, x is a variable variable, and n is a nonnegative integers called the degree of the polynomial. p y

AH: lagrange polynomial

Lagrange interpolation
Suppose the function y = f ( x) is given at the N+1 points:

( x0 , y0 ), ( x1 , y1 ), . . . , ( x N , y N )
where the values of xk (called nodes) are spread out t over the th interval i t l [a, [ b] and d satisfy ti f

a x0 < x1 < x2 < . . . < x N b


and yk = f ( xk ).
AH: lagrange polynomial 8

We shall construct a Lagrange polynomial, denoted by PN(x) of degree N which passes through all these N+1 points. All given values of xk and yk will be used in the construction of PN( (x). ) The derivatives of y = f ( x) are not necessary. The approximation polynomial PN(x) can be used to represent y = f ( x) over the entire interval [a [a, b] b].
AH: lagrange polynomial 9

Existence and uniqueness theorem


If x0 , x1 , . . . , x N are distinct real numbers, b then h f for arbitrary bi values l y0 , y1 , . . . , y N there is a unique q p polynomial y PN( (x) ) of degree at most N such that
PN ( xk ) = yk , 0 k N .

AH: lagrange polynomial

10

Interpolation vs extrapolation
Although there is only one Nth order polynomial that fits N+1 N 1 points, there are a variety of mathematical formats in which y can be expressed. this polynomial When x0 < x < xN , that is the point x where the approximation polynomial is to be constructed is within the interval [a, b], then the process is known as interpolation and the approximation PN(x) is called the i t interpolated l t d values. l
AH: lagrange polynomial 11

Interpolation vs extrapolation
If either x < x0 or x > xN, that is the point at which hich the appro approximation imation is to be constructed is outside the interval [a, b], the process is known as extrapolation and the approximation PN(x) is called the extrapolated values.

AH: lagrange polynomial

12

Consider a line segment which passes through two points (x0, y0) and (x1, y1). ) The gradient of the line that passes through these points is given by
y1 y0 m= x1 x0

Th The equation ti of f the th straight t i ht line li th that t join j i the points is x x0 y = P( x) = y0 + ( y1 y0 ) x1 x0


AH: lagrange polynomial 13

x x0 y = P( x) = y0 + ( y1 y0 ) x1 x0

x x0 x x0 y = y0 1 + y1 x1 x0 x1 x0

x x0 x1 x y = y0 + y1 x1 x0 x1 x0

can be written as

x x0 x x1 P + y1 1 ( x ) = y = y0 x0 x1 x1 x0
Each term on the RHS involves a linear factor. Th f Therefore P1(x) ( ) is i a polynomial l i l of fd degree 1 1.
AH: lagrange polynomial 14

x x0 x x1 P + y1 * 1 ( x ) = y = y0 x0 x1 x1 x0 x x1 L1, 0 ( x) = L0 ( x) = x0 x1
x x0 L1,1 ( x) = L1 ( x) = x1 x0
Verify the following: Next, we define

L1,0 ( x0 ) = L0 ( x0 ) = 1

L1,1 ( x0 ) = L1 ( x0 ) = 0
15

L1,0 ( x1 ) = L0 ( x1 ) = AH: 0 lagrange polynomial L1,1 ( x1 ) = L1 ( x1 ) = 1

Therefore the polynomial

x x0 x x1 P + y1 1 ( x ) = y0 x0 x1 x1 x0
or

( A)

P 1 ( x ) = y0 L1,0 ( x ) + y1 L1,1 ( x ) = y0 L0 ( x ) + y1 L1 ( x )
is the unique linear function that passes through points (x0, y0) and (x1, y1) since

P 1 ( x0 ) = y0 P 1 ( x1 ) = y1
AH: lagrange polynomial 16

The equation

P 1 ( x ) = y0 L1,0 ( x ) + y1 L1,1 ( x ) = y0 L0 ( x ) + y1 L1 ( x )
can be b written itt as

P 1 ( x ) = y k L1, k ( x ) = y k Lk ( x )
k =0 k =0

The above equation is the Lagrange Lagrange Interpolation Polynomial of Degree 1

AH: lagrange polynomial

17

Example 1
Consider the function y = cos x in [0, 1.2]. Use x0 = 0 and x1 = 1.2 to construct Lagrange polynomial of degree 1. To find P1(x). when x0 = 0, y0 = cos0 = 1. when x1 = 1 1.2, 2 y1 = cos1 cos1.2 2 = 0.3624.
AH: lagrange polynomial

Substitute these numbers in (A):

18

x 1.2 x0 P + 0.3624 0 3624 1 ( x) = 1 0 1.2 1.2 0

P 1 ( x ) = 0.8333( x 1.2) + 0.302 x


Now we can use the above equation to approximate IP y(0.8) = 0.57492 IP y(1) = ? EP y(1.7) (1 7) = ?
AH: lagrange polynomial 19

I t Interval: l [0, [0 1.2]. 1 2]

f(x)

P1(x)

AH: lagrange polynomial

20

The concept p of linear interpolation p can be generalized to higher degree polynomials. Now consider the construction of polynomial of degree g at most N that p passes through g the N+1 points

( x 0 , y 0 ), ( x 1 , y 1 ), . . . , ( x N , y N )

AH: lagrange polynomial

21

Lagrange polynomial of degree N


PN ( x) = y0 LN , 0 ( x) + y1 LN ,1 ( x) + . . . + y N LN , N ( x) *

PN ( x) = y0 L0 ( x) + y1 L1 ( x) + . . . + y N LN ( x) * PN ( x) = yk LN ,k ( x)
k =0 N

PN ( x) = yk Lk ( x)
k =0

where

( x x0 )( x x1 ) . . . ( x x N ) Lk = LN ,k ( x) = ( xk x0 )( xk x1 ) . . . ( xk x N )
AH: lagrange polynomial 22

( x x0 )( x x1 ) . . . ( x x N ) Lk = LN ,k ( x) = ( xk x0 )( xk x1 ) . . . ( xk x N )
Lk ( x) = LN ,k ( x) =
j =0 jk N

(x x j ) ( xk x j )

For convenience, we will write LN,k(x) as Lk(x).

AH: lagrange polynomial

23

Example 2
Find Lagrange polynomial of degree 2 for the 1 function f ( x) = .
x

Use nodes x0 = 2, x1 = 2.5 and x2 = 4. 4 Use the polynomial to approximate f(3) f(3).

AH: lagrange polynomial

24

P2 ( x) = y0 L0 ( x) + y1 L1 ( x) + y2 L2 ( x) ( x x1 )( x x2 ) L0 ( x) = = ( x 6.5) x + 10 ( x0 x1 )( x0 x2 ) ( x x0 )( x x2 ) (4 x + 24) x 32 = L1 ( x) = ( x1 x0 )( x1 x2 ) 3 ( x x0 )( x x1 ) ( x 4.5) x + 5 L2 ( x) = = ( x2 x0 )( x2 x1 ) 3


AH: lagrange polynomial 25

y0 = f ( x0 ) = 0.5

y1 = f ( x1 ) = 0.4
y2 = f ( x2 ) = 0.25 P2 ( x) = y0 L0 ( x) + y1 L1 ( x) + y2 L2 ( x)

P2 ( x) = (0.05 x 0.425) x + 1.15


f (3) = P2 (3) = [0.05 0 (3) 0.425 42 ]3 + 1.15 1 = 0.325 32

AH: lagrange polynomial

26

f(x)=1/x f(x)=(0.05x-0.425)x+1.15

I t Interval: l [2, [2 4]. 4]

f(x)

P2(x)
1 1.5 2 2.5 3 3.5 4 4.5 5

x
5.5

AH: lagrange polynomial

27

Lagrange interpolation of degree 3?

P3 ( x) = y0 L0 ( x) + y1 L1 ( x) + y2 L2 ( x) + y3 L3 ( x) ( x x1 )( x x2 )( x x3 ) L0 ( x) = ( x0 x1 )( x0 x2 )( x0 x3 ) ( x x0 )( x x2 )( x x3 ) L1 ( x) = ( x1 x0 )( x1 x2 )( x1 x3 )

AH: lagrange polynomial

28

( x x0 )( x x1 )( x x3 ) L2 ( x) = ( x2 x0 )( x2 x1 )( x2 x3 ) ( x x0 )( x x1 )( x x2 ) L3 ( x) = ( x3 x0 )( x3 x1 )( x3 x2 )

AH: lagrange polynomial

29

Example 1
k xk yk 0 1 1 1 0 1 2 1 1 3 2 5
nodes

Construct the Lagrange interpolation polynomial of degree 3 that agrees with the data set given above. above

P3 ( x) = 1 + x x

AH: lagrange polynomial

30

Exercise 2
Let f(x) = ex. Construct the Lagrange interpolation polynomial l i l of fd degree 4 on th the i interval t l[ [-1, 1 1] b by using the nodes {-1, -, 0, , 1}.
P4 ( x) = 1.0 + 0.9979 x + 0.4996 x 2 + 0.1773 x 3 + 0.0434 x 4

AH: lagrange polynomial

31

Example 3
given

f (8.3) = 17.56492 f (8.6) = 18.50515 f (8.7) = 18.82091

Use Lagrange Polynomial of degree 2 to approximate f(8.4). (8 4)

AH: lagrange polynomial

32

solutions
Notice that:

x0 = 8.3 x1 = 8.6 x2 = 8.7


y0 = 17.56492 y1 = 18.50515 y2 = 18.82091

AH: lagrange polynomial

33

P2 ( x) = y0 L0 ( x) + y1 L1 ( x) + y2 L2 ( x)
1st need to find L0(x):

( x x1 )( x x2 ) L0 ( x) = ( x0 x1 )( x0 x2 ) ( x 8.6)( x 8.7) = (8.3 8.6)(8.3 8.7) = 8.3333( x 8.6)( x 8.7)

AH: lagrange polynomial

34

2nd, find L1(x):

( x x0 )( x x2 ) L1 ( x) = ( x1 x0 )( x1 x2 ) ( x 8.3)( x 8.7) = (8.6 8.3)(8.6 8.7) = 33.3333( x 8.3)( x 8.7)

AH: lagrange polynomial

35

3rd, find L2(x):

( x x0 )( x x1 ) L2 ( x) = ( x2 x0 )( x2 x1 ) ( x 8.3)( x 8.6) = (8.7 8.3)(8.7 8.6) = 25( x 8.3)( x 8.6)

AH: lagrange polynomial

36

Combine them together:

P2 ( x ) = 17 .56492[8.3333 ( x 8.6)( x 8.7 )] + 18 .50515[ 33 .3333 ( x 8.3)( x 8.7 )] + 18 .82091[ 25( x 8.3)( x 8.6)]
After simplify, will get:

P2 ( x ) = 146 .37374 ( x 8.6)( x 8.7 ) 616 .83771( x 8.3)( x 8.7 ) + 470 .52275 ( x 8.3)( x 8.6)
AH: lagrange polynomial 37

Now can use P2(8.4) to approximate f(8.4).

f (8.4) P2 (8.4) = 146 .37374 (8.4 8.6)(8.4 8.7 ) 616 .83771(8.4 8.3)(8.4 8.7 ) + 470 .52275 (8.4 8.3)(8.4 8.6)

f (8.4) P2 (8.4) = 17 .8771


= 17 .877
(correct to 3 decimal places)

AH: lagrange polynomial

38

Example 4
given

f ( 0.5) = 0.0247500 f ( 0.25) = 0.3349375 f (0) = 1.1010000

Use Lagrange Polynomial of degree 2 to approximate f ( 1 ) correct to 4 decimal 3 places.

AH: lagrange polynomial

39

solutions
Notice that:

x0 = 0.5 x1 = 0.25 x2 = 0
y0 = 0.0247500 y1 = 0.3349375 y2 = 1.1010000
AH: lagrange polynomial 40

P2 ( x) = y0 L0 ( x) + y1 L1 ( x) + y2 L2 ( x)
1st need to find L0(x):

( x x1 )( x x2 ) L0 ( x) = ( x0 x1 )( x0 x2 ) ( x + 0.25)( x + 0) = (0.5 + 0.25)(0.5 + 0) = 8( x + 0.25)( x)

AH: lagrange polynomial

41

2nd, find L1(x):

( x x0 )( x x2 ) L1 ( x) = ( x1 x0 )( x1 x2 ) ( x + 0.5)( x + 0) = (0.25 + 0.5)(0.25 + 0) = 16( x + 0.5)( x)

AH: lagrange polynomial

42

3rd, find L2(x):

( x x0 )( x x1 ) L2 ( x) = ( x2 x0 )( x2 x1 ) ( x + 0.5)( x + 0.25 5) = (0 + 0.5)(0 + 0.25) = 8( x + 0.5)( x + 0.25)

AH: lagrange polynomial

43

Combine them together:

P2 ( x ) = 0.0247500 [8( x + 0.25)( x )]

+ 0.3349375 [ 16 ( x + 0.5)( x )] + 1.1010000 [8( x + 0.5)( x + 0.25)]


After simplify, will get:

P2 ( x ) = 0.198 ( x + 0.25)( x )

5.359 ( x + 0.5)( x ) + 8.808 ( x + 0.5)( x + 0.25)


AH: lagrange polynomial 44

Now can use P2(-1/3) to approximate f(-1/3).

P2 ( 1 ( 0.33333 + 0.25)( )( 0.33333) ) 3 ) = 0.198( 5.359( 0.33333 + 0.5)( 0.33333) + 8.808( 8 808( 0 0.33333 33333 + 0 0.5)( 5)( 0 0.33333 33333 + 0 0.25) 25)
= 0.0054997 + 0.2977251 0.1223307 = 0.1698947 0.1699 (correct to 4 decimal places)

AH: lagrange polynomial

45

Exercise 1
Let
f (0.6) = 0.17694460 f (0.7) = 0.01375227 f (0.8) = 0.22363362 f (1.0) = 0.65809197

Use Lagrange Polynomial of 1. degree 1 2. degree 2 3 degree 3 3. to approximate f ( 0.9 ) correct to 4 decimal places.
Ans: 0.4409, 0.4384, 0.4420
AH: lagrange polynomial 46

Exercise 2
Let f

( x ) = ln( x + 1), x 0

= 0, x1 = 0.6, and x 2 = 0.9,

Use Lagrange Polynomial of g 1 1. degree 2. degree 2 to approximate f ( 0.45 ) correct to 4 decimal places. Find the true error. error
Ans: P1(x)=0.7833x, P1(0.45)=0.3525, TE=0.0191 P2(x)=-0.2339x2+0.9237x, P2(0.45)=0.3683, TE=0.0033
AH: lagrange polynomial 47

Exercise 3
The following table lists the population of the United States from 1940 to 1990.
year Population (in thousands) 1940 132 165 132,165 1950 151 326 151,326 1960 179 323 179,323 1970 203 302 203,302 1980 1990

226 542 249,633 226,542 249 633

Find the Lagrange polynomial of degree 5 fitting this data, and use this p polynomial y to estimate the population in the years 1930, 1965 and 2010.
Ans: P(1930)=169,649,000; P(1965)=191,767,000; AH: lagrange polynomial P(2010)=171,351,000.

48

The way I see it. it You may be disappointed if you fail, but you are doomed if you don't try.

AH: lagrange polynomial

49

Das könnte Ihnen auch gefallen