舞動數學

Trapezoidal Rule for Numerical Integration

Trapezoidal Rule for Numerical Integration

The Trapezoidal Rule approximates the integral of a function by dividing the area under the curve into trapezoids.
Area=$\frac{1}{2}(a+h)h$
$f(x)=x^3+2x^2+3x+4$
$\displaystyle \int_a^b f(x)dx \approx \sum_{i=0}^{n-1} \frac{1}{2}\left( f(x_i)+f(x_{i+1}) \right) (x_{i+1}-x_i)$
Actual integral value=297.08
n=6
Sum of the areas of trapezoids=305.00
ERROR=7.92
n=11
Sum of the areas of trapezoids=299.06
ERROR=1.98
n=101
Sum of the areas of trapezoids=297.10
ERROR=0.02
As the number of trapezoids increases, the approximation of the integral becomes more accurate.

製作人:林宇星