Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Function Approximations Package >

NIntegrateInterpolatingFunction

NIntegrateInterpolatingFunction[f, {x, xmin, xmax}]
gives a numerical approximation to an integral with InterpolatingFunction objects in the integrand.
NIntegrateInterpolatingFunction[f, {x, xmin, xmax}, {y, ymin, ymax}, ...]
gives a numerical approximation to a multidimensional integral.
  • NIntegrateInterpolatingFunction uses the function NIntegrate, but it breaks up the domain of integration into sections where the InterpolatingFunction objects are smooth.
  • The arguments of the InterpolatingFunction objects may themselves be univariate functions of the integration variables.
  • Numerically integrating a multidimensional integral using NIntegrateInterpolatingFunction with InterpolatingFunction objects containing a large number of nodes may take significantly longer than using NIntegrate.
  • NIntegrateInterpolatingFunction has the same options as NIntegrate.
A trapezoidal approximation to sin(x):
Since sin(x) is not smooth, NIntegrate will generate a warning message:
Using NIntegrateInterpolatingFunction produces a slightly more accurate answer without any error messages:
In this case the integrand is simply an interpolating function, so you can use Integrate to check:
Needs["FunctionApproximations`"]
A trapezoidal approximation to sin(x):
In[2]:=
Click for copyable input
Out[2]=
Since sin(x) is not smooth, NIntegrate will generate a warning message:
In[3]:=
Click for copyable input
Out[3]=
Using NIntegrateInterpolatingFunction produces a slightly more accurate answer without any error messages:
In[4]:=
Click for copyable input
Out[4]=
In this case the integrand is simply an interpolating function, so you can use Integrate to check:
In[5]:=
Click for copyable input
Out[5]=
NIntegrateInterpolatingFunction threads element-wise over the first argument:
Complex-valued interpolation:
Multidimensional integrals:
The arguments of the interpolating function may themselves be univariate functions of the integration variables:
A trapezoidal approximation to Sin[Pi x]:
Accumulate the sampling points used by NIntegrateInterpolatingFunction:
Plot the sampling points. The function is sampled at the x coordinates in the order of the y coordinates:
Accumulate the sampling points used by NIntegrate:
With NIntegrate, the nonsmooth behavior of f[x] near the points produces an error message and requires many recursive steps to evaluate accurately:
Increasing the order of the interpolation will produce a smoother function:
With a smoother function, fewer function evaluations are needed by NIntegrate:
If the interpolation is smooth enough, NIntegrate will require fewer function evaluations than NIntegrateInterpolatingFunction:
Multidimensional interpolating functions with a large number of nodes may take much longer to integrate using NIntegrateInterpolatingFunction instead of NIntegrate:
With NIntegrate, only one integral is evaluated, but the nonsmooth behavior generates many recursive steps:
Using NIntegrateInterpolatingFunction, the integral is broken up into 10^4 integrals over a smaller domain, where the integrand is smooth:
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team