8. Trapezoid rule integration

A trapezoid is a quadrilateral (four-sided polygon) that has two parallel sides. The parallel sides are called its bases and the other two sides are called its legs. The trapezoid's height is the distance between the two bases.

If a trapezoid has a height of h and base lengths b1 and b2, then its area is h × (b1 + b2) / 2. The following equation gives the sums of the areas used to approximate the area under a function:

If we assume that all of the trapezoids have the same height, dx = (xi+1 – xi), then we can factor out the dx and the factor of ½ to get the following:

This is simple, but we can make it even ...

Get Improving your C# Skills now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.