maths.freeNumerical Methods › Numerical integration: trapezoid and Simpson

Numerical integration: trapezoid and Simpson

Approximating an integral from sampled values, with error bounds.

The trapezoid rule joins samples with straight lines (error ∝ h²); Simpson's rule uses parabolas (error ∝ h⁴). Picture it: the area under the curve chopped into strips. Think it: both are exact for polynomials up to a degree, and Richardson extrapolation combines them to cancel error terms.

Esempio di funzionamento: integrate e^(-x^2) dx from 0 to 1

Integrate e^(-x^2) from 0 to 1

\int_{0}^{1} e^{- x^{2}}\, dx

Passo dopo passo

  1. \int_{0}^{1} e^{- x^{2}}\, dx

    First find an antiderivative F, then evaluate F(b) − F(a).

  2. \int e^{- x^{2}}\, dx = \frac{\sqrt{\pi} \operatorname{erf}{\left(x \right)}}{2}

    Erf rule.

  3. F(1) - F(0) = \left(\frac{\sqrt{\pi} \operatorname{erf}{\left(1 \right)}}{2}\right) - \left(0\right)

    Fundamental theorem of calculus: plug in the limits.

  4. = \frac{\sqrt{\pi} \operatorname{erf}{\left(1 \right)}}{2} \approx 0.74682

    Simplify.

Rivela la risposta
\frac{\sqrt{\pi} \operatorname{erf}{\left(1 \right)}}{2}

Symbols used here

\int f(x)\,dx,\ \int_a^b
integral
Antiderivative (indefinite) or signed area from a to b (definite).
\sqrt{x},\ \sqrt[n]{x}
square root, n-th root
The non-negative number whose square (n-th power) is x.
\pi
pi
Ratio of a circle's circumference to its diameter, 3.14159…
e
Euler's number
2.71828…, the base whose exponential is its own derivative.
\approx
approximately equal
Equal to the precision shown, not exactly.
\leq,\ \geq
less/greater than or equal
Inequalities that allow equality; < and > exclude it.
f'(x),\ \frac{dy}{dx}
derivative
Instantaneous rate of change; slope of the graph.
O(n^2),\ \Theta,\ \Omega
big-O notation
Grows no faster than n² (up to a constant), for large n.
x_{n+1} = x_n - \frac{f(x_n)}{f\'(x_n)}
Newton iteration
The next approximation follows the tangent to the axis.

How to: Numerical integration: trapezoid and Simpson

  1. First find an antiderivative F, then evaluate F(b) − F(a).
  2. Erf rule.
  3. Fundamental theorem of calculus: plug in the limits.
  4. Simplify.

Questions people ask

Why not just solve exactly?

Most equations have no closed-form solution at all, and many that do are unusable in practice. A numerical method delivers as many correct digits as you need, and a good one tells you how many that is.

Why can Newton's method fail?

If it starts where the tangent is nearly flat it shoots far away; near a repeated root it slows to a crawl; and with several roots it may land on the wrong one. A bracketing method like bisection is slower but cannot fail.

Prova il tuo

Più in Numerical Methods