**Example
3.** Let . Use
the Monte Carlo method to calculate approximations to the
integral .

**Solution 3.**

We are done!

**Aside.** We can use
*Mathematica*'s subroutine NIntegrate
to perform Monte Carlo integration, and we can verify that it is
computing the same results as our subroutine MonteCarloIntegral1D.

We will need to seed the random number generator with the same integer so that we get the same sequence of random numbers.

Observe that the results are the same.

We are really done!

**Aside.** The analytic
value of the integral can be found.

(c) John H. Mathews 2005