Four Techniques for One Dimensional Riemann Definite Integration by James Pate Williams, Jr. BA, BS, MSwE, PhD

The four methods considered in this study are as follows:

  1. Trapezoidal Rule
  2. Simpson’s Rule
  3. Gauss-Legendre Quadrature
  4. Monte Carlo Method

The trapezoidal rule requires (n  + 2) function evaluations, n real number increments, and six additional real number arithmetic operations. Simpson’s rule involves (n + 2) function evaluations, n real number increments, and ten additional real number arithmetic operations. Gauss-Legendre quadrature uses n function evaluations, 3 * n real number arithmetic operations, 2 * n index operations, and five additional arithmetic operations. Finally, the Monte Carlo Method requires n function evaluations, n random number generations, 2 * n + 3 additional real number arithmetic operations. The Gauss-Legendre quadrature also involves some complicated orthogonal polynomial operations to determine the abscissas and weights. Below are some results from our test C# application.

ResultsForm 10_25_2018 5_20_34 PMResultsForm 10_25_2018 5_21_14 PMResultsForm 10_25_2018 5_21_28 PMResultsForm 10_25_2018 5_22_26 PMResultsForm 10_25_2018 5_22_47 PMResultsForm 10_25_2018 5_23_05 PMResultsForm 10_25_2018 5_23_52 PMResultsForm 10_25_2018 5_24_19 PMResultsForm 10_25_2018 5_24_39 PM

We conclude from the preceding dearth of tests that for given n the order of accuracy is generally Gauss-Legendre, Simpson’s, Trapezoidal, and finally Monte Carlo.

Calculating a Few Digits of the Transcendental Number Pi by Throwing Darts by James Pate Williams, BA, BS, MSwE, PhD

Suppose you have a unit square with a circle of unit diameter inscribed . You can compute a few digits of the transcendental number, pi, 3.1415926535897932384626433832795…, by using the algorithm described as follows. Let n be the number of darts to throw and h be the number of darts that land within the inscribed circle.

h = 0

for i = 1 to n do

Choose two random numbers x and y such that x and y are contained in the interval 0 to 1 inclusive that is x and y contained in [0, 1]

Let u = x – 1 / 2 and v = y – 1 / 2

if u * u + v * v <= 0.25 = 1 / 4 then h = h + 1

next i

pi = 4 * h / n

Below are the results of a C# Microsoft Visual Studio simulation project. In the first case we throw 100,000 darts and get two significant digits of pi and then we throw a 1,000,000 darts and five significant digits of pi are computed. Of course, in a previous entry by this author we can calculate hundreds or thousands of digits of pi in relatively little time:

https://jamespatewilliamsjr.wordpress.com/2018/07/01/the-bailey-borwein-plouffe-formula-for-calculating-the-first-n-digits-of-pi/

MainForm 10_16_2018 3_04_04 AMMainForm 10_16_2018 3_05_45 AMMainForm 10_16_2018 3_09_36 AMMainForm 10_16_2018 3_09_54 AM

MonteCarloPi Source Code