math 375 numerical analysisbanach.millersville.edu/~bob/math375/neville/main.pdf · neville’s...
TRANSCRIPT
Neville’s MethodMATH 375 Numerical Analysis
J. Robert Buchanan
Department of Mathematics
Spring 2019
Motivation
I We have learned how to approximate a function usingLagrange polynomials and how to estimate the error insuch an approximation.
I Today we will learn how to interpolate between data valuesfound in a table without knowing the function thatgenerated the values.
I We will see that we can perform the interpolation withoutexplicitly writing out the interpolating polynomial.
Interpolation from Data
Suppose we had only the following table of data for f (x):
x f (x)10.1 0.1753722.2 0.3778432.0 0.5299241.6 0.6639350.5 0.63608
Approximate f (27.5) using polynomial interpolation.
Linear approximation:
P1(27.5) =(27.5− 32.0)(22.2− 32.0)
f (22.2)+(27.5− 22.2)(32.0− 22.2)
f (32.0) ≈ 0.46009
Interpolation from Data
Suppose we had only the following table of data for f (x):
x f (x)10.1 0.1753722.2 0.3778432.0 0.5299241.6 0.6639350.5 0.63608
Approximate f (27.5) using polynomial interpolation.Linear approximation:
P1(27.5) =(27.5− 32.0)(22.2− 32.0)
f (22.2)+(27.5− 22.2)(32.0− 22.2)
f (32.0) ≈ 0.46009
Higher Order ApproximationsQuadratic approximation: (two choices)
P2(27.5) =(27.5− 22.2)(27.5− 32.0)(10.1− 22.2)(10.1− 32.0)
f (10.1)
+(27.5− 10.1)(27.5− 32.0)(22.2− 10.1)(22.2− 32.0)
f (22.2)
+(27.5− 10.1)(27.5− 22.2)(32.0− 10.1)(32.0− 22.2)
f (32.0) ≈ 0.46141
P̂2(27.5) =(27.5− 32.0)(27.5− 41.6)(22.2− 32.0)(22.2− 41.6)
f (22.2)
+(27.5− 22.2)(27.5− 41.6)(32.0− 22.2)(32.0− 41.6)
f (32.0)
+(27.5− 22.2)(27.5− 32.0)(41.6− 22.2)(41.6− 32.0)
f (41.6) ≈ 0.46200
There are also two potential cubic interpolating polynomialsand a single quartic polynomial.
Remarks
I Without knowing f (x) we have no idea of the size of theerrors in these approximations.
I The highest degree polynomial does not necessarilydeliver the smallest error.
I Knowing the Lagrange Interpolating Polynomial of degreek does not help us find the one of degree k + 1.
I There is a method for using previous calculations to derivehigher order interpolations.
Remarks
I Without knowing f (x) we have no idea of the size of theerrors in these approximations.
I The highest degree polynomial does not necessarilydeliver the smallest error.
I Knowing the Lagrange Interpolating Polynomial of degreek does not help us find the one of degree k + 1.
I There is a method for using previous calculations to derivehigher order interpolations.
Lagrange Polynomials
DefinitionIf f is a function defined at x0, x1, . . . , xn distinct real numbersand m1, m2, . . . , mk are k distinct integers with 0 ≤ mi ≤ n,then the Lagrange polynomial that agrees with f at the k pointsxm1 , xm2 , . . . , xmk is denoted Pm1,m2,··· ,mk .
Example (1 of 2)
Let x0 = 1, x1 = 2, x2 = 4, x3 = 5, and x4 = 7 and f (x) = J0(x)(Bessel function of the first kind of order zero).
Determine P1,3,4(x).
P1,3,4(x) =(x − 5)(x − 7)(2− 5)(2− 7)
J0(2) +(x − 2)(x − 7)(5− 2)(5− 7)
J0(5)
+(x − 2)(x − 5)(7− 2)(7− 5)
J0(7)
=
[1
15x2 − 4
5x +
73
]J0(2) +
[−1
6x2 +
32
x +73
]J0(5)
+
[1
10x2 − 7
10x + 1
]J0(7)
Example (1 of 2)
Let x0 = 1, x1 = 2, x2 = 4, x3 = 5, and x4 = 7 and f (x) = J0(x)(Bessel function of the first kind of order zero).
Determine P1,3,4(x).
P1,3,4(x) =(x − 5)(x − 7)(2− 5)(2− 7)
J0(2) +(x − 2)(x − 7)(5− 2)(5− 7)
J0(5)
+(x − 2)(x − 5)(7− 2)(7− 5)
J0(7)
=
[1
15x2 − 4
5x +
73
]J0(2) +
[−1
6x2 +
32
x +73
]J0(5)
+
[1
10x2 − 7
10x + 1
]J0(7)
Example (2 of 2)
Let x0 = 1, x1 = 2, x2 = 4, x3 = 5, and x4 = 7 and f (x) = J0(x).
Use P1,3,4(3) to approximate J0(3).
P1,3,4(x) =(x − 5)(x − 7)(2− 5)(2− 7)
J0(2) +(x − 2)(x − 7)(5− 2)(5− 7)
J0(5)
+(x − 2)(x − 5)(7− 2)(7− 5)
J0(7)
P1,3,4(3) =815
J0(2) +23
J0(5)−15
J0(7)
≈ −0.0590053
Actual value: J0(3) ≈ −0.260052
Example (2 of 2)
Let x0 = 1, x1 = 2, x2 = 4, x3 = 5, and x4 = 7 and f (x) = J0(x).
Use P1,3,4(3) to approximate J0(3).
P1,3,4(x) =(x − 5)(x − 7)(2− 5)(2− 7)
J0(2) +(x − 2)(x − 7)(5− 2)(5− 7)
J0(5)
+(x − 2)(x − 5)(7− 2)(7− 5)
J0(7)
P1,3,4(3) =815
J0(2) +23
J0(5)−15
J0(7)
≈ −0.0590053
Actual value: J0(3) ≈ −0.260052
Example (2 of 2)
Let x0 = 1, x1 = 2, x2 = 4, x3 = 5, and x4 = 7 and f (x) = J0(x).
Use P1,3,4(3) to approximate J0(3).
P1,3,4(x) =(x − 5)(x − 7)(2− 5)(2− 7)
J0(2) +(x − 2)(x − 7)(5− 2)(5− 7)
J0(5)
+(x − 2)(x − 5)(7− 2)(7− 5)
J0(7)
P1,3,4(3) =815
J0(2) +23
J0(5)−15
J0(7)
≈ −0.0590053
Actual value: J0(3) ≈ −0.260052
Theoretical Result
TheoremLet f be defined at x0, x1, . . . , xk and xi and xj be two distinctreal numbers in this set. Then the kth degree Lagrangepolynomial that interpolates f at x0, x1, . . . , xk is
P(x) =(x − xj)
(xi − xj)P0,1,...,j−1,j+1,...,k (x)−
(x − xi)
(xi − xj)P0,1,...,i−1,i+1,...,k (x).
This theorem allows us to build a Lagrange polynomial ofdegree k from two Lagrange polynomials each of degree k −1.
Theoretical Result
TheoremLet f be defined at x0, x1, . . . , xk and xi and xj be two distinctreal numbers in this set. Then the kth degree Lagrangepolynomial that interpolates f at x0, x1, . . . , xk is
P(x) =(x − xj)
(xi − xj)P0,1,...,j−1,j+1,...,k (x)−
(x − xi)
(xi − xj)P0,1,...,i−1,i+1,...,k (x).
This theorem allows us to build a Lagrange polynomial ofdegree k from two Lagrange polynomials each of degree k −1.
ProofLet Q(x) = P0,1,...,j−1,j+1,...,k (x) and Q̂(x) = P0,1,...,i−1,i+1,...,k (x),then
P(x) =(x − xj)Q(x)− (x − xi)Q̂(x)
(xi − xj).
If x = xi , then P(xi) = Q(xi) = f (xi). If x = xj , thenP(xj) = Q̂(xj) = f (xj). If l ∈ {0,1, . . . , k} with i 6= l 6= j then
P(xl) =(xl − xj)Q(xl)− (xl − xi)Q̂(xl)
(xi − xj)
=(xl − xj)f (xl)− (xl − xi)f (xl)
(xi − xj)= f (xl).
Thus P(x) is a polynomial of degree at most k whichinterpolates f (x) at xi for i = 0,1, . . . , k and thus
P(x) = P0,1,...,k (x).
ProofLet Q(x) = P0,1,...,j−1,j+1,...,k (x) and Q̂(x) = P0,1,...,i−1,i+1,...,k (x),then
P(x) =(x − xj)Q(x)− (x − xi)Q̂(x)
(xi − xj).
If x = xi , then P(xi) = Q(xi) = f (xi). If x = xj , thenP(xj) = Q̂(xj) = f (xj). If l ∈ {0,1, . . . , k} with i 6= l 6= j then
P(xl) =(xl − xj)Q(xl)− (xl − xi)Q̂(xl)
(xi − xj)
=(xl − xj)f (xl)− (xl − xi)f (xl)
(xi − xj)= f (xl).
Thus P(x) is a polynomial of degree at most k whichinterpolates f (x) at xi for i = 0,1, . . . , k and thus
P(x) = P0,1,...,k (x).
ProofLet Q(x) = P0,1,...,j−1,j+1,...,k (x) and Q̂(x) = P0,1,...,i−1,i+1,...,k (x),then
P(x) =(x − xj)Q(x)− (x − xi)Q̂(x)
(xi − xj).
If x = xi , then P(xi) = Q(xi) = f (xi). If x = xj , thenP(xj) = Q̂(xj) = f (xj). If l ∈ {0,1, . . . , k} with i 6= l 6= j then
P(xl) =(xl − xj)Q(xl)− (xl − xi)Q̂(xl)
(xi − xj)
=(xl − xj)f (xl)− (xl − xi)f (xl)
(xi − xj)= f (xl).
Thus P(x) is a polynomial of degree at most k whichinterpolates f (x) at xi for i = 0,1, . . . , k and thus
P(x) = P0,1,...,k (x).
Recursive Generation of Polynomials
P0,1(x) =1
x1 − x0[(x − x0)P1 − (x − x1)P0]
P1,2(x) =1
x2 − x1[(x − x1)P2 − (x − x2)P1]
P0,1,2(x) =1
x2 − x0
[(x − x0)P1,2 − (x − x2)P0,1
]...
Neville’s Method
Define polynomial Qi,j(x) = Pi−j,i−j+1,...,i(x) where 0 ≤ j ≤ i .I j represents the degree of the polynomial.I i determines the consecutive values of x used.I Qi,j(x) can be found recursively.
Qi,j(x) =(x − xi−j)Qi,j−1(x)− (x − xi)Qi−1,j−1(x)
xi − xi−j
Tabular Calculation
Given x0, x1, . . . , xn and f (x0), f (x1), . . . f (xn) we can arrangethe Lagrange interpolating polynomials in the following table.
x0 f (x0) = P0 = Q0,0x1 f (x1) = P1 = Q1,0 P0,1 = Q1,1x2 f (x2) = P2 = Q2,0 P1,2 = Q2,1 P0,1,2 = Q2,2...
......
...xn f (xn) = Pn = Qn,0 Pn−1,n = Qn,1 Pn−2,n−1,n = Qn,2 · · · P0,1,...,n = Qn,n
Example
Approximate f (27.5) from the following data.
xi f (xi)
10.1 0.1753722.2 0.3778432.0 0.5299241.6 0.6639350.5 0.63608
Example
Order points by increasing distance from x = 27.5.
xi Qi,032.0 0.5299222.2 0.3778441.6 0.6639310.1 0.1753750.5 0.63608
Example
xi Qi,0 Qi,132.0 0.5299222.2 0.37784 0.46009†
41.6 0.66393 0.45600‡
10.1 0.17537 0.44524∗
50.5 0.63608 0.37380∗∗
†0.46009 =(27.5− 32.0)(0.37784)− (27.5− 22.2)(0.52992)
22.2− 32.0‡0.45600 =
(27.5− 22.2)(0.66393)− (27.5− 41.6)(0.37784)41.6− 22.2
∗0.44524 =(27.5− 41.6)(0.17537)− (27.5− 10.1)(0.66393)
10.1− 41.6∗∗0.37380 =
(27.5− 10.1)(0.63608)− (27.5− 50.5)(0.17537)50.5− 10.1
Example
xi Qi,0 Qi,1 Qi,232.0 0.5299222.2 0.37784 0.4600941.6 0.66393 0.45600 0.46200†
10.1 0.17537 0.44524 0.46071‡
50.5 0.63608 0.37380 0.55843∗
†0.46200 =(27.5− 32.0)(0.45600)− (27.5− 41.6)(0.46009)
41.6− 32.0‡0.46071 =
(27.5− 22.2)(0.44524)− (27.5− 10.1)(0.45600)10.1− 22.2
∗0.55843 =(27.5− 41.6)(0.37380)− (27.5− 50.5)(0.44524)
50.5− 41.6
Example
xi Qi,0 Qi,1 Qi,2 Qi,332.0 0.5299222.2 0.37784 0.4600941.6 0.66393 0.45600 0.4620010.1 0.17537 0.44524 0.46071 0.46174†
50.5 0.63608 0.37380 0.55843 0.47901‡
†0.46174 =(27.5− 32.0)(0.46071)− (27.5− 10.1)(0.46200)
10.1− 32.0‡0.47901 =
(27.5− 22.2)(0.55843)− (27.5− 50.5)(0.46071)50.5− 22.2
Example
xi Qi,0 Qi,1 Qi,2 Qi,3 Qi,432.0 0.5299222.2 0.37784 0.4600941.6 0.66393 0.45600 0.4620010.1 0.17537 0.44524 0.46071 0.4617450.5 0.63608 0.37380 0.55843 0.47901 0.45754†
†0.45754 =(27.5− 32.0)(0.47901)− (27.5− 50.5)(0.46174)
50.5− 32.0
Neville’s Iterated Interpolation Algorithm
Goal: evaluate the interpolating polynomial P on n + 1 distinctnumbers x0, . . . , xn at x to approximate f (x).
INPUT values x , x0, . . . , xn, f (x0), . . . , f (xn)
STEP 1 For i = 0,1, . . . ,n set Qi,0 = f (xi).STEP 2 For i = 1,2, . . . ,n
for j = 1,2, . . . , iset Qi,j =
1xi − xj
[(x − xi−j)Qi,j−1 − (x − xi)Qi−1,j−1
].
STEP 3 OUTPUT Q. STOP.
Example (1 of 2)
Use Neville’s Iterated Interpolation to obtain the approximationsfor Lagrange interpolating polynomials of degrees one, two, andthree for f (0).
xi f (xi)
−0.50 1.93750−0.25 1.332030.25 0.800780.50 0.68750
Example (2 of 2)
Qi,j(0) =(0− xi−j)Qi,j−1(0)− (0− xi)Qi−1,j−1(0)
xi − xi−j
i xi Qi,0 Qi,1 Qi,2 Qi,30 −0.50 1.937501 −0.25 1.33203
0.72656
2 0.25 0.80078
1.06641 0.95312
3 0.50 0.68750
0.91406 1.01562 0.98437
Example (2 of 2)
Qi,j(0) =(0− xi−j)Qi,j−1(0)− (0− xi)Qi−1,j−1(0)
xi − xi−j
i xi Qi,0 Qi,1 Qi,2 Qi,30 −0.50 1.937501 −0.25 1.33203 0.726562 0.25 0.80078
1.06641 0.95312
3 0.50 0.68750
0.91406 1.01562 0.98437
Q1,1 =(0− x0)Q1,0 − (0− x1)Q0,0
x1 − x0
=(0.50)(1.33203) + (−0.25)(1.93750)
−0.25− (−0.50)= 0.72656
Example (2 of 2)
Qi,j(0) =(0− xi−j)Qi,j−1(0)− (0− xi)Qi−1,j−1(0)
xi − xi−j
i xi Qi,0 Qi,1 Qi,2 Qi,30 −0.50 1.937501 −0.25 1.33203 0.726562 0.25 0.80078 1.06641
0.95312
3 0.50 0.68750
0.91406 1.01562 0.98437
Q2,1 =(0− x1)Q2,0 − (0− x2)Q1,0
x2 − x1
=(0.25)(0.80078) + (0.25)(1.33203)
0.25− (−0.25)= 1.06641
Example (2 of 2)
Qi,j(0) =(0− xi−j)Qi,j−1(0)− (0− xi)Qi−1,j−1(0)
xi − xi−j
i xi Qi,0 Qi,1 Qi,2 Qi,30 −0.50 1.937501 −0.25 1.33203 0.726562 0.25 0.80078 1.06641
0.95312
3 0.50 0.68750 0.91406
1.01562 0.98437
Q3,1 =(0− x2)Q3,0 − (0− x3)Q2,0
x3 − x2
=(−0.25)(0.68750) + (0.50)(0.80078)
0.50− 0.25= 0.91406
Example (2 of 2)
Qi,j(0) =(0− xi−j)Qi,j−1(0)− (0− xi)Qi−1,j−1(0)
xi − xi−j
i xi Qi,0 Qi,1 Qi,2 Qi,30 −0.50 1.937501 −0.25 1.33203 0.726562 0.25 0.80078 1.06641 0.953123 0.50 0.68750 0.91406
1.01562 0.98437
Q2,2 =(0− x0)Q2,1 − (0− x2)Q1,1
x2 − x0
=(0.50)(1.06641) + (0.25)(0.72656)
0.25− (−0.50)= 0.95312
Example (2 of 2)
Qi,j(0) =(0− xi−j)Qi,j−1(0)− (0− xi)Qi−1,j−1(0)
xi − xi−j
i xi Qi,0 Qi,1 Qi,2 Qi,30 −0.50 1.937501 −0.25 1.33203 0.726562 0.25 0.80078 1.06641 0.953123 0.50 0.68750 0.91406 1.01562
0.98437
Q3,2 =(0− x1)Q3,1 − (0− x3)Q2,1
x3 − x1
=(0.25)(0.91406) + (0.50)(1.06641)
0.50− (−0.25)= 1.01562
Example (2 of 2)
Qi,j(0) =(0− xi−j)Qi,j−1(0)− (0− xi)Qi−1,j−1(0)
xi − xi−j
i xi Qi,0 Qi,1 Qi,2 Qi,30 −0.50 1.937501 −0.25 1.33203 0.726562 0.25 0.80078 1.06641 0.953123 0.50 0.68750 0.91406 1.01562 0.98437
Q3,3 =(0− x0)Q3,2 − (0− x3)Q2,2
x3 − x0
=(0.50)(1.01562) + (0.50)(0.95312)
0.50− (−0.50)= 0.98437
Homework
I Read Section 3.2.I Exercises: 1a, 3, 5, 7