Originally Posted by

**Ackbeet** Whoops. I forgot the factor of two. It should be the following:

$\displaystyle \displaystyle{\int_{x_{1}}^{x_{N}}f(x)\,dx=\frac{x _{N}-x_{1}}{2N}(y_{1}+2y_{2}+2y_{3}+\dots+2y_{N-1}+y_{N})}.$

Here is the explanation of this formula: the LHS is merely a symbol representing, in this case, the area under all the piecewise linear functions (another way to think of it: it's the sum of all the areas of the trapezoids).

The RHS of this formula shows you how to compute that area. To get this formula, merely note that the width of each trapezoid is equal to the width of the whole interval divided by the number of intervals, which is

$\displaystyle \displaystyle{\frac{x_{N}-x_{1}}{N}}.$

Now, the area of the jth trapezoid is given by (merely translating the formula you gave me):

$\displaystyle \displaystyle{\frac{x_{N}-x_{1}}{N}\left(\frac{y_{j}+y_{j+1}}{2}\right)}.$

You can think of this expression as the width times the average of the heights on the right and left sides of the subinterval. Does this make sense?

Now, if I add all those areas up, I get this:

$\displaystyle \displaystyle{\frac{x_{N}-x_{1}}{N}\left(\frac{y_{0}+y_{1}}{2}+\frac{y_{1}+y _{2}}{2}+\dots+\frac{y_{N-1}+y_{N}}{2}\right)}$

$\displaystyle \displaystyle{=\frac{x_{N}-x_{1}}{2N}(y_{0}+y_{1}+y_{1}+y_{2}+\dots+y_{N-1}+y_{N})}$

$\displaystyle \displaystyle{=\frac{x_{N}-x_{1}}{2N}(y_{0}+2y_{1}+2y_{2}+\dots+2y_{N-1}+y_{N}).}$

All the middle terms are in the sum twice, and the endpoints are there only once.

Does this make the formula clear to you?