Вы находитесь на странице: 1из 4

MATH 128A, SUMMER 2010, HOMEWORK 5 SOLUTION

BENJAMIN JOHNSON

Homework 5: Due Monday, July 12


3.2; 4a, 9a, 16
3.3; 2a, 4a
3.4; 4b, 6b, 19
section 3.2
4. Use the Newton forward-difference formula to construct interpolating polynomials of degree
one, two, and three for the following data. Approximate the specified value using each of
the polynomials.
a. f (0.43) if f (0) = 1, f (0.25) = 1.64872, f (0.5) = 2.71828, f (0.75) = 4.48169

solution: Newtons forward-difference formula gives Pn (x) = nk=0 ks k f (x0 ). In our


P 
case, we have x0 = 0 and xk = x0 + 0.25 k for each k, so that h = 0.25; and solving
x = x0 + s h for s given x = 0.43, x0 = 0, and h = 0.25 yields s = 1.72.
To get expressions for the polynomials, we need to compute 0 f (x0 ), 1 f (x0 ), 2 f (x0 ),
and 3 f (x0 ).

0 f (x0 ) = f (x0 ) = 1
1 f (x0 ) = f (x1 ) f (x0 ) = 1.64872 1 = 0.64872.
2 f (x0 ) = (f (x2 ) f (x1 )) (f (x1 ) f (x0 )) = (2.71828 1.64872) 0.64872 = 0.42084.
3 f (x0 ) = (f (x3 )2f (x2 )+f (x1 ))0.42084 = 4.4816922.71828+1.648720.42084 =
0.27301.

Now we have:
P1 (0.43) = f (x0 ) + 1.72

1
f (x0 ) = 1 + 1.72 0.64872 = 2.1158.
P2 (0.43) = P1 (0.43) + 2 2 f (x0 ) = 2.1158 + 1.72(1.721)
1.72

21
0.42084 = 2.37638.
1.72
 3 1.72(1.721)(1.722)
P3 (0.43) = P2 (0.43) + 3 f (x0 ) = 2.37638 + 3!
0.27301 = 2.3606.

9. a. Approximate f (0.05) using the following data and the Newton forward divided-difference
formula:

x 0.0 0.2 0.4 0.6 0.8


f (x) 1.00000 1.22140 1.49182 1.82212 2.22554

solution: Here we have x0 = 0 and xk = x0 + 0.2 k for each k = 1, . . . , 4. So in the


formulas we have h = 0.2 and x = 0.05 = x0 + 0.25 h implying s = 0.25. The Newton
forward divided-difference formula gives:

Date: July 12, 2010.


1
2 BENJAMIN JOHNSON

4  
X 0.25
P4 (0.05) = 4 f (x0 )
k=0
k
         
0.25 0 0.25 1 0.25 2 0.25 3 0.25
= f (x0 ) + f (x0 ) + f (x0 ) + f (x0 ) + 4 f (x0 )
0 1 2 3 4
= 1 1 + 0.25 0.22140 + 0.09375 0.04902 + 0.0546875 0.01086 + 0.0375977 0.00238
= 1.05126

For this problem I computed both the choose functions and the k s using Mathemat-
ica. I have included the relevant session transcript below for reference. Even though
Mathematica isnt covered in this class, it may be useful to see what it can do easily. It
is a useful program for doing symbolic algebra, manipulating lists, and for employing a
variety of common mathematical functions without having to write too much code. Of
course for this problem you could also have written some MATLAB code to accomplish
more or less the same thing, or written out more steps by hand.

In[389]:= Binomial[0.25, 2]

Out[389]= -0.09375

In[390]:= Binomial[0.25, 3]

Out[390]= 0.0546875

In[391]:= Binomial[0.25, 4]

Out[391]= -0.0375977

In[379]:= f = {1.0, 1.22140, 1.49182, 1.82212, 2.22554}

Out[379]= {1., 1.2214, 1.49182, 1.82212, 2.22554}

In[383]:= Df = Table[f[[i + 1]] - f[[i]], {i, 4}]

Out[383]= {0.2214, 0.27042, 0.3303, 0.40342}

In[385]:= DDf = Table[Df[[i + 1]] - Df[[i]], {i, 3}]

Out[385]= {0.04902, 0.05988, 0.07312}

In[387]:= DDDf = Table[DDf[[i + 1]] - DDf[[i]], {i, 2}]

Out[387]= {0.01086, 0.01324}

In[388]:= DDDDf = Table[DDDf[[i + 1]] - DDDf[[i]], {i, 1}]

Out[388]= {0.00238}
MATH 128A, SUMMER 2010, HOMEWORK 5 SOLUTION 3

16. For a function f , the Newton divided-difference formula gives the interpolating polynomial
16
P3 (x) = 1 + 4x + 4x(x 0.25) + x(x 0.25)(x 0.5),
3
on the nodes x0 = 0, x1 = 0.25, and x3 = 0.75. Find f (0.75).
solution: Since the interpolating polynomial agrees with f at the xi and we are asked to
find f (x3 ), it suffices to compute P3 (x3 ). We get
P3 (0.75) = 1 + 4(0.75) + 4 0.75 (0.75 0.25) + 16
3
0.75(0.75 0.25)(0.75 0.5) = 6.

section 3.3
2. Use Theorem 3.9 or Algorithm 3.3 to construct an approximating polynomial for the follow-
ing data.

x f (x) f 0 (x)
a. 0 1.00000 2.00000
0.5 2.71828 5.43656

solution: I will
P use Theorem 3.9. It says the Hermite P polynomial is given by the formula
H2n+1 (x) = nj=0 f (xj )[12(xxj )L0n,j (x)]L2n,j (x)+ nj=0 f 0 (xj )(xxj )L2n,j (x). In our
case n = 1 and there are only two points x0 = 0 and x1 = 0.5. The formula becomes

H3 (x) = f (x0 )[1 2(x x0 )L01,0 (x)]L21,0 (x)


+ f (x1 )[1 2(x x1 )L01,1 (x)]L21,1 (x)
+ f 0 (x0 )(x x0 )L21,0 (x)
+ f 0 (x1 )(x x1 )L21,1 (x)

L1,0 (x) = xxx 1


0 x1
= x0.5
0.5
= 2.00000(x 0.5)
L1,0 (x) = 4.00000(x 0.5)2
2

L01,0 (x) = 2.00000


L1,1 (x) = xxx 0
1 x0
= x0
0.5
= 2x
2 2
L1,1 (x) = 4x
L01,1 (x) = 2
So
H3 (x) = 1.00000[1 2x(2.00000)]4.00000(x 0.5)2
+ 2.71828[1 2(x 0.5)(2)]4x2
+ 2.00000x 4.00000(x 0.5)2
+ 5.43656(x 0.5)4x2
Since calculating (as opposed to simplifying) is the point, this final answer is fine.
4. The data in Exercise 2 were generated using the following functions. Use the polynomials
constructed in Exercise 2 for the given value of x to approximate f (x), and calculate the
absolute error.
4 BENJAMIN JOHNSON

a. f (x) = e2x ; approximate f (0.43).


solution: Plugging 0.43 into the polynomial we got for Exercise 2 part a, we obtain
H3 (0.43) = 2.36207. Since f (0.43) = e0.432 = 2.36316, the absolute error is 0.00109.
section 3.4
4. Construct the free cubic spline for the following data.
x f (x)
b. 0.25 1.33203
0.25 0.800781

solution: Since there are only two points, there will only be one cubic function S0
in the cubic spline. This function must have the form S0 (x) = ax3 + bx2 + cx + d.
Our constraints are that S0 (0.25) = 1.33203, that S0 (0.25) = 0.800781, and that
S000 (0.25) = S000 (0.25) = 0. From these constraints we need to determine a, b, c and d.
We begin by considering the constraints on the second derivative. Starting with our
assumed form for S0 , we have S00 (x) = 3ax2 + 2bx + c. Then S000 (x) = 6ax + 2b. Since
this is a linear degree one equation, the only way it can be zero at two distinct points
x = 0.25 and x = 0.25 is if it is the zero equation, which gives a = b = 0.
We thus have that S0 is a linear function. The slope of this function is 0.8007811.33203
0.25(0.25)
=
1.0625, and so c = 1.0625. Now we can solve for d using (for example) c 0.25 + d =
0.800781, obtaining d = 1.06641.

S0 (x) = 1.0625x + 1.06641


6. The data in Exercise 4 were generated using the following functions. Use the cubic splines
constructed in Exercise 4 for the given value of x to approximate f (x), and f 0 (x) and
calculate the actual error.
b. f (x) = x4 x3 + x2 x + 1; approximate f (0) and f 0 (0).
solution: Using the S0 from Exercise 4b, we have S0 (0) = 1.06641, and S00 (0) =
1.0625. The actual answers are f (0) = 1 and f 0 (0) = 1. So the absolute error of
approximation for f 0 (0) is 0.06641, and the absolute approximation error for f 0 (0) is
0.0625.
19. Suppose that f (x) is a polynomial of degree three. Show that f (x) is its own clamped cubic
spline, but that it cannot be its own free cubic spline.
solution: Given any set of endpoints [a, b] and any set of intermediate points x1 , . . . , xn1 ,
the conditions for a clamped cubic spline are satisfied by f , (i.e. f matches the values of
f and f matches the derivatives of f at all the required points. Since the clamped cubic
spline interpolation is unique, it must be f .
On the other hand, a condition for the free cubic spline interpolant is that the second
derivative be zero at the endpoints. If f were its own free cubic spline on some interval, say
[a, b], then we would need f 00 (a) = f 00 (b) = 0. However, the second derivative of any cubic
polynomial is a polynomial of degree 1, and from the Fundamental Theorem of Algebra
(or more precisely one of its corollaries) this degree one polynomial can only be zero at
two distinct points a and b if it is the zero polynomial. This implies in particular that
the coefficients of both the x3 term and the x2 term in f are zero and this contradicts the
assumption that f was a cubic polynomial. Consequently, f cannot be its own free cubic
spline.

Вам также может понравиться