Exercise 2 - Monte Carlo Integration
- Write a program to perform a Monte Carlo integration of the
function y = x - sin(x) over the interval x=0 to x=pi.
Compare your results with the analytic solutions.
- Write a Monte Carlo integration program to integrate the function f(x) = (1-x2)1/2 over the range x = -1 to x = 1.
- Sketch the function and determine ymax
- Compare your computed result with the analytical result
- How many pairs of random numbers are required to achieve an accuracy of three decimal places?
- Write a program to compute the transcendental number e.
(Hint: Consider the integral of 1/x from x=1 to 10)
- Write a program to compute the volume of a sphere whose radius is 2.
Compare your results with the analytic solutions.