==> Due on Mon 3/19 in class <==
1-d harmonic oscillator in thermal equilibrium.
Classical statistical mechanics tells us that equilibrium properties of a system are determined by the so-called partition function exp(-V(x)/kT), where V(x) is the total potential energy of configuration x. We will work in units such that kT=1. Consider a particle in a one-dimensional harmonic potential V(x)=x^2/2; here x is simply the one-dimensional coordinate of the particle. The average potential energy of the particle is given by
INT_{-infty, infty} [ x^2/2 exp(-x^2/2) dx ] Ev = ---------------------------------------------- . INT_{-infty, infty} [ exp(-x^2/2) dx ](INT_{-infty, infty} [....] stands for ``integrating [....] from minus infinity to plus infinity''.)
Write a program to calculate this integral by the Metropolis algorithm. Equilibrate the random walk for several hundred steps before collecting samples. After equilibration, divide the random walk into n_blk blocks of n_smpls each, like in HW2. Compute Ev, (including error bar) and also estimate an average acceptance ratio from the program. Start the random walk in any way you think is reasonable.