Solutions Manual to Accompany An Introduction to Numerical Methods and Analysis. James F. Epperson

Чтение книги онлайн.

Читать онлайн книгу Solutions Manual to Accompany An Introduction to Numerical Methods and Analysis - James F. Epperson страница 8

Solutions Manual to Accompany An Introduction to Numerical Methods and Analysis - James F. Epperson

Скачать книгу

Show that if and , then .Solution: We haveandThese follow from the definition of the notation. Therefore,which implies that .

      11 12. Suppose that and , for sufficiently small. Does it follow that (for sufficiently small)?

      12 13. Show thatfor all sufficiently small. Hint: Expand out to the fourth order terms.Solution:This is a straight‐forward manipulation with the Taylor expansionsandAdd the two expansions to getNow solve for .

      13 14. Explain, in your own words, why it is necessary that the constant in (1.8) be independent of .

      Exercises:

      1. In each problem below,

is the exact value, and
is an approximation to
. Find the absolute error and the relative error.

      1 , ;

      2 , ;

      3 , ;

      4 , .

       Solution:

      1 Abs. error , rel. error ;

      2 Abs. error , rel. error ;

      3 Abs. error , rel. error ;

      4 Abs. error , rel. error .

      1 2. Perform the indicated computations in each of three ways: (i) Exactly; (ii) Using three‐digit decimal arithmetic, with chopping; (iii) Using three‐digit decimal arithmetic, with rounding. For both approximations, compute the absolute error and the relative error.;;;.

      2 3. For each function below explain why a naive construction will be susceptible to significant rounding error (for near certain values), and explain how to avoid this error.;;;;.Solution: In each case, the function is susceptible to subtractive cancellation which will be amplified by division by a small number. The way to avoid the problem is to use a Taylor expansion to make the subtraction and division both explicit operations. For instance, in (a), we would writeTo get greater accuracy, take more terms in the Taylor expansion.

      3 4. For , how many terms in a Taylor expansion are needed to get single precision accuracy (7 decimal digits) for all ? How many terms are needed for double precision accuracy (14 decimal digits) over this same range?

      4 5. Using single precision arithmetic, only, carry out each of the following computations, using first the form on the left side of the equals sign, then using the form on the right side, and compare the two results. Comment on what you get in light of the material in 1.3., , ., , .Solution: “Single precision” means 6 or 7 decimal digits, so the point of the problem is to do the computations using 6 or 7 digits.Using MATLAB's single command on the author's laptop (running MATLAB R2019b), we getbutUsing the same software and hardware, we getbutWhat is interesting is how modern hardware and software have dramatically improved the results here. Earlier editions, which relied upon results using FORTRAN or C on a late 1990s Sun workstation, showed much more of a difference.

      5 6. Consider the sumwhere . Again using only single precision, compute this two ways: First, by summing in the order indicated in the formula; second, by summing backwards, i.e., starting with the term and ending with the term. Compare your results and comment upon them.

      6 7. (a) Using the computer of your choice, find three values , , and , such that(b) Repeat for your favorite calculator app.(c) Do this for single precision in your preferred computing environment.Solution:(a) The key issue is to get an approximation to the machine epsilon, then take , or something similar. This will guarantee that but . There is an additional issue, in that MATLAB always rounds unformatted output, so to see that you got a different result you have to use (ugh!) fprintf to print out enough digits. On my laptop, I was able to useand then fprintf told me thatIt is an interesting aspect of the history of this book, that when this exercise was first written (“a long time ago, in a computational environment far, far, away”), actual physical calculators were still commonplace (as opposed to smartphone/tablet apps). On an elderly Sharp calculator, circa 1997, the author found that , , and worked. Using a scientific calculator app on his phone, the author found that , , and worked. (However, he was not able to get this to work on the Windows 10 calculator app. It would make an interesting quasi‐research question to explain why.)(b) Using MATLAB's single command (carefully), I usedThen,

      7 8. Assume we are using 3‐digit decimal arithmetic. For , , computefor equal to each of 1, 2, and 3. Comment.

      8 9. Let . Explain, in your own words, why the computationis potentially rife with rounding error. (Assume that and are of comparable size.) Hint: See previous problem.Solution: This is just a generalization of the previous problem. If is small enough, then will be independent of .

      9 10. Using the computer and language of your choice, write a program to estimate the machine epsilon.Solution: There are lots of ways to do this. The basic idea is to add a small number to 1, and then check to see if the result is different from one, otherwise continue on. One possible solution is the following:Algorithm 1.1Computation of the machine epsilon x = 1.e-10; for k=1:6000 y = 1 + x; if y <= 1 disp(`macheps = ') disp(x) break end x = x*.99; end xThis produces (on the author's laptop) . If we change the initial x to 0.5, and decrement by a factor of 2 each step, we get , which, being larger, is a better estimate. (Why?)

      10 11. We can compute using Taylor polynomials in two ways, either usingor usingDiscuss, in your own words, which approach is more accurate. In particular, which one is more (or less) susceptible to rounding error?Solution:Because of the alternating signs in the first approach, there is some concern about subtractive cancellation when it is used.

      11 12. What is the machine epsilon for a computer that uses binary arithmetic, 24 bits for the fraction, and rounds? What if it chops?Solution: Recall that the machine epsilon is the largest number such that the computer returns . We therefore need to find the largest number that can be represented with 24 binary digits such that , when rounded to 24 bits, is still equal to 1. This is perhaps best done by explicitly writing out the addition in binary notation. We haveIf the machine chops, then we can set all of the values to 1 and the computer will still return ; if the machine rounds, then we need to make the first digit a zero. Thus, the desired values areand

      12 13. What is the machine epsilon for a computer that uses octal (base 8) arithmetic, assuming it retains 8 octol digits in the fraction?

      (No exercises in this section.)

      2.1 HORNER'S RULE AND NESTED MULTIPLICATION

      Exercises:

      1 Write each of the following polynomials

Скачать книгу