Trapezoidal rule to approximate integrals
In this article we approximate integrals by the trapezoidal rule.
- One dimensional integrals
Let [math] [a,b] [/math] be an interval and [math] f:[a,b]\to \mathbb{R} [/math] a real function. We want to approximate the integral [math] \int_a^bf(u) \; du [/math].
Consider a partition of the interval [math] [a,b] [/math] in [math] N [/math] equal subintervals of length [math] h=\frac{b-a}{N} [/math], given by [math] u_n=a+nh, [/math] where [math] n=0,1,...,N [/math]. The trapezoidal rule is as follows: [math] \int_a^b f(u) \; du \sim \frac12 f(u_0)+\sum_{i=1}^{N-1}f(u_i)+\frac12 f(u_N) [/math] that can be written as [math] \int_a^b f(u) \; du \sim \sum_{i=0}^{N}w_if(u_i), [/math] where [math] w_i [/math] are the components of the weight vector [math] w=(1/2,1,1,...,1,1,1/2) [/math].