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

  • 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.

主站蜘蛛池模板: 烟台市| 运城市| 宜良县| 连城县| 洛宁县| 武冈市| 邵阳县| 盐山县| 防城港市| 宜春市| 西乌珠穆沁旗| 昌乐县| 深泽县| 沅江市| 南皮县| 桐柏县| 改则县| 元阳县| 张家港市| 揭阳市| 屯留县| 扶沟县| 蓝田县| 太原市| 浦北县| 泊头市| 怀柔区| 虞城县| 峡江县| 福清市| 乐清市| 大田县| 息烽县| 巴塘县| 凤凰县| 合山市| 利津县| 吕梁市| 芦山县| 锦屏县| 威信县|