Solutions Manual to Accompany An Introduction to Numerical Methods and Analysis. James F. Epperson
(for any function)so we use this to estimate the second derivative of :Therefore the estimate on the error isAccording to MATLAB, the exact value (to 15 places) isthus the interpolation error is , so our estimate is a tad high, but certainly it is within the range of acceptable estimation.
4 Construct a linear interpolating polynomial to the function using and as the nodes. What is the upper bound on the error over the interval , according to the error estimate?
5 Repeat the above for , using the interval .Solution: The polynomial isThe error bound is given byThis is again a conservative estimate, since a simple plot of the difference shows that the maximum absolute error is about 0.04.
6 Repeat the above for , using the interval .
7 If we want to use linear interpolation to the sine function and obtain an accuracy of , how close together do the entries in the table have to be? What if we change the error criterion to ?Solution: This amounts to asking how small does have to be to make the upper bound in the error estimate less than the specified tolerance. For convenience set . We have, then, for ,so that making the error less than requires taking . For an error less than we need .
8 Repeat the above for , for .
9 If we try to approximate the logarithm by using a table of logarithm entries, together with linear interpolation, to construct the approximation to over the interval , how many points are required to get an approximation that is accurate to within ?Solution: The error estimate isSo we require for accuracy; this means we need points. (Which is a lot of points!)
10 Construct a piecewise linear approximation to over the interval using the nodes . What is the maximum error in this approximation?
11 Repeat the above for over the interval , using the nodes .Solution: The polynomials areThe maximum errors are given byandso the overall error bound is about 0.078.
2.5 APPLICATION — THE TRAPEZOID RULE
Exercises:
1 Use the trapezoid rule with to approximate the integralYou should get that . How small does have to be to get that the error is less than ? ?
2 Use the trapezoid rule and to approximate the integralHow small does have to be to get that the error is less than ? ?
3 Repeat the above with .
4 Apply the trapezoid rule with , to approximate the integralHow small does have to be to get that the error is less than ? ?Solution: It's a fairly direct (if tedious) computation to getNow, for the accuracy, we haveThe second derivative isand we can bound this (for all ) as follows:A better upper bound would come fromTherefore, to get accuracy requires (using the weaker upper bound)To get accuracy requires
5 Apply the trapezoid rule with , to approximate the integralFeel free to use a computer program or a calculator, as you wish. How small does have to be to get that the error is less than ? ?Solution: The approximation is . The error bound gives usso we require for accuracy, and for accuracy.
6 Apply the trapezoid rule with , to approximate the integralHow small does have to be to get that the error is less than ? ?Solution: The approximation is . The error bound yieldsso we need to get accuracy, and to get accuracy.
7 Apply the trapezoid rule with , to approximate the integralHow small does have to be to get that the error is less than ? ?
8 Apply the trapezoid rule with , to approximate the integralHow small does have to be to get that the error is less than ? ?Solution: We haveTo get the accuracy, we note thatso that, over the interval ,Therefore, to get an error less than we take to satisfyTo get an error less than we take to satisfy
9 Let denote the value you obtained in the previous problem. Repeat the computation, this time using , and call this approximate value . Then computeand compare this to the given exact value of the integral.
10 Repeat the above for the integralSolution: We getandThe exact value is , so we see that is much more accurate than either of the trapezoid rule values.
11 For each integral below, write a program to do the trapezoid rule using the sequence of mesh sizes , where is the length of the given interval. Verify that the expected rate of decrease of the error is obtained:, , ;, , ;, , ;, , ;, , ;, , .
12 For each integral in Problem 11, how small does have to be to get accuracy, according to the error theory, of at least ? ?Solution: For the single case of (d), since , we have , sofor all on . We therefore haveWe therefore get accuracy by imposing which implies For accuracy we have
13 Apply the trapezoid rule to the integralusing a sequence of uniform grids with . Do we get the expected rate of convergence? Explain.
14 The length of a curve , for between and , is given by the integralUse the trapezoid rule with and to find the length of one “arch” of the sine curve.Solution: We get(using ), and(using ).
15 Use the trapezoid rule to find the length of the logarithm curve between and , using and .
16 What should be to guarantee an accuracy of when using the trapezoid rule for each of the following integrals:Solution: The error bound gives usso we require .Solution: The error bound gives usso we require .Solution: The error bound gives usso we require .Solution: The error bound gives usso we require .
17 Since the natural logarithm is defined as an integral,(2.3) it is possible to use the trapezoid rule (or any other numerical integration rule) to construct approximations to .Show that using the trapezoid rule on the integral (2.3) results in the series approximation (for )Hint: What are and in the integral defining the logarithm?How many terms are needed in this approximation to get an error of less than for all ? How many terms are needed for an error of less than over the same interval?Implement this series for a predicted accuracy of and compare it to the intrinsic natural logarithm function on your computer, over the interval . Is the expected accuracy achieved?If we were only interested in the interval , how many terms would be needed for the accuracy specified in (b)?Is it possible to reduce the computation of for all to the computation of for ? Explain.
18 How small must be to compute the error function,using the trapezoid rule, to within accuracy for all ?Solution: The error estimate implies thatwhere and we have used a very crude upper bound on the second derivative. Since we want to achieve the specified accuracy for all , we use (since this maximizes the upper bound) and therefore solve the inequalityto get .
19 Use the data in Table 2.8 to computeusing and .
20 Use the data in Table 2.7 to computeusing and .Solution: Using we getusing , we get
21 Show that the trapezoid rule is exact for all linear polynomials.
22 Prove Theorem 2.4.Solution: Let ; then we can apply Theorem 2.2 to get thatwhere . Therefore,
23 Extend the discussion on stability to include changes in the interval of integration instead of changes in the function. State and prove a theorem that bounds the change in the trapezoid rule approximation towhen the upper limit of integration changes from to , but remains the same.
24 Consider a function which is the floating point representation of ; thus is the rounding error in computing . If we assume that for all , show thatWhat does this say about the effects of rounding error on the trapezoid rule?Solution:sowhere . The result follows by simple manipulation.
25 We will end this section with a few exercises designed to illustrate the trapz command. Strictly speaking, trapz simply does a specialized summation. If S = trapz(Y) , thenwhich is the trapezoid rule with . To do an actual trapezoid rule for a uniform discretization, just multiply by ; for , we havewhere f is the vector of values.For each of the following integrals, use trapz to compute an approximate value.Apply the trapezoid rule with to approximate the integralCompare what you got here to what you got in Problem 6.Solution: The following script will do the job. I got trapy = 0.385643909952095 ; in Problem 6 we got 0.3856439099.N = 8; h = 1/N; x = [0:N]/N; y = log(1 + x); S = trapz(y); trapy = h*SRepeat the above for .Solution: If we set N = 100 in the above script, we getand the error is now much less than before.Apply the trapezoid