Numerical integration, in some instances also known as numerical quadrature, asks for the value of a definite integral. Popular methods use one of the Newton–Cotes formulas (such as midpoint rule or Simpson's rule) or Gaussian quadrature. These methods rely on a "divide and conquer" strategy, whereby an integral on a relatively large set is broken down into integrals on smaller sets. In higher dimensions, where these methods become prohibitively expensive in terms of computational effort, one may use other methods such as the Monte Carlo method. Here, we will study a very simple approximation technique, called a trapezoidal rule.
Trapezoidal rule
The trapezoidal rule (also known as the trapezoid rule or trapezium rule) is a technique for approximating the definite integral
The trapezoidal rule tends to become extremely accurate when periodic functions are integrated over their periods.
Approximation by Linear Functions
The function
Numerical Implementation of the Trapezoidal Rule
For a domain discretized into
Although the method can adopt a nonuniform grid as well, this example used a uniform grid for the the approximation.