In

numerical analysisNumerical analysis is the study of algorithms that use numerical approximation for the problems of mathematical analysis ....

,

**numerical integration** constitutes a broad family of algorithms for calculating the numerical value of a definite

integralIntegration is an important concept in mathematics and, together with its inverse, differentiation, is one of the two main operations in calculus...

, and by extension, the term is also sometimes used to describe the

numerical solution of differential equationsNumerical ordinary differential equations is the part of numerical analysis which studies the numerical solution of ordinary differential equations...

. This article focuses on calculation of definite integrals. The term

**numerical quadrature** (often abbreviated to

*quadrature*Quadrature — historical mathematical term which means calculating of the area. Quadrature problems have served as one of the main sources of mathematical analysis.- History :...

) is more or less a synonym for

*numerical integration*, especially as applied to one-dimensional integrals. Numerical integration over more than one dimension is sometimes described as

**cubature**, although the meaning of

*quadrature* is understood for higher dimensional integration as well.

The basic problem considered by numerical integration is to compute an approximate solution to a definite integral:

If is a smooth well-behaved function, integrated over a small number of dimensions and the limits of integration are bounded, there are many methods of approximating the integral with arbitrary precision.

## Reasons for numerical integration

There are several reasons for carrying out numerical integration.

The integrand

*f(x)* may be known only at certain points,

such as obtained by

samplingIn statistics and survey methodology, sampling is concerned with the selection of a subset of individuals from within a population to estimate characteristics of the whole population....

.

Some embedded systems and other computer applications may need numerical integration for this reason.

A formula for the integrand may be known, but it may be difficult or impossible to find an

antiderivativeIn calculus, an "anti-derivative", antiderivative, primitive integral or indefinite integralof a function f is a function F whose derivative is equal to f, i.e., F ′ = f...

which is an elementary function. An example of such an integrand is

*f(x)* = exp(−

*x*^{2}), the antiderivative of which (the

error functionIn mathematics, the error function is a special function of sigmoid shape which occurs in probability, statistics and partial differential equations...

, times a constant) cannot be written in elementary form.

It may be possible to find an antiderivative symbolically, but it may be easier to compute a numerical approximation than to compute the antiderivative. That may be the case if the antiderivative is given as an infinite series or product, or if its evaluation requires a special function which is not available.

## Methods for one-dimensional integrals

Numerical integration methods can generally be described as combining evaluations of the integrand to get an approximation to the integral. The integrand is evaluated at a finite set of points called

**integration points** and a weighted sum of these values is used to approximate the integral. The integration points and weights depend on the specific method used and the accuracy required from the approximation.

An important part of the analysis of any numerical integration method is to study the behavior of the approximation error as a function of the number of integrand evaluations.

A method which yields a small error for a small number of evaluations is usually considered superior.

Reducing the number of evaluations of the integrand reduces the number of arithmetic operations involved,

and therefore reduces the total

round-off errorA round-off error, also called rounding error, is the difference between the calculated approximation of a number and its exact mathematical value. Numerical analysis specifically tries to estimate this error when using approximation equations and/or algorithms, especially when using finitely many...

.

Also,

each evaluation takes time, and the integrand may be arbitrarily complicated.

A 'brute force' kind of numerical integration can be done, if the integrand is reasonably well-behaved (i.e.

piecewiseOn mathematics, a piecewise-defined function is a function whose definition changes depending on the value of the independent variable...

continuousIn mathematics, a continuous function is a function for which, intuitively, "small" changes in the input result in "small" changes in the output. Otherwise, a function is said to be "discontinuous". A continuous function with a continuous inverse function is called "bicontinuous".Continuity of...

and of

bounded variationIn mathematical analysis, a function of bounded variation, also known as a BV function, is a real-valued function whose total variation is bounded : the graph of a function having this property is well behaved in a precise sense...

), by evaluating the integrand with very small increments.

### Quadrature rules based on interpolating functions

A large class of quadrature rules can be derived by constructing

interpolatingIn the mathematical field of numerical analysis, interpolation is a method of constructing new data points within the range of a discrete set of known data points....

functions which are easy to integrate. Typically these interpolating functions are

polynomialIn mathematics, a polynomial is an expression of finite length constructed from variables and constants, using only the operations of addition, subtraction, multiplication, and non-negative integer exponents...

s.

The simplest method of this type is to let the interpolating function be a constant function (a polynomial of degree zero) which passes through the point ((

*a*+

*b*)/2,

*f*((

*a*+

*b*)/2)). This is called the

*midpoint rule* or

*rectangle rule*In mathematics, specifically in integral calculus, the rectangle method computes an approximation to a definite integral, made by finding the area of a collection of rectangles whose heights are determined by the values of the function.Specifically, the interval over which the function is to be...

.

The interpolating function may be an affine function (a polynomial of degree 1)

which passes through the points (

*a*,

*f*(

*a*)) and (

*b*,

*f*(

*b*)).

This is called the

*trapezoidal rule*.

For either one of these rules, we can make a more accurate approximation by breaking up the interval [

*a*,

*b*] into some number

*n* of subintervals, computing an approximation for each subinterval, then adding up all the results. This is called a

*composite rule*,

*extended rule*, or

*iterated rule*. For example, the composite trapezoidal rule can be stated as

where the subintervals have the form [

*k* *h*, (

*k*+1)

*h*], with

*h* = (

*b*−

*a*)/

*n* and

*k* = 0, 1, 2, ...,

*n*−1.

Interpolation with polynomials evaluated at equally spaced points in [

*a*,

*b*] yields the Newton–Cotes formulas, of which the rectangle rule and the trapezoidal rule are examples.

Simpson's ruleIn numerical analysis, Simpson's rule is a method for numerical integration, the numerical approximation of definite integrals. Specifically, it is the following approximation:...

, which is based on a polynomial of order 2, is also a Newton–Cotes formula.

Quadrature rules with equally spaced points have the very convenient property of

*nesting*. The corresponding rule with each interval subdivided includes all the current points, so those integrand values can be re-used.

If we allow the intervals between interpolation points to vary, we find another group of quadrature formulas, such as the

Gaussian quadratureIn numerical analysis, a quadrature rule is an approximation of the definite integral of a function, usually stated as a weighted sum of function values at specified points within the domain of integration....

formulas. A Gaussian quadrature rule is typically more accurate than a Newton–Cotes rule which requires the same number of function evaluations, if the integrand is

smoothIn mathematical analysis, a differentiability class is a classification of functions according to the properties of their derivatives. Higher order differentiability classes correspond to the existence of more derivatives. Functions that have derivatives of all orders are called smooth.Most of...

(i.e., if it is sufficiently differentiable) Other quadrature methods with varying intervals include Clenshaw–Curtis quadrature (also called Fejér quadrature) methods.

Gaussian quadrature rules do not nest, but the related Gauss–Kronrod quadrature formulas do. Clenshaw–Curtis rules nest.

### Adaptive algorithms

If

*f(x)* does not have many derivatives at all points, or if the derivatives become large, then Gaussian quadrature is often insufficient. In this case, an algorithm similar to the following will perform better: