Q:

Numpy divide by zero. Why?

import pygame
import random
import math
import numpy as np
import matplotlib.pyplot as plt
fx = np.zeros([11])
fy = np.zeros([11])
x = np.zeros([11])
y = np.zeros([11])
x[0] = 11
y[0] = 1
sigma = 1.01
e = 1.1
dt = 0.1
def LJ(x,y):
    for i in range(1,10):
        for j in range(1,10):
            rx = (x[i]-x[j])
            ry = (y[i]-y[j])
            fx[i] = 24*e*(((2/rx)*sigma/rx**12)-((1/rx)*sigma/rx**6))
            fy[i] = 24*e*(((2/ry)*sigma/ry**12)-((1/ry)*sigma/ry**6))
    print fx, fy

Why am I still getting errors 
RuntimeWarning: divide by zero encountered in double_scalars
and
RuntimeWarning: invalid value encountered in double_scalars

The result I am getting is
[  0.  nan  nan  nan  nan  nan  nan  nan  nan  nan   0.] [  0.  nan  nan  nan  nan  nan  nan  nan  nan  nan   0.]

I tried to modify starting x and y but that gave no effect.

A:

In this code:
def LJ(x,y):
    for i in range(1,10):
        for j in range(1,10):
            ...

If i == j, you are comparing a particle to itself. Try skipping that iteration of the for-loops like so:
def LJ(x,y):
    for i in range(1,10):
        for j in range(1,10):
            if i == j:
                continue
            rx = (x[i]-x[j])
            ry = (y[i]-y[j])
            fx[i] = 24*e*(((2/rx)*sigma/rx**12)-((1/rx)*sigma/rx**6))
            fy[i] = 24*e*(((2/ry)*sigma/ry**12)-((1/ry)*sigma/ry**6))

Also, you will need to put in actual values for the x and y lists, as they are all currently 0's. Two particles at exactly the same location exert an infinite amount of force according to that equation, so the divide by 0 is accurate in that scenario.

