# Homework for Metropolis sampling¶

First we copy things that we developed in the class.

This is implementation of the Lindhardt formula:

\begin{eqnarray} P(q,\omega) = -2 \int \frac{d^3k\; d\Omega_q}{(2\pi)^3} \frac{f(\varepsilon_{\vec{k}+\vec{q}})-f(\varepsilon_{\vec{k}})}{\omega-\varepsilon_{\vec{k}+\vec{q}}+\varepsilon_\vec{k}+i\delta} \end{eqnarray}

where $\varepsilon_\vec{k}=k^2-k_F^2$.

The input is momentum, where momentum[0,:] is $\vec{q}$ and momentum[1,:] is $\vec{k}$. It returns the value for array of frequencies.

Now we modify IntegrateByMetropolis so that func is allowed to return complex array of values. We marked all lines that require change by

# Next line needs CORRECTION for homework

• Pval[iq,iOm] becomes $q$ and $\Omega$ array.

• When we compute ratio, we need to take only the zero frequency value of the function, i.e., abs(fQ_new) and fQ.

• In measurement, the weight W should depend only zero frequency value only, to cancel the probability from the Metropolis, i.e., abs(fQ)

• When measuring, we need to properly update the values Pval[iQ,:]+= f0.

• The physical weight $\widetilde{V}_{physical}$ for determining if V0 is of the right magnitude, needs to be changed so that it depends on zero frequency only f0

• When we reset the stored values in Pval, we need to create array of proper size and type Pval = zeros(shape(Pval), dtype=complex)

• Printing should be modified, for example ratio has to be correctly modified to depend on zero frequency obly, and only the zero frequency value of the function is printed out.