Beruflich Dokumente
Kultur Dokumente
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
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
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
Lagrange polynomials
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
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
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
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.
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
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
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
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
18
f(x)
P1(x)
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 )
21
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 )
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).
24
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)
26
f(x)=1/x f(x)=(0.05x-0.425)x+1.15
f(x)
P2(x)
1 1.5 2 2.5 3 3.5 4 4.5 5
x
5.5
27
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 )
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 )
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
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
31
Example 3
given
32
solutions
Notice that:
33
P2 ( x) = y0 L0 ( x) + y1 L1 ( x) + y2 L2 ( x)
1st need to find L0(x):
34
35
36
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
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)
38
Example 4
given
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):
41
42
43
P2 ( x ) = 0.198 ( x + 0.25)( x )
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)
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
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
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.
49