>  Docs Center  >  Libraries  >  ASTROLIB  >  TSUM






      Trapezoidal summation of the area under a curve.


      Adapted from the procedure INTEG in the IUE procedure library.

Calling Sequence

      Result = TSUM(y)
      Result = TSUM( x, y, [ imin, imax ] )


      x = array containing monotonic independent variable. If omitted, then
              x is assumed to contain the index of the y variable.
              x = lindgen( N_elements(y) ).
      y = array containing dependent variable y = f(x)

Optional Inputs

      imin = scalar index of x array at which to begin the integration
              If omitted, then summation starts at x[0].
      imax = scalar index of x value at which to end the integration
              If omitted then the integration ends at x[npts-1].


      result = area under the curve y=f(x) between x[imin] and x[imax].


      IDL> x = [0.0,0.1,0.14,0.3]
      IDL> y = sin(x)
      IDL> print,tsum(x,y) ===> 0.0445843
      In this example, the exact curve can be computed analytically as
      1.0 - cos(0.3) = 0.0446635


      The area is determined of individual trapezoids defined by x[i],
      x[i+1], y[i] and y[i+1].
      If the data is known to be at all smooth, then a more accurate
      integration can be found by interpolation prior to the trapezoidal
      sums, for example, by the standard IDL User Library int_tabulated.pro.

Modification History

      Written, W.B. Landsman, STI Corp. May 1986
      Modified so X is not altered in a one parameter call Jan 1990
      Converted to IDL V5.0 W. Landsman September 1997
      Allow non-integer values of imin and imax W. Landsman April 2001
      Fix problem if only 1 parameter supplied W. Landsman June 2002

© 2022 L3Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Contact Us