Mathematics.

numerical integration

Numerical Integration

Numerical Analysis25 minDifficulty3 out of 10

You should know: integral, numerical methods

Overview

Numerical integration, or quadrature, approximates the value of a definite integral ∫ₐᵇ f(x) dx when no closed-form antiderivative exists, or when f is known only from discrete data points. The core idea is to replace the integrand by a simple approximating function — a constant, a line, or a low-degree polynomial — over small subintervals, integrate that approximation exactly, and sum the pieces. The two most common elementary rules, the trapezoidal rule and Simpson's rule, arise from approximating f by piecewise linear and piecewise quadratic interpolants respectively. Quadrature underlies computations from areas under experimental curves to probability calculations to solving differential equations.

Intuition

Imagine trying to find the area under an irregular curve without a formula for it — you can approximate that area with shapes you already know how to measure. Slice the region into narrow vertical strips; over each strip, replace the curve with something simple (a flat top, a slanted top, or a gentle arc) whose area you can compute exactly, then add the strips up. The narrower the strips and the better the local approximation, the closer the total gets to the true area — this trade-off between how many pieces you use and how well each piece fits is the entire game of numerical quadrature.

Formal Definition

Definition

Partition [a, b] into n subintervals of width h = (b−a)/n with nodes xᵢ = a + ih, and approximate the integral by a weighted sum of function values fᵢ = f(xᵢ):

abf(x)dxi=0nwif(xi)\int_a^b f(x)\,dx \approx \sum_{i=0}^{n} w_i f(x_i)
General quadrature rule form
abf(x)dxh2[f0+2i=1n1fi+fn]\int_a^b f(x)\,dx \approx \dfrac{h}{2}\Big[f_0 + 2\sum_{i=1}^{n-1}f_i + f_n\Big]
Composite trapezoidal rule (n subintervals)
abf(x)dxh3[f0+4 ⁣ ⁣i odd ⁣ ⁣fi+2 ⁣ ⁣i even,i0,n ⁣ ⁣fi+fn]\int_a^b f(x)\,dx \approx \dfrac{h}{3}\Big[f_0 + 4\!\!\sum_{i \text{ odd}}\!\! f_i + 2\!\!\sum_{i \text{ even}, i\ne 0,n}\!\! f_i + f_n\Big]
Composite Simpson's rule (n even)

Worked Examples

  1. Step size h = (1−0)/2 = 0.5; nodes x = 0, 0.5, 1.

    h=0.5h = 0.5
  2. Function values: f(0) = e⁰ = 1, f(0.5) = e^{0.5} ≈ 1.648721, f(1) = e ≈ 2.718282.

    f0=1,  f1=1.648721,  f2=2.718282f_0 = 1,\; f_1 = 1.648721,\; f_2 = 2.718282
  3. Apply the trapezoidal formula (h/2)[f₀ + 2f₁ + f₂].

    0.52[1+2(1.648721)+2.718282]=0.25[1+3.297442+2.718282]=0.25(7.015724)=1.753931\tfrac{0.5}{2}\big[1 + 2(1.648721) + 2.718282\big] = 0.25\,[1 + 3.297442 + 2.718282] = 0.25(7.015724) = 1.753931
  4. Exact value is e − 1 ≈ 1.718282, so the trapezoidal estimate overshoots by about 0.0357 (about 2.1%).

    01exdx=e11.718282\int_0^1 e^x\,dx = e - 1 \approx 1.718282

Answer: Trapezoidal estimate ≈ 1.753931 vs. exact ≈ 1.718282 (overestimate, since eˣ is convex).

Practice Problems

Difficulty 3/10

Approximate ∫₀¹ x³ dx using the trapezoidal rule with n = 1 (a single trapezoid). Compare to the exact value.

Difficulty 5/10

Water flow rate (m³/s) measured at 1-second intervals over 4 seconds is 2, 3, 5, 4, 2. Use the composite trapezoidal rule to estimate the total volume that passed.

Difficulty 4/10

Numerical quadrature methods are most useful when:

Quiz

The general strategy behind numerical quadrature is to:
The trapezoidal rule approximates the integrand on each subinterval with a:
For a convex function like eˣ, the trapezoidal rule tends to:

Summary

  • Numerical integration approximates ∫f(x)dx by replacing the integrand with simple pieces (constant, linear, quadratic) that are integrated exactly and summed.
  • It is essential when no elementary antiderivative exists or when f is known only from sampled data.
  • The trapezoidal and Simpson's rules are the most common elementary quadrature schemes, differing in the degree of the local approximating polynomial.

References