Integration

Newton-Cotes Integration

Approximating integrals when antiderivatives are unknown.

1

Introduction

Why Numerical Integration?

  • Often $f(x)$ is only known at discrete points (data).
  • The antiderivative $F(x)$ may not exist in closed form (e.g., $e^{-x^2}$).
  • We need to compute integrals quickly for real-time applications.
Integral Area

Area under the curve.

Riemann Sums Recap

Lower Sum

Lower Sum ($m_i$)

Upper Sum

Upper Sum ($M_i$)

$L(f;P) \leq \int_{a}^{b} f(x)\,dx \leq U(f;P)$

2

The Trapezoid Rule

Instead of rectangles (constant approximation), let's use a linear approximation (Trapezoids).

Basic Trapezoid

Basic Formula

$\int_a^b f(x) \,dx \approx \frac{b-a}{2}(f(a)+f(b))$

Area of a trapezoid: avg height $\times$ width.

Composite Trapezoid Rule

Break the interval $[a,b]$ into $n$ sub-intervals of width $h = (b-a)/n$. Apply the trapezoid rule to each.

$T(f;P) = \frac{h}{2} \left[ f(x_0) + 2\sum_{i=1}^{n-1} f(x_i) + f(x_n) \right]$
Composite Trapezoid

Error Analysis

Error = $-\frac{(b-a) h^2}{12} f''(\eta) = \mathcal{O}(h^2)$

Convergence is quadratic. Halving $h$ reduces error by 4.

3

Simpson's Rule

Can we do better? Yes, use a Quadratic Approximation (Parabola) over pairs of intervals.

Basic Simpson

Basic Formula (1/3 Rule)

$\int_a^b f(x)\,dx \approx \frac{h}{3}\left[f(a) + 4f(\frac{a+b}{2}) + f(b)\right]$

Requires 3 points (2 intervals of width $h$).

Composite Simpson's Rule

Sum over $n/2$ pairs of intervals.

$\int_a^b f(x) \approx \frac{h}{3} \left[ f(a) + f(b) + 4\sum_{\text{odd } i} f(x_i) + 2\sum_{\text{even } i} f(x_i) \right]$

Error Analysis

Error = $-\frac{(b-a) h^4}{180} f^{(4)}(\xi) = \mathcal{O}(h^4)$

Huge Win: Two orders of magnitude better than Trapezoid!

4

Newton-Cotes Summary

Rule Points ($n$) Formula Error Order
Trapezoid 2 $\frac{h}{2}(f_0 + f_1)$ $\mathcal{O}(h^2)$
Simpson's 1/3 3 $\frac{h}{3}(f_0 + 4f_1 + f_2)$ $\mathcal{O}(h^4)$
Simpson's 3/8 4 $\frac{3h}{8}(f_0 + 3f_1 + 3f_2 + f_3)$ $\mathcal{O}(h^4)$
Boole's 5 $\frac{2h}{45}(7f_0 + 32f_1 + 12f_2 + 32f_3 + 7f_4)$ $\mathcal{O}(h^6)$

🧠 Final Challenge +20 XP

Why does Simpson's Rule generally provide a much better approximation than the Trapezoid Rule for the same step size $h$?