[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: INT_TABULATED Errors



In article <3888997E.7EBB8BE1@fsl.noaa.gov>,
  Andy Loughe <loughe@fsl.noaa.gov> wrote:
>
> ; Compute the area under the curve using INT_TABULATED
> ;
> ; Example 1
> x = [0.0, 0.3333, 0.985, 1.0]
> y = [0.0, 0.529, 0.894, 1.0]
> plot, x, y, psym=-2, title='Example 1'
> print, '   Too small ==> ', INT_TABULATED(x, y)
> ;
> ; Example 2
> x = [0.0, 0.10, 0.79, 1.0]
> y = [0.0, 0.67, 0.96, 1.0]
> plot, x, y, psym=-2, title='Example 2'
> print, '   Too large ==> ', INT_TABULATED(x, y)

Your example has two characteristics that make them unsuitable for
INT_TABULATED.   First they have abrupt changes in slope, and so
INT_TABULATED, which uses cubic spline interpolation, will poorly
approximate the function.    Second, they have a very irregularly spaced
grid, and INT_TABULATED computes the integral using a regular grid with
the same spacing.    (I would have rewritten INT_TABULATED to make sure
the regular grid spacing is at least as fine as the smallest separation
in the irregular input grid.)

Anyway, for a non-smooth curve I recommend using a simple trapezoidal
integration, such as tsum.pro available at
http://idlastro.gsfc.nasa.gov/ftp/pro/math/tsum.pro

Wayne Landsman                        landsman@mpb.gsfc.nasa.gov


Sent via Deja.com http://www.deja.com/
Before you buy.