NIntegrate

NIntegrate[f, {x, xmin, xmax}]
gives a numerical approximation to the integral .

NIntegrate[f, {x, xmin, xmax}, {y, ymin, ymax}, ...]
gives a numerical approximation to the multiple integral .

Details and OptionsDetails and Options

  • Multiple integrals use a variant of the standard iterator notation. The first variable given corresponds to the outermost integral and is done last.
  • NIntegrate by default tests for singularities at the boundaries of the integration region and at the boundaries of regions specified by settings for the Exclusions option.
  • NIntegrate[f, {x, x0, x1, ..., xk}] tests for singularities in a one-dimensional integral at each of the intermediate points . If there are no singularities, the result is equivalent to an integral from to . You can use complex numbers to specify an integration contour in the complex plane.
  • The following options can be given:
  • AccuracyGoalInfinitydigits of absolute accuracy sought
    EvaluationMonitorNoneexpression to evaluate whenever expr is evaluated
    ExclusionsNoneparts of the integration region to exclude
    MaxPointsAutomaticmaximum total number of sample points
    MaxRecursionAutomaticmaximum number of recursive subdivisions
    MethodAutomaticmethod to use
    MinRecursion0minimum number of recursive subdivisions
    PrecisionGoalAutomaticdigits of precision sought
    WorkingPrecisionMachinePrecisionthe precision used in internal computations
  • NIntegrate usually uses adaptive algorithms, which recursively subdivide the integration region as needed. specifies the minimum number of recursive subdivisions to try. MaxRecursion gives the maximum number.
  • NIntegrate usually continues doing subdivisions until the error estimate it gets implies that the final result achieves either the AccuracyGoal or the PrecisionGoal specified.
  • For low-dimensional integrals, the default setting for PrecisionGoal is related to WorkingPrecision. For high-dimensional integrals, it is typically taken to be a fixed value, usually .
  • You should realize that with sufficiently pathological functions, the algorithms used by NIntegrate can give wrong answers. In most cases, you can test the answer by looking at its sensitivity to changes in the setting of options for NIntegrate.
  • Possible explicit settings for the Method option include:
  • "GlobalAdaptive"global adaptive integration strategy
    "LocalAdaptive"local adaptive integration strategy
    "DoubleExponential"double exponential quadrature
    "MonteCarlo"Monte Carlo integration
    "AdaptiveMonteCarlo"adaptive Monte Carlo integration
    "QuasiMonteCarlo"quasi Monte Carlo integration
    "AdaptiveQuasiMonteCarlo"adaptive quasi Monte Carlo integration
  • With Method->{"strategy", Method->"rule"} or Method->{"strategy", Method->{rule1, rule2, ...}} possible strategy methods include:
  • "GlobalAdaptive"subdivide based on global error estimates
    "LocalAdaptive"subdivide based only on local error estimates
  • Methods used as rules include:
  • "CartesianRule"multidimensional product of rules
    "ClenshawCurtisRule"Clenshaw-Curtis rule
    "GaussKronrodRule"Gauss points with Kronrod extension
    "LevinRule"Levin-type oscillatory rules
    "LobattoKronrodRule"Gauss-Lobatto points with Kronrod extension
    "MultidimensionalRule"multidimensional symmetric rule
    "MultipanelRule"combination of 1D rules
    "NewtonCotesRule"Newton-Cotes rule
    "RiemannRule"Riemann sum rule
    "TrapezoidalRule"uniform points in one dimension
  • With the setting Method->"rule", the strategy method will be selected automatically.
  • Additional method suboptions can be given in the form Method->{..., opts}.
  • NIntegrate symbolically analyzes its input to transform oscillatory and other integrands, subdivide piecewise functions, and select optimal algorithms.
  • The method suboption specifies the maximum number of seconds for which to attempt performing symbolic analysis of the integrand.
  • N[Integrate[...]] calls NIntegrate for integrals that cannot be done symbolically.
  • NIntegrate first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically.
  • NIntegrate has attribute HoldAll and effectively uses Block to localize variables.

ExamplesExamplesopen allclose all

Basic Examples (4)Basic Examples (4)

Compute a numerical integral:

In[1]:=
Click for copyable input
Out[1]=

Compute a multidimensional integral (with singularity at the origin):

In[1]:=
Click for copyable input
Out[1]=

Compute areas and volumes for implicitly defined regions:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Integrate oscillatory and other complicated functions:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
New in 1 | Last modified in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »