Page 75 - Applied Numerical Methods Using MATLAB
P. 75

64    MATLAB USAGE AND COMPUTATIONAL ERRORS
                command window.

                >>x = 2^30;x+2^-23== x,x-2^-23==x
                which will give you the logical answer 1 (true) and 0 (false). Justify this
                                                                    31
                                                                            29
                                                                 30
                result based on the difference of resolution of two ranges [2 ,2 )and [2 ,
                                                             30
                 30
                                                                           30
                2 ) to which the true values of computational results (2 + 2 −23 )and (2 −
                2 −23 ) belong, respectively. Note from Eq. (1.2.5) that the resolutions—that is,
                the maximum quantization errors—are   E = 2 E−52  = 2 −52+30  = 2 −22  and
                2 −52+29  = 2 −23 , respectively. For details, refer to Fig. P1.18, which illustrates
                the procedure of addition/subtraction with four mantissa bits, one hidden bit,
                and one guard bit.
           1.19 Resolution of Number Representation and Quantization Error
                (a) What is the result of typing the following statements into the MATLAB
                   command window?
                    >>7/100*100 - 7

                   How do you compare the absolute value of this answer with the reso-
                   lution   of the range to which 7 belongs?
                (b) Find how many numbers are susceptible to this kind of quantization
                   error caused by division/multiplication by 100, among the numbers
                   from 1 to 31.
                (c) What will be the result of running the following program? Why?

                     %nm1p19: Quantization Error
                     x = 2-2^-50;
                     for n = 1:2^3
                        x = x+2^-52; fprintf(’%20.18E\n’,x)
                     end


           1.20 Avoiding Large Errors/Overflow/Underflow
                (a) For x = 9.8 201  and y = 10.2 199 , evaluate the following two expressions
                   that are mathematically equivalent and tell which is better in terms of
                   the power of resisting the overflow.


                             2
                    (i) z =  x + y 2                                  (P1.20.1a)

                                  2
                   (ii) z = y (x/y) + 1                               (P1.20.1b)
                   Also for x = 9.8 −201  and y = 10.2 −199 , evaluate the above two expres-
                   sions and tell which is better in terms of the power of resisting the
                   underflow.
                                                                            8.5
                                                                       7.4
                (b) With a = c = 1 and for 100 values of b over the interval [10 ,10 ]
                   generated by the MATLAB command ‘logspace(7.4,8.5,100)’,
   70   71   72   73   74   75   76   77   78   79   80