from math import * def integral(N_pieces,dx): E=0.0 x=-dx/2.0 for i in range(N_pieces): x=x+dx # print x # test line r=2.2-x dE=8.99e9*10*dx/pow(r,2.0) E=E+dE # print E # test line return E ################################# # what follows is the main routine ################################## print 'N\t\t\tE(N)' #for j in range(1): # test line for j in range(9): N=pow(2.0,j+2) N=int(N) h=2.0/N I=integral(N,h) print N,'\t\t\t',I