In most of the Monte-Carlo-Algorithms I studied, I found, at the place where they compute the energy, always a line of code, where they divided by four.

For example, this code-snippet is taken from here

def Energy(Q):
        for i in range(len(Q)):
            for j in range(len(Q)):
        return starting_energy/4

Another example can be found here

def calcEnergy(config):
    '''Energy of a given configuration'''
    energy = 0
    for i in range(len(config)):
        for j in range(len(config)):
            S = config[i,j]
            nb = config[(i+1)%N, j] + config[i,(j+1)%N] + config[(i-1)%N, j] + config[i,(j-1)%N]
            energy += -nb*S
    return energy/4.

From my understanding, we want to compute the energy of a spin-configuration that includes the spin we are currently looking at plus its closest neighbors. So in sum that would make 5 ising-spins we are computing in this function.

So why is it correct to return return energy/4 instead of return energy/5?


1 Answer 1


The energy expression is not a sum over spins, it is a sum over spin pairs, each pair counted once. But as expressed in

nb = config[(i+1)%N, j] + config[i,(j+1)%N] + config[(i-1)%N, j] + config[i,(j-1)%N

each (non-zero coupling) spin pair is counted 4 times. Hence the need to quarter the final result.

  • $\begingroup$ Thank you very much. I didn't understand that it is actually spin pairs one is looking at. $\endgroup$
    – MLK
    Jun 6, 2020 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.