



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!




Math 151A Homework #4 – due Wednesday 11/01, in class
Show all your work!
1. Error term for Taylor’s theorem (section 3.1, problem 31) In class we proved Theorem 3.3, which stated the error term for the Lagrange interpolating polynomial. Using the same procedure, prove Taylor’s theorem (Theorem 1.14). You will want to use the function
g ( t ) = f ( t ) − P ( t ) − [ f ( x ) − P ( x )] ·
( t − x 0 ) n +^1 ( x − x 0 ) n +^1
where P ( x ) is the n th Taylor polynomial.
Answer: Let f ∈ Cn [ a , b ], f ( n +^1 )^ exists on [ a , b ] and x 0 ∈ [ a , b ]. Let x be some point in [ a , b ] and
P ( x ) = f ( x 0 ) + f ′( x 0 )( x − x 0 ) + f (^2 )( x 0 ) 2!
( x − x 0 )^2 + · · · + f ( n ) n!
( x − x 0 ) n.
Then
g ( x ) = f ( x ) − P ( x ) − [ f ( x ) − P ( x )] · ( x − x 0 ) n +^1 ( x − x 0 ) n +^1 = f ( x ) − P ( x ) − [ f ( x ) − P ( x )] = 0
and
g ( x 0 ) = f ( x 0 ) − P ( x 0 ) − [ f ( x ) − P ( x )] · ( x 0 − x 0 ) n +^1 ( x − x 0 ) n +^1 = f ( x 0 ) − P ( x 0 ) = 0
because f ( x 0 ) = P ( x 0 ). Moreover, notice that f ( k )( x 0 ) = P ( k )( x 0 ) for all 0 ≤ k ≤ n + 1. Since g is a continuous, differentiable function on [ a , b ] and g is zero at the two points x , x 0 ∈ [ a , b ], then Rolle’s theorem says that a ξ 1 ∈ [ x , x 0 ] exists with g ′(ξ 1 ) = 0. Now we have that g ′(ξ 1 ) = 0 and g ′( x 0 ) = 0, so by Rolle’s theorem, there exists a ξ 2 ∈ [ξ 1 , x 0 ] with g (^2 )(ξ 2 ) = 0. And so on, until g ( n )(ξ n ) = g ( n )( x 0 ) = 0 and Rolle’s theorem tells us that there exists a ξ n + 1 ∈ [ξ n , x 0 ] with g ( n +^1 )(ξ n + 1 ) = 0. Since P is an n -degree polynomial, P ( n +^1 )^ is identically zero. And so
g ( n +^1 )(ξ n + 1 ) = 0 = f ( n +^1 )(ξ n + 1 ) − [ f ( x ) − P ( x )] ·
( n + 1 )! ( x − x 0 ) n +^1
and
f ( x ) = P ( x ) + f ( n +^1 )(ξ n + 1 ) ( n + 1 )! ( x − x 0 ) n +^1
which is what Taylor’s theorem states.
2. Lagrange interpolation (section 3.1, problems 1a & 3) Given the function f ( x ) = cos x , use the points x 0 = 0, x 1 = 0 .6 and x 2 = 0 .9 to do the following:
a. Construct Lagrange polynomials of degree at most one and at most two to approximate f ( x ).
Answer: For a first degree interpolating polynomial we need the first degree Lagrange polynomials. We will use x 0 and x 1 to construct them:
( x − x 1 ) ( x 0 − x 1 )
( x − 0. 6 ) (− 0. 6 )
= − 1. 666667 x + 1
( x − x 0 ) ( x 1 − x 0 )
( x ) ( 0. 6 )
= 1. 666667 x
which yields an interpolating polynomial of
P 1 ( x ) = L 1 , 0 f ( x 0 ) + L 1 , 1 f ( x 1 ) = (− 1. 666667 x + 1 ) cos( 0 ) + ( 1. 666667 x ) cos( 0. 6 ) = − 0. 2911073 x + 1
For second degree, we use the three second degree Lagrange polynomials
( x − x 1 )( x − x 2 ) ( x 0 − x 1 )( x 0 − x 2 )
( x − 0. 6 )( x − 0. 9 ) ( 0 − 0. 6 )( 0 − 0. 9 )
x^2 − 1. 5 x + 0. 54
L 2 , 1 =
( x − x 0 )( x − x 2 ) ( x 1 − x 0 )( x 1 − x 2 )
( x − 0 )( x − 0. 9 ) ( 0. 6 − 0 )( 0. 6 − 0. 9 )
x^2 − 0. 9 x − 0. 18
L 2 , 2 =
( x − x 0 )( x − x 1 ) ( x 2 − x 0 )( x 2 − x 1 )
( x − 0 )( x − 0. 6 ) ( 0. 9 − 0 )( 0. 9 − 0. 6 )
x^2 − 0. 6 x
and get
P 2 ( x ) = L 2 , 0 f ( x 0 ) + L 2 , 1 f ( x 1 ) + L 2 , 2 f ( x 2 )
= x^2 − 1. 5 x + 0. 54
cos( 0 ) + x^2 − 0. 9 x − 0. 18
cos( 0. 6 ) + x^2 − 0. 6 x
cos( 0. 9 )
= (− 0. 43108687 ) x^2 + (− 0. 03245519 ) x + 1.
b. Use these polynomial approximations to compute the value of cos( 0. 45 ) and the absolute error.
Answer: P 1 ( 0. 45 ) = 0 .8690017, P 2 ( 0. 45 ) = 0 .8981007, and cos( 0. 45 ) = 0 .900447. So | cos( 0. 45 ) − P 1 ( 0. 45 )| = 0 .0314454 and | cos( 0. 45 ) − P 2 ( 0. 45 )| = 0 .002347.
c. Use theorem 3.3 to calculate an error bound for these approximations. Do the answers from part (b) obey the error bounds? Answer: Theorem 3.3 tells us that the absolute error is given by
| f ( x ) − P ( x )| = f ( n +^1 )(ξ( x )) ( n + 1 )!
n
i = 0
( x − xi ).
So then,
| f ( x ) − P 1 ( x )| =
∣∣ f^ (^2 )(ξ) 2
cos( 0 ) 2
b. f ( x ) =
x and the values x 0 = 0, x 1 = 1, x 2 = 2, x 3 = 4 and x 4 = 5 Answer: To approximate
3, we use Neville’s method to approximate f ( x ) =
x at x = 3: octave:2> nodes=[0,1,2,4,5]; f=sqrt(nodes); x=3; neville ans =
c. Compare the accuracy of the approximation in parts (a) and (b). Answer: We see that part (a) gives an absolute error of |
3 − 1. 70833 | = 0 .023721; whereas part (b) gives an absolute error of 0.041441, which is larger.
4. Newton’s divided difference [computational] (section 3.2, problem 7a) Use Algorithm 3.2 to construct the interpolating polynomial of degree three for the unequally spaced points given in the following table:
x f(x) -0.1 5. 0.0 2. 0.2 3. 0.3 1.
Answer: Newton’s divided difference code (ndd.m): %---------------------------------------------------------- % Newton divided difference for polynomial interpolation % must put x0,x1,...,xn in vector called "nodes" % and f(x0),f(x1),... in vector called "f" %----------------------------------------------------------
% create matrix to store up F_{i,j} n = length(nodes); F = zeros(n);
% fill up first column for i = 1:n F(i,1) = f(i); end
% now fill up row by row for i = 2:n for j = 2:i F(i,j) = ( F(i,j-1) - F(i-1,j-1) ) / ( nodes(i) - nodes(i-j+1) ); end
end
% print out diagonal elements diag(F)
generates the coefficients: octave:3> nodes=[-0.1,0.0,0.2,0.3]; f=[5.3,2.0,3.19,1.0]; ndd ans =
-33.
-556.
which yields the interpolating polynomial
P ( x ) = 5. 3 − 33. 0 ( x + 0. 1 ) + 129. 8333 ( x + 0. 1 )( x ) − 556. 6667 ( x + 0. 1 )( x )( x − 0. 2 )