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  /


The Mathematica function NIntegrate computes a numerical approximation to a definite integral. To use NIntegrate you must enter a symbolic expression for the function you want to integrate. There are many situations that arise in experimental and numerical work in which all you have is a list of values of the function to be integrated. The function ListIntegrate given in this package will compute an approximation to the integral in this case.

Approximating a definite integral from a list of function values.

ListIntegrate works by using Interpolation to construct an InterpolatingFunction object to approximate the function that produced the data with a collection of interpolating polynomials. The InterpolatingFunction is integrated to obtain the result. You can specify the degree of the polynomial used in the InterpolatingFunction object by giving a value for k. k is the number of points used to construct each polynomial and the degree of each polynomial is k1 (InterpolationOrder->

k1). The default value for k is


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

  • This gives a list of function values forĀ 

  • In[2]:= data = Table[ n^2, {n, 0, 7}]


  • This gives an approximation to the integral of the function that produced the list of "data". The step size of 1 means that the values in the list come from x values that are 1 unit apart.
  • In[3]:= ListIntegrate[data, 1]


  • Because the data were created by a degree two polynomial, the approximation is exact.
  • In[4]:= Integrate[x^2, {x, 0, 7}]


  • This gives the integral derived from the same data with a small random perturbation added.
  • In[5]:= ListIntegrate[
    Table[ n^2 + .1 Random[ ],
    {n, 0, 7}], 1]


  • If the data are a little noisy the approximation is still fairly good.
  • In[6]:= % - %%


  • By giving a list of pairs you can work with variable step-size data. The approximation is not as good as before, because the degree of the approximation has been reduced to

    , that is, linear interpolation.
  • In[7]:= ListIntegrate[


    If you know that there is significant error in your data, that is, it differs a great deal from the "true function", it is better to smooth the error using Fit and then use NIntegrate to compute the integral of the fit.

    Integration Using Interpolation

    This package has been included for compatibility with previous versions of Mathematica. The functionality of this package has been superseded by improvements made to InterpolatingFunction. For example, the first and last examples can just as easily be done directly.

  • This makes an InterpolatingFunction approximation.
  • In[8]:= app = ListInterpolation[data,{{0,7}}]


  • This integrates the approximation.
  • In[9]:= Integrate[app[x],{x,0,7}]


  • Here approximation and integration are performed in one step.
  • In[10]:= Integrate[Interpolation[{{0,0},{1,1},{2,4},{5,25},{7,49}},


    It is advantageous to use the direct construction because it can be used to find the integral over part of the interval between the points, an approximate indefinite integral function, or the approximate integral for multidimensional data on tensor product grids.