12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

42 chapter 2To see if these assumptions are correct and determine what level of precision ispossible for the best choice of N, plot log 10 |[A(N) − A(2N)]/A(2N)| versus log 10 N,similar to what we have done in Figure 2.2. If you obtain a rapid straight-line dropoff, then you know you are in the region of convergence and can deduce a valuefor β from the slope. As N gets larger, you should see the graph change from astraight-line decrease to a slow increase as round-off error begins to dominate. Agood place to quit is before this. In any case, now you understand the error in yourcomputation and therefore have a chance to control it.As an example of how different kinds of errors enter into a computation, weassume we know the analytic form for the approximation and round-off errors:The total error is then a minimum whenɛ approx ≃ 1N 2 , ɛ ro ≃ √ Nɛ m , (2.34)⇒ ɛ tot = ɛ approx + ɛ ro ≃ 1N 2 + √ Nɛ m . (2.35)dɛ totdN = −2N 3 + 1 2ɛ m√N=0, (2.36)⇒ N 5/2 = 4ɛ m. (2.37)For a single-precision calculation (ɛ m ≃ 10 −7 ), the minimum total error occurs whenN 5/2 ≃ 410 −7 ⇒ N ≃ 1099, ⇒ ɛ tot ≃ 4 × 10 −6 . (2.38)In this case most of the error is due to round-off and is not approximation error.Observe, too, that even though this is the minimum total error, the best we can dois about 40 times machine precision (in double precision the results are better).Seeing that the total error is mainly round-off error ∝ √ N, an obvious way todecrease the error is to use a smaller number of steps N. Let us assume we do thisby finding another algorithm that converges more rapidly with N, for example,one with approximation error behaving likeThe total error is nowɛ approx ≃ 2N 4 . (2.39)ɛ tot = ɛ ro + ɛ approx ≃ 2N 4 + √ Nɛ m . (2.40)The number of points for minimum error is found as before:dɛ totdN =0 ⇒ N 9/2 ⇒ N ≃ 67 ⇒ ɛ tot ≃ 9 × 10 −7 . (2.41)−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 42

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!