2 0.08 0.08 0.06 0.06 0.04 0.04 0.02 0.02 0.00 0.00 0.750 0.875 1.000 1.125 exact computed 1-(2x-x ) 1.250 x Figure 3.1: Evaluation of 1 − (2x − x2) exactly (dashed curve) and in a floating-point representation with β = 2 and p = 6 (solid line). From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press 6 5 4 3 2 x − 6x + 15x − 20x + 15x − 6x + 1 vs x 20 IEEE single precision value × 10 10 7 (x−1)6 7 10 0 -10 -20 0.99990 0.99995 1.00000 Figure 3.2: Numerical evaluation of a polynomial in the power form (1 − x)6 (dashed line and right vertical axis) and in the expanded form x6 − 6x5 + 15x4 − 20x3 + 15x2 − 6x + 1 (solid line and left vertical axis), using IEEE single-precision floating-point arithmetic in both cases. The computed values plotted on the vertical axes have been multiplied by 107. The value of mach is 1.192 × 10−7; the value of one ulp is 5.96 × 10−8 in the range shown. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press Roots of (z−1)20 = 2 −24 0.50 m [z − 1] 0.25 0.00 -0.25 -0.50 -0.50 -0.25 0.00 0.25 0.50 [zm − 1] Figure 3.3: The points represent the error in the mth root, zm − 1, of the polynomial equation (z − 1)20 = 2−24, for m ∈ (0 : 19). From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press y 4.0 3.5 y = 1–x – b 3.0 2.5 2.0 1.5 1.0 0.5 0.0 –0.5 x0 x1 x2 1.0 2.0 3.0 4.0 x Figure 3.4: Illustration of the first two steps of Newton-Raphson iteration for the function f(x) = 1/x − b, with b = 0.5. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press f(x4) f(x3) f(x2) f(x1) x0 x 1 x2 x3 x4 Figure 3.5: Approximate evaluation of the integral the right-hand rectangle rule. x4 x0 f(x) dx using From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press Global error in Euler’s method 0.00100 Error 0.00075 0.00050 0.00025 0.00000 0.00000 0.00002 0.00005 0.00007 0.00010 Step size Figure 3.6: Absolute value of the global error in Euler’s method for L = 1 and a = 1. The computation was performed using IEEE-754 single-precision arithmetic. The global truncation error predicted by Eq. (3.111) is shown as a dashed line. For step sizes larger than approximately h = 0.00001, the error decreases roughly linearly in h, with considerable scatter due to rounding error. For step sizes much smaller than h = 0.00002, the error increases rapidly because of an accumulation of rounding errors. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press (ha) –1 1 (ha) Figure 3.7: The region of stability of Euler’s method, computed using the test equation y = ay, is a disk of radius 1 centered at z = −1, where z = ha. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press cn 100 80 60 40 20 0 -20 -40 -60 -80 -100 50 100 x Figure 3.8: The solution computed to the equation y = − y by Euler’s method with a step size h = 2.1, which is outside of the region of stability. The initial condition is y(0) = 1. The analytical solution is so heavily damped, and is of such a small magnitude, that on the scale of this graph it nearly coincides with the horizontal axis. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press cn 1.00 0.75 0.75 0.50 0.50 0.25 0.25 0.00 0.0 0.00 0.5 1.0 1.5 yn 1.00 2.0 x Figure 3.9: The computed (solid line) and exact (dashed line) solutions of the differential equation y = −y, illustrating a weak instability. The first step of the computed solution was taken using Euler’s method; the remaining steps were taken with the midpoint method. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press (ha) –1 1 (ha) Figure 3.10: The region of stability of the backward Euler method, computed using the test equation y = ay, is the set of points outside, and on the circumference of, a disk of radius 1 centered at z = 1, where z = ha. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press (ha) 2 1 (ha) 0 –1 –2 –1.00 –0.75 –0.50 –0.25 0.00 0.25 Figure 3.11: The region of absolute stability of the midpoint-trapezoidal predictor-corrector method, computed using the test equation y = ay, in the plane of complex z = ha. From: Modern Mathematical Methods for Physicists and Engineers, by C. D. Cantrell © 2000 Cambridge University Press