Page 103 -
P. 103

strip areas to obtain the value of the integral. This technique is referred to as
                             the midpoint rule.
                              We can justify the above algorithm by recalling the Mean Value Theorem of
                             Calculus, which states that:


                                                     ∫ b  fx dx()  =  ( b a f c) ( )−       (4.4)
                                                      a

                             where c ∈ [a, b]. Thus, if we divide the interval of integration into narrow sub-
                             intervals, then the total integral can be written as the sum of the integrals over
                             the subintervals, and we approximate the location of c in a particular sub-
                             interval by the midpoint between its boundaries.


                             Example 4.5
                             Use the above algorithm to compute the value of the definite integral of the
                             function sin(x) from 0 to π.

                             Solution: Edit and execute the following program:

                                dx=pi/200;
                                x=0:dx:pi-dx;
                                xshift=x+dx/2;
                                yshift=sin(xshift);
                                Int=dx*sum(yshift)
                             You get for the above integral a result that is within 1/1000 error from the
                             analytical result.



                             In-Class Exercises

                             Find numerically, to a 1/10,000 accuracy, the values of the following definite
                             integrals:

                                      ∫ ∞  1
                             Pb. 4.21  0 x + 1  dx
                                          2

                                      ∫ ∞      2
                             Pb. 4.22    exp(−x  )cos( x2  )dx
                                       0
                                      ∫ π /2  6    7
                             Pb. 4.23  0  sin ( )cos ( )x  x dx




                             © 2001 by CRC Press LLC
   98   99   100   101   102   103   104   105   106   107   108