This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Add-ons / Standard Packages / NumericalMath  /

NumericalMath`NIntegrateInterpolatingFunct`

The Mathematica function NIntegrate uses algorithms that assume that the integrand is smooth to at least several orders. InterpolatingFunction objects typically do not satisfy this assumption; they are continuous, but only piecewise smooth. The algorithms used by NIntegrate converge very slowly when applied to InterpolatingFunction objects, especially in several dimensions. NIntegrate allows the domain of integration to be broken up into several pieces and the integral evaluated over each piece. If the pieces of the domain correspond to the pieces over which the InterpolatingFunction is smooth, NIntegrate will converge much more rapidly. NIntegrateInterpolatingFunction automatically breaks up the domain of integration.


Numerical approximations to integrals with InterpolatingFunction objects in the integrand.

NIntegrateInterpolatingFunction uses the function NIntegrate, but it breaks up the domain into sections where the InterpolatingFunction object is smooth.

  • This loads the package.
  • In[1]:= <<NumericalMath`NIntegrateInterpolatingFunct`

  • This creates an InterpolatingFunction object approximating the sine function.
  • In[2]:= sin = Interpolation[Table[{x,Sin[x]},{x,0,4,.5}]]

    Out[2]=

  • This list gives the time used to evaluate the integral plus the result of the integral.
  • In[3]:= NIntegrateInterpolatingFunction[sin[x^2]^2,
    {x,0,2}] // Timing

    Out[3]=

  • NIntegrate produces almost exactly the same result, but takes much longer because the convergence is poor without properly breaking up the domain.
  • In[4]:= NIntegrate[sin[x^2]^2, {x,0,2}] // Timing

    Out[4]=

    If you simply need to find the integral of an InterpolatingFunction object (as opposed to a function of one), it is better to use Integrate because this gives you the result which is exact for the polynomial approximation used in the InterpolatingFunction object.