Approximate a definite integral using composite Simpson's 1/3 rule with n subintervals.
Simpson's 1/3 rule approximates ∫f(x)dx by fitting quadratic polynomials through consecutive triplets of points. The composite version splits [a,b] into n equal subintervals (n must be even) and applies the basic rule to each pair. Error is O(h⁴), making it much more accurate than the trapezoidal rule for the same n.
Simpson's 1/3 rule
∫[a,b]f(x)dx ≈ (h/3)[f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + ... + f(xₙ)]
Simpson's rule uses pairs of subintervals (triplets of points) to fit parabolas. An odd n would leave an unpaired subinterval.
The error is proportional to h⁴·f''''(c) for some c in [a,b]. Doubling n reduces error by a factor of 16.