官术网_书友最值得收藏!

26. Rectangle rule integration

Monte Carlo integration is relatively simple, but it's also not repeatable. If you perform the same test multiple times with a different selection of random points, you'll get slightly different results.

Another method for estimating an area is to use a Riemann sum. (The method is named after the 19th century German mathematician Bernhard Riemann who made great contributions to integral geometry and other fields.) To calculate a Riemann sum, also known as applying the rectangle rule, you divide the area into thin slices and add up the areas of the slices. The following diagram shows an area being approximated by a Riemann sum:

In this example, the height of each rectangle is given by the function's value at the rectangle's left edge, so this is sometimes called the left Riemann sum. Other variations use the function's value at the rectangle's right edge (the right Riemann sum) or in the rectangle's middle (the midpoint rule).

The widths of the rectangles depend on the number of rectangles. Using more, thinner rectangles gives a closer approximation to the actual area.

Write a program that uses the left Riemann sum to approximate the area under a function. Use your program to estimate the areas for the curves described in the preceding problem.

If you remember your calculus, make the program calculate the areas exactly and compare the calculated and estimated results.

主站蜘蛛池模板: 信丰县| 万盛区| 镇宁| 鹤庆县| 拉孜县| 西乡县| 特克斯县| 瑞安市| 永泰县| 沂南县| 宽甸| 繁峙县| 安宁市| 那坡县| 徐水县| 永兴县| 扬中市| 页游| 长乐市| 怀集县| 若羌县| 美姑县| 正蓝旗| 宣城市| 兰西县| 微山县| 焉耆| 牟定县| 青阳县| 七台河市| 林甸县| 于田县| 高州市| 侯马市| 浏阳市| 阜新市| 修水县| 临泽县| 滦平县| 嵊泗县| 昆山市|