This applet demonstrates an elementary application of Monte Carlo integration to evaluate a simple integral.

By clicking on the appropriate button, you can evaluate the integral via either the rectangle rule or Monte Carlo integration. In either case, the number of quadrature points N used to estimate the integral can be varied by changing the value in the box (the largest value accepted is 1000000).

The result of the calculation is then displayed, along with the error in the result (given that the exact value of the integral is 1). Also, in the figure you will see the x-values used to perform the quadrature. For the Monte Carlo integration, different points are generated (and a different estimate of the integral is obtained) each time the button is pressed; for the rectangle-rule integration, the values are determined once given N, and do not change with each button-press.