Return to Computer Vision Notebooks

Numerical Integration



Overview and implementation of some numerical methods for definite integration.

Definite Integral


$$ \large f(x)=x^3-4x^2+4x+2 $$

analytical integration

$$ \large I=\int_{a}^{b}f(x) \, dx =\int_{a}^{b}(x^3-4x^2+4x+2) \, dx $$

Given $\large a=\frac{1}{2}$ and $\large b=\frac{5}{2}$,

$$ \large I=\left.\left(\frac{x^4}{4}-\frac{4x^3}{3}+2x^2+2x\right)\right|_a^b = \frac{61}{12} \approx 5.0833 $$

1. Rectangle rule


rectangle left-hand point

rectangle right-hand point

rectangle middle point

2. Trapezoidal rule


trapezoidal

3. Comparing to Ground Truth


comparing ground truth