Numerical Integration Learning Platform

Learn Numerical Integration with interactive visualization, step-by-step calculations, dynamic graphs, and automatic solutions.

x₀ x₁ x₂ x₃ ∫ f(x) dx ≈ Area

Core Approximation Methods

Trapezoidal Rule

Approximates the area under a curve using 1st-degree linear interpolations (trapezoids). Works with any number of intervals.

Simpson's 1/3 Rule

Approximates the area using 2nd-degree quadratic curves (parabolas). Offers higher accuracy, but requires an even number of subintervals.

Simpson's 3/8 Rule

Approximates the area using 3rd-degree cubic segments. Requires the number of subintervals to be a multiple of 3.

Step-by-Step Solutions

Not just answers, but detailed, pedagogical steps including finding step size $h$, computing the points tables, and substituting terms.

Interactive Visualizations

Plotly integration displays the function curve and plots the precise geometric boundaries to visualize the approximation area.

Academic Standards

Formula derivations and layouts modeled directly on university mathematical syllabi and Newton-Cotes formulations.

Theoretical Foundations

What is Integration?

Integration is the mathematical process used to find the total accumulation of a quantity. Most commonly, it represents the area under a curve on a graph.

Indefinite Integral

Gives a family of functions plus an integration constant $C$. It has no defined boundaries.

$$\int f(x) \, dx = F(x) + C$$

Definite Integral

Gives a specific numerical value. It is evaluated between defined boundaries, from $a$ to $b$.

$$\int_{a}^{b} f(x) \, dx = [F(x)]_{a}^{b} = F(b) - F(a)$$

Numerical Integration

Numerical integration is a branch of numerical analysis that provides algorithms for estimating the value of a definite integral when analytical solutions are difficult or impossible to calculate.

The area under a curve is approximated by dividing the interval $[a, b]$ into $n$ smaller sections and approximating each section using simpler geometric shapes:

  • Rectangles: 0th-degree polynomial representation
  • Trapezoids: 1st-degree polynomial representation
  • Parabolic segments: 2nd-degree polynomial representation

Why Use Numerical Integration?

  1. The function has no analytical closed-form integral (e.g. $e^{x^2}$ or $\frac{\sin x}{x}$).
  2. The function is too complex to integrate analytically.
  3. The data is given in tabular or experimental form (i.e. only discrete coordinates $(x_i, y_i)$ are known, not the overall equation).
  4. Computer-based calculations require numerical approximations.

Comparison: Analytical vs. Numerical Integration

Aspect Analytical Integration Numerical Integration
Precision Gives the exact value using mathematical formulas Gives an approximate value using calculations
Input Requirements Requires a known, differentiable mathematical function Works with complex formulas or tabulated discrete coordinates
Difficulty Can be extremely difficult or impossible for complicated functions Uniformly simple, computer-friendly arithmetic steps
Result Output Provides symbolic function formulas or exact values Provides numerical values rounded to required decimals

Derivation of the General Newton-Cotes Formula

The main closed-form methods of numerical integration are derived from the Newton–Cotes Quadrature Formulas. These approximate the value of an integral by replacing the actual function $f(x)$ with an interpolating polynomial $P_n(x)$ of degree $n$ over equally spaced points.


Mathematical Derivation Steps

Let $y = f(x)$ be a function evaluated at $n+1$ equally spaced partition points $x_0, x_1, x_2, \dots, x_n$ where $x_i = x_0 + ih$, and $h$ is the step size:

$$h = \frac{b - a}{n}$$

Let's evaluate the definite integral:

$$I = \int_{a}^{b} f(x) \, dx = \int_{x_0}^{x_0 + nh} f(x) \, dx$$

We replace $f(x)$ with Newton's Forward Difference Interpolation Formula:

$$f(x) \approx y_0 + r \Delta y_0 + \frac{r(r-1)}{2!} \Delta^2 y_0 + \frac{r(r-1)(r-2)}{3!} \Delta^3 y_0 + \dots$$

where $x = x_0 + rh$, which gives $dx = h \, dr$.

Changing the limits of integration from $x$ to $r$:

  • If $x = x_0$, then $r = 0$
  • If $x = x_0 + nh$, then $r = n$

Substituting these into the definite integral:

$$I = \int_{0}^{n} \left[ y_0 + r \Delta y_0 + \frac{r(r-1)}{2} \Delta^2 y_0 + \frac{r(r-1)(r-2)}{6} \Delta^3 y_0 + \dots \right] h \, dr$$

Integrating this term-by-term with respect to $r$ over the interval $[0, n]$:

$$I = h \left[ r y_0 + \frac{r^2}{2} \Delta y_0 + \left( \frac{r^3}{6} - \frac{r^2}{4} \right) \Delta^2 y_0 + \left( \frac{r^4}{24} - \frac{r^3}{6} + \frac{r^2}{4} \right) \Delta^3 y_0 + \dots \right]_0^n$$

Applying the limits $0$ and $n$ and simplifying by factoring out $n$:

$$I = nh \left[ y_0 + \frac{n}{2} \Delta y_0 + \frac{n(2n-3)}{12} \Delta^2 y_0 + \frac{n(n-2)^2}{24} \Delta^3 y_0 + \dots \right]$

This is the General Newton–Cotes Quadrature Formula (or General Quadrature Formula). By setting $n = 1, 2,$ or $3$, we derive the specific integration rules.

Closed vs. Open Form Formulas

If the integration limits $a$ and $b$ are part of the interpolating point set ($x_0 = a$ and $x_n = b$), the formula is Closed Form (e.g. Trapezoidal, Simpson's Rules). If the integration limits lie outside the interpolating points, the formula is Open Form.

n = 1

1. Trapezoidal Rule (Two-Point Formula)

Derived by setting $n = 1$ in the General Newton-Cotes formula, assuming the curve is a straight line $y = Ax + B$ in each subinterval.

Derivation Detail

For $n = 1$, the general formula is integrated over a single interval $[x_0, x_1]$:

$$\int_{x_0}^{x_1} f(x) \, dx = h \left[ y_0 + \frac{1}{2} \Delta y_0 \right] = h \left[ y_0 + \frac{1}{2} (y_1 - y_0) \right] = \frac{h}{2}(y_0 + y_1)$$

Summing across all $n$ subintervals (Composite form):

$$I \approx \frac{h}{2} \left[ (y_0 + y_1) + (y_1 + y_2) + \dots + (y_{n-1} + y_n) \right]$$
$$I \approx \frac{h}{2} \left[ y_0 + y_n + 2(y_1 + y_2 + \dots + y_{n-1}) \right]$$
Advantages
  • Extremely simple to derive and calculate.
  • Can be used with any number of subintervals $n \ge 1$.
Disadvantages
  • Lower accuracy (local error order is $O(h^3)$, global error order is $O(h^2)$).
  • Rough linear approximations can overshoot/undershoot highly curved functions.
n = 2

2. Simpson's 1/3 Rule (Three-Point Formula)

Derived by setting $n = 2$ in the General Newton-Cotes formula, replacing the curve in each pair of intervals with a second-degree quadratic parabola.

Derivation Detail

Integrating over two adjacent intervals $[x_0, x_2]$ (setting $n=2$):

$$\int_{x_0}^{x_2} f(x) \, dx = 2h \left[ y_0 + \frac{2}{2} \Delta y_0 + \frac{2(4-3)}{12} \Delta^2 y_0 \right] = 2h \left[ y_0 + (y_1 - y_0) + \frac{1}{6} (y_2 - 2y_1 + y_0) \right]$$
$$\int_{x_0}^{x_2} f(x) \, dx = \frac{h}{3} (y_0 + 4y_1 + y_2)$$

Extending this to multiple subintervals. Because we require groups of two subintervals, the total number of subintervals $n$ must be even.

$$I \approx \frac{h}{3} \left[ y_0 + y_n + 4(y_1 + y_3 + \dots + y_{n-1}) + 2(y_2 + y_4 + \dots + y_{n-2}) \right]$$
Advantages
  • Highly accurate: local error is $O(h^5)$, global error is $O(h^4)$.
  • Exact for polynomials up to degree 3.
Disadvantages
  • Strict structural constraint: $n$ must be even.
  • Cannot be used directly with odd datasets.
n = 3

3. Simpson's 3/8 Rule (Four-Point Formula)

Derived by setting $n = 3$ in the General Newton-Cotes formula, replacing the curve in each group of three intervals with a third-degree cubic polynomial.

Derivation Detail

Integrating over three adjacent intervals $[x_0, x_3]$ (setting $n=3$):

$$\int_{x_0}^{x_3} f(x) \, dx = \frac{3h}{8} (y_0 + 3y_1 + 3y_2 + y_3)$$

For composite applications, we group by intervals of 3, meaning the total number of subintervals $n$ must be a multiple of 3.

$$I \approx \frac{3h}{8} \left[ y_0 + y_n + 3(y_1 + y_2 + y_4 + y_5 + \dots + y_{n-1}) + 2(y_3 + y_6 + \dots + y_{n-3}) \right]$$
Advantages
  • Uses cubic approximations, which model cubic curves exactly.
  • Very high local error accuracy $O(h^5)$.
Disadvantages
  • Strict structural constraint: $n$ must be a multiple of 3.
  • Slightly more complex arithmetic coefficients.

Comparison Matrix of Methods

Method Name Degree of Interpolating Polynomial Number of Intervals ($n$) Required Formula Global Error Order
Trapezoidal Rule 1 (Linear) Any integer ($n \ge 1$) $I \approx \frac{h}{2}[(y_0 + y_n) + 2\sum y_{rem}]$ $O(h^2)$
Simpson's 1/3 Rule 2 (Quadratic) Must be Even ($n \ge 2$) $I \approx \frac{h}{3}[(y_0 + y_n) + 4\sum y_{odd} + 2\sum y_{even}]$ $O(h^4)$
Simpson's 3/8 Rule 3 (Cubic) Must be Multiple of 3 ($n \ge 3$) $I \approx \frac{3h}{8}[(y_0 + y_n) + 3\sum y_{\text{not div 3}} + 2\sum y_{\text{div 3}}]$ $O(h^4)$