Trapezoidal & Simpson's 1/3 Rule

Approximate definite integrals \(\int_a^b f(x)\,dx\) using linear trapezoids (\(O(h^2)\)) and quadratic parabolic arcs (\(O(h^4)\)) over \(n\) subintervals.

Integrand \(f(x)\) & Quadrature Geometry

f(x) Trapezoids Simpson parabolic arcs

Subinterval Weights Table

Error vs Subintervals \(n\) (Log Scale)

Scilab & Python Code (Minimal Exam-Ready)

Quadrature Formulas (\(h = \frac{b-a}{n}\))

Trapezoidal Rule:

$$ I_T = \frac{h}{2}\left[y_0 + 2(y_1 + y_2 + \dots + y_{n-1}) + y_n\right] $$

Simpson's 1/3 Rule (\(n\) even):

$$ I_S = \frac{h}{3}\left[y_0 + 4(y_1 + y_3 + \dots + y_{n-1}) + 2(y_2 + y_4 + \dots + y_{n-2}) + y_n\right] $$

Accuracy Comparison

  • Trapezoidal: Error is \(O(h^2) \propto -\frac{(b-a)h^2}{12}f''(\xi)\); exact for linear functions.
  • Simpson's 1/3: Error is \(O(h^4) \propto -\frac{(b-a)h^4}{180}f^{(4)}(\xi)\); exact for cubics too!