Numerical Integration
- Approximates a definite integral by summing areas of simple shapes over subintervals.
- Common simple methods are the rectangle (Riemann sum) and trapezoid rules, which divide the interval into pieces and sum areas.
- These basic rules are easy to implement but can be inaccurate for functions with a lot of curvature; more advanced methods exist for improved accuracy.
Definition
Section titled “Definition”Numerical integration is a method of approximating the definite integral of a function. It is used when a function’s integral cannot be expressed in closed form, so we approximate the integral numerically.
Explanation
Section titled “Explanation”Numerical integration works by dividing the interval of integration into subintervals and approximating the area under the curve on each subinterval with a simple geometric shape (for example, a rectangle or trapezoid). The areas of those shapes are summed to produce an approximation of the definite integral.
Two common approaches:
- Rectangular integration (rectangle rule or left/right Riemann sum): each subinterval is approximated by a rectangle whose height is the function value at a chosen point within the subinterval and whose width is the subinterval length.
- Trapezoidal integration (trapezoid rule): each subinterval is approximated by a trapezoid whose height is the average of the function values at the subinterval endpoints and whose width is the subinterval length.
When a function has substantial curvature, rectangular and trapezoidal rules may be insufficiently accurate; methods such as Simpson’s rule or Gaussian quadrature can provide better approximations.
Examples
Section titled “Examples”Rectangular integration (rectangle rule / Riemann sum)
Section titled “Rectangular integration (rectangle rule / Riemann sum)”Consider the function
from (x = 0) to (x = 2). Divide the region into four equal intervals. The function values at these intervals are 0, 1, 4, and 9. The interval width is 0.5. The area of each rectangle is the function value times the interval width; the sum of these four rectangles is the approximate value of the integral.
Trapezoidal integration (trapezoid rule)
Section titled “Trapezoidal integration (trapezoid rule)”Using the same function
from (x = 0) to (x = 2) divided into four equal intervals, the function values at these intervals are 0, 1, 4, and 9. For each interval, the height of the trapezoid is the average of the function values at the two endpoints, and the width is the interval length. The sum of the areas of the four trapezoids is the approximate value of the integral.
Use cases
Section titled “Use cases”- Apply numerical integration when a function’s integral cannot be expressed in a closed form and an approximation is required.
Notes or pitfalls
Section titled “Notes or pitfalls”- Rectangular and trapezoidal rules are easy to implement but can be inaccurate for functions with a lot of curvature.
- For such functions, more advanced methods (for example, Simpson’s rule or Gaussian quadrature) may yield better accuracy.
Related terms
Section titled “Related terms”- Rectangle rule
- Left/right Riemann sum
- Trapezoid rule
- Simpson’s rule
- Gaussian quadrature