Re: Numerical integration on an irregular grid



Glyn Edwards wrote:
>
> Is there a "best" way to approximate the integral of a function
> when the function is only known at irregularly spaced points? It is safe
> tu assume the function is continuous.
>
> Currently I am using a simple trapezium rule as I can't find anything more
> appropriate that isn't restricted to regular grids (Simpson's rule). The
> only way I could get the function at regular points is by interpolation.

Use a sliding (three point) interval spline fit to calculate the
integral (or derivative) analytically via spline fit coefficients. The
method does very well assuming the max point spacing is reasonable.
If so, then "spline.f" on netlib would serve your purpose well.

http://netlib.org/fmm/spline.f

.


Quantcast