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
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.
Details and Options
- To use NIntegrateInterpolatingFunction, you first need to load the Function Approximations Package using Needs["FunctionApproximations`"].
- NIntegrateInterpolatingFunction uses the function NIntegrate, but it breaks up the domain of integration into sections where the InterpolatingFunction objects are smooth.
- If the integrand f does not contain any InterpolatingFunction objects, NIntegrateInterpolatingFunction is equivalent to NIntegrate.
- The arguments of the InterpolatingFunction objects may themselves be univariate functions of the integration variables.
- If the integrand f is simply an InterpolatingFunction object, it is better to use Integrate because this gives a result that is exact for the polynomial approximation used in the InterpolatingFunction object.
- 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.
Examples
open all close allBasic Examples (1)
Needs["FunctionApproximations`"]A trapezoidal approximation to
:
sin = Interpolation[Table[{x, Sin[x]}, {x, 0, 1, .1}], InterpolationOrder -> 1]Since
is not smooth, NIntegrate will generate a warning message:
NIntegrate[sin[x], {x, 0, 1}]Using NIntegrateInterpolatingFunction produces a slightly more accurate answer without any error messages:
NIntegrateInterpolatingFunction[sin[x], {x, 0, 1}]In this case the integrand is simply an interpolating function, so you can use Integrate to check:
Integrate[sin[x], {x, 0, 1}]Scope (3)
Needs["FunctionApproximations`"]NIntegrateInterpolatingFunction threads element-wise over the first argument:
f = FunctionInterpolation[Sin[x], {x, 0, 1}]NIntegrateInterpolatingFunction[{x, x^2f[x]}, {x, 0, 1}]Needs["FunctionApproximations`"]f = FunctionInterpolation[Exp[I x], {x, 0, 1}]NIntegrateInterpolatingFunction[f[x]^2, {x, 0, 1}]Needs["FunctionApproximations`"]f = FunctionInterpolation[Sin[x y], {x, 0, 1}, {y, 0, 1}]NIntegrateInterpolatingFunction[f[x, y], {x, 0, 1}, {y, 0, 1}]Generalizations & Extensions (1)
Needs["FunctionApproximations`"]The arguments of the interpolating function may themselves be univariate functions of the integration variables:
sin = FunctionInterpolation[Sin[x y], {x, 0, 4}, {y, 0, 4}]NIntegrateInterpolatingFunction[sin[y^2, x^2]^2, {x, 0, 2}, {y, 0, 2}]Properties & Relations (1)
Needs["FunctionApproximations`"]A trapezoidal approximation to Sin[π x]:
f = Interpolation[Table[{x, Sin[π x]}, {x, 0, 1, .1}], InterpolationOrder -> 1]Plot[f[x], {x, 0, 1}]Accumulate the sampling points used by NIntegrateInterpolatingFunction:
samplingPoints = Reap[NIntegrateInterpolatingFunction[f[x], {x, 0, 1}, EvaluationMonitor :> Sow[x]]][[2, 1]];Plot the sampling points. The function is sampled at the x coordinates in the order of the y coordinates:
ListPlot[Transpose[{samplingPoints, Range[Length[samplingPoints]]}], GridLines -> {Range[0, 1, .1], None}]Accumulate the sampling points used by NIntegrate:
samplingPoints = Reap[NIntegrate[f[x], {x, 0, 1}, EvaluationMonitor :> Sow[x]]][[2, 1]];With NIntegrate, the nonsmooth behavior of f[x] near the points x=
produces an error message and requires many recursive steps to evaluate accurately:
ListPlot[Transpose[{samplingPoints, Range[Length[samplingPoints]]}], GridLines -> {Range[0, 1, .1], None}]Increasing the order of the interpolation will produce a smoother function:
f = Interpolation[Table[{x, Sin[π x]}, {x, 0, 1, .1}], InterpolationOrder -> 3]Plot[f[x], {x, 0, 1}]With a smoother function, fewer function evaluations are needed by NIntegrate:
samplingPoints = Reap[NIntegrate[f[x], {x, 0, 1}, EvaluationMonitor :> Sow[x]]][[2, 1]];ListPlot[Transpose[{samplingPoints, Range[Length[samplingPoints]]}], GridLines -> {Range[0, 1, .1], None}]If the interpolation is smooth enough, NIntegrate will require fewer function evaluations than NIntegrateInterpolatingFunction:
f = Interpolation[Table[{x, Sin[π x]}, {x, 0, 1, .1}], InterpolationOrder -> 5]samplingPoints = Reap[NIntegrate[f[x], {x, 0, 1}, EvaluationMonitor :> Sow[x]]][[2, 1]];ListPlot[Transpose[{samplingPoints, Range[Length[samplingPoints]]}], GridLines -> {Range[0, 1, .1], None}]Possible Issues (1)
Needs["FunctionApproximations`"]Multidimensional interpolating functions with a large number of nodes may take much longer to integrate using NIntegrateInterpolatingFunction instead of NIntegrate:
f = Interpolation[Flatten[Table[N[{x, y, Sin[x y]}], {x, 0, π, (π/100)}, {y, 0, π, (π/100)}], 1]];With NIntegrate, only one integral is evaluated, but the nonsmooth behavior generates many recursive steps:
NIntegrate[f[x, y]^2, {x, 0, π}, {y, 0, π}]//TimingUsing NIntegrateInterpolatingFunction, the integral is broken up into
integrals over a smaller domain, where the integrand is smooth:
NIntegrateInterpolatingFunction[f[x, y]^2, {x, 0, π}, {y, 0, π}]//TimingSee Also
Tech Notes
Related Guides
Text
Wolfram Research (2010), NIntegrateInterpolatingFunction, Wolfram Language function, https://reference.wolfram.com/language/FunctionApproximations/ref/NIntegrateInterpolatingFunction.html.
CMS
Wolfram Language. 2010. "NIntegrateInterpolatingFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/FunctionApproximations/ref/NIntegrateInterpolatingFunction.html.
APA
Wolfram Language. (2010). NIntegrateInterpolatingFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FunctionApproximations/ref/NIntegrateInterpolatingFunction.html
BibTeX
@misc{reference.wolfram_2026_nintegrateinterpolatingfunction, author="Wolfram Research", title="{NIntegrateInterpolatingFunction}", year="2010", howpublished="\url{https://reference.wolfram.com/language/FunctionApproximations/ref/NIntegrateInterpolatingFunction.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_nintegrateinterpolatingfunction, organization={Wolfram Research}, title={NIntegrateInterpolatingFunction}, year={2010}, url={https://reference.wolfram.com/language/FunctionApproximations/ref/NIntegrateInterpolatingFunction.html}, note=[Accessed: 15-June-2026]}