THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

# 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 .
• 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 xi. If there are no singularities, the result is equivalent to an integral from x0 to xk. You can use complex numbers xi to specify an integration contour in the complex plane.
• The following options can be given:
 AccuracyGoal Infinity digits of absolute accuracy sought EvaluationMonitor None expression to evaluate whenever expr is evaluated Exclusions None parts of the integration region to exclude MaxPoints Automatic maximum total number of sample points MaxRecursion Automatic maximum number of recursive subdivisions Method Automatic method to use MinRecursion 0 minimum number of recursive subdivisions PrecisionGoal Automatic digits of precision sought WorkingPrecision MachinePrecision the precision used in internal computations
• NIntegrate usually uses adaptive algorithms, which recursively subdivide the integration region as needed. MinRecursion 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 2.
• 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:
• 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 Cartesian product of rules "ClenshawCurtisRule" Clenshaw-Curtis rule "GaussKronrodRule" Gauss points with Kronrod extension "LobattoKronrodRule" Gauss-Lobatto points with Kronrod extension "MultidimensionalRule" multidimensional symmetric rule "MultipanelRule" combination of 1D rules "NewtonCotesRule" Newton-Cotes rule "TrapezoidalRule" uniform points in one dimension
• Additional method suboptions can be given in the form Method->{..., opts}.
• The method suboption "SymbolicProcessing" specifies the maximum number of seconds for which to attempt performing symbolic analysis of the integrand.
• NIntegrate first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically.
Compute a numerical integral:
Compute a multidimensional integral (with singularity at the origin):
Compute a high-dimensional integral:
Compute a numerical integral:
 Out[1]=

Compute a multidimensional integral (with singularity at the origin):
 Out[1]=

Compute a high-dimensional integral:
 Out[2]=
 Scope   (16)
Integration over an infinite region:
Line integral in the complex plane:
Integration over an infinite strip:
Integration over a region with functional boundaries:
Integration with complex numbers:
One-dimensional integral with singularities at both ends of the integration region:
Three-dimensional integral with singularities at two of the corners:
One-dimensional integral with a singularity inside the integration region:
Specify the location of the singularity to handle it with appropriate transformations:
Compute a highly oscillatory integral with a singularity at the origin:
Fourier integral finite range:
Fourier integral finite range:
Fourier integral infinite range:
BesselJ integral infinite range:
Piecewise oscillatory integral:
Compute a 10-dimensional integral using adaptive Monte Carlo integration:
Find the volume of the unit ball in 5 dimensions:
 Options   (10)
The AccuracyGoal option can be used to change the default absolute tolerance:
The integration process stops once the accuracy goal criterion has been exceeded:
The result with the default settings is different since the default uses only a precision criterion:
Get the number of evaluation points used in a numerical integration:
Show the evaluation points used in a numerical integration:
Integration by excluding the curves on which the integrand's denominator is zero:
The curves on which the integrand is singular:
Stop integration after a specified number of points has been exceeded:
Without enough adaptive recursion, the following gives a poor result:
Specifying a larger value for MaxRecursion gives a much better result:
Specifying the singularity locations is even more efficient:
Timing for the default multidimensional rule:
Using a higher-order multidimensional rule is faster:
NIntegrate may miss sharp peaks of integrands:
Increasing MinRecursion forces a finer subdivision of the integration region:
The number of samples used to evaluate for different relative tolerances:
The number of samples needed typically increases exponentially with the PrecisionGoal:
NIntegrate can compute integrals using higher working precision:
The PrecisionGoal used is 10 less than the WorkingPrecision:
 Applications   (3)
This finds the 3 quartile of the NormalDistribution using NIntegrate and FindRoot:
This finds the 3 quartile of the NormalDistribution using Quantile:
Use Green's theorem to find the area of a parametrically defined two-dimensional region:
Find the Fourier coefficients of a periodic function on :
Show the difference between the function and the Fourier series:
When a closed-form solution is available, Integrate can be used instead of NIntegrate:
The result of NIntegrate is close to the exact value:
NDSolve can be used instead of NIntegrate:
NIntegrate will typically give a more precise result since it uses global error control:
Approximate the tail of a sum using the Euler-Maclaurin formula:
The Euler-Maclaurin formula approximation compares well with the exact result:
The Euler-Maclaurin method of NSum uses Integrate or NIntegrate:
Find a cumulative distribution function from a probability distribution function:
CDF gives the same result:
The Residue of a function at a pole is equivalent to a contour integral:
Numerically integrate on a contour that includes the real axis from - to :
Several special functions are defined as integrals:
For high precision, using the special function is usually preferable:
For integrands with complicated variation, many levels of adaptive recursion may be required:
Specifying higher recursive subdivision levels gives a convergent result:
Since the default is to use relative tolerance, integrals that are zero may be computed slowly:
Specifying an absolute tolerance with AccuracyGoal will reduce the amount of work:
Higher-dimensional cubature-based integration to default precision may be slow:
Decreasing the PrecisionGoal speeds up the computation:
Using a quasi Monte Carlo method for the same low PrecisionGoal may be even faster:
NIntegrate automatically uses Monte Carlo integration for dimensions higher than :
It can be time-consuming to compute functions symbolically:
Restricting the function definition avoids symbolic evaluation:
Sampling points for a 3-dimensional integration, using a low-order method: