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

  • The Modern C# Challenge
  • Rod Stephens
  • 233字
  • 2021-08-13 15:24:00

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.

主站蜘蛛池模板: 赤水市| 龙岩市| 庐江县| 布尔津县| 鄂托克前旗| 昌图县| 文水县| 连城县| 新干县| 蒙城县| 东阳市| 安达市| 张家界市| 中宁县| 溧阳市| 苍南县| 西乌珠穆沁旗| 阳西县| 西昌市| 句容市| 陵川县| 乳山市| 余江县| 大洼县| 海原县| 隆回县| 明溪县| 昌乐县| 姜堰市| 六枝特区| 荆州市| 无锡市| 昌宁县| 韶关市| 阳朔县| 安乡县| 邵阳县| 榆中县| 平南县| 绥芬河市| 滦南县|