Homework 4

1) Nested Integrals:
Write a program to integrate the function f(x,y,z)=y*z*z*exp(x*y*z) numerically with respect to x, y, and z. All lower integration limits are 0, and all upper limits are 1. Solve the integral analytically, and compare it with your numerical result. As a starting point, you can use the program "nestedintegrals.f" on the website, which was discussed in class. Please hand in a print-out a copy of your program. (40 points)

2) Random Number Generator:
Modify Pang's program for the Gaussian random number generator to include a parameter "sigma" which controls the width of the distribution function. Generate plots of the distribution function for sigma= 0.5, 1.0, and 2.0, using 10,000 realizations for each case. It should look like this . (30 points)


3) Lorentzian Distribution Function:
Write a program to produce a random number generator with a Lorentzian distribution function, P(x)=a0/(a0^2 + (x-x0)^2), centered at x0=2.0 with a width a0=1.0. Make a plot of your distribution using 100,000 realizations. As a starting point, you may use the routine 'grnf.f' on our website. (30 points)