Numerical methods. Note 2
[~Home~] Integration I Numerical Methods. Note~ « 2 »

Integration. Classical formulas for equally spaced abscissas.

The classical n-point formula gives an estimate of an integral In ≈ 0h f(x)dx using the values of the integrand at n-points typically equally spaced within the interval (0,h). Due to round-off errors n cannot be too large, say n<10 for single and n<20 for double precision.
Closed (Newton-Cotes) formulae use the end-points of the interval Open formulae use only the inner points of the interval:

Problems

  1. Make a function OPEN24 that estimates the integral J=ab f(x)dx and the the integration error ERR using the 2-4 point open formulae:
    function [J,ERR] = OPEN24 ("f",a,b)
       calculate J2 and J4 
       J=J4 ; ERR=abs(J4-J2)
    
  2. Make a function DUMBINT that estimates the integral J=ab f(x)dx and the integration error by subdividing the interval (a,b) into N sub-intervals and using OPEN24 for each sub-interval:
    function [J,err] = DUMBINT ("f",a,b,N)
       subdivide (a,b) into N sub-intervals (ai,bi)
       for each sub-interval calculate the sub-integral and sub-error [Si,ei] = OPEN24("f",ai,bi)
       calculate the global-integral J=∑iSi and global-error err=√(∑iei2)
    
  3. Using your program calculate the integral
    -2020  [1/1+x2] dx
    and estimate the number of points (integrand evaluations) necessary to achieve the accuracy of err = 0.0001.

"Copyleft" © 2004 D.V.Fedorov (fedorov at phys dot au dot dk)