Page 76 - Applied Numerical Methods Using MATLAB
P. 76

PROBLEMS   65
                    evaluate the following two formulas (for the roots of a quadratic
                    equation) that are mathematically equivalent and plot the values of the
                    second root of each pair. Noting that the true values are not available
                    and so the shape of solution graph is only one practical basis on which
                    we can assess the quality of numerical solutions, tell which is better in
                    terms of resisting the loss of significance.
                                 1            √

                    (i)  x 1 ,x 2 =  (−b ∓ sign(b) b − 4ac)           (P1.20.2a)
                                                 2
                                2a
                              1            √               c/a

                                              2
                    (ii)  x 1 =  (−b − sign(b) b − 4ac), x 2 =        (P1.20.2b)
                             2a                             x 1
                                                           16
                                                      14
                 (c) For 100 values of x over the interval [10 ,10 ], evaluate the follow-
                    ing two expressions that are mathematically equivalent, plot them, and
                    based on the graphs, tell which is better in terms of resisting the loss
                    of significance.
                           √
                               2
                    (i) y =  2x + 1 − 1                               (P1.20.3a)
                                2x 2
                    (ii) y = √                                        (P1.20.3b)
                               2
                             2x + 1 + 1
                                                       −9
                (d) For 100 values of x over the interval [10 ,10 −7.4 ], evaluate the fol-
                    lowing two expressions that are mathematically equivalent, plot them,
                    and based on the graphs, tell which is better in terms of resisting the
                    loss of significance.
                           √        √
                    (i) y =  x + 4 −  x + 3                           (P1.20.4a)
                                   1
                    (ii) y = √      √                                 (P1.20.4b)
                             x + 4 +  x + 3

                 (e) On purpose to find the value of (300 125 /125!)e −300 , type the following
                    statement into the MATLAB command window.

                     >>300^125/prod([1:125])*exp(-300)
                    What is the result? Is it of any help to change the order of multipli-
                    cation/division? As an alternative, make a routine which evaluates the
                    expression

                                λ k  −λ
                         p(k) =   e      for λ = 300 and an integer k  (P1.20.5)
                                k!
                    in a recursive way, say, like p(k + 1) = p(k) ∗ λ/k and then, use the
                    routine to find the value of (300 125 /125!)e −300 .
   71   72   73   74   75   76   77   78   79   80   81