2 matplotlib.use('Agg') # select backend that doesn't require X Windows
10 def d(a,b,x) : # know denominator
11 return (x, ((a**2 - x**2)**2 + (b*x)**2))
12 def rm(r, height) : # root marker
13 return ([r, r], float(height) * array([0.0001,1]))
14 def zr(a,b,p,q) : # p, q \in {-1,1}
15 return p*i*b/2.0 * (1 + q*sqrt(complex(1,0) - (2*a/b)**2))
16 def zrc(c,b,p,q) : # p, q \in {-1,1}
17 return p*i*b/2.0 * (1 + q*sqrt(complex(1,0) - (2*c)**2))
18 def dr(a,b,x) : # attempt at factoring
20 return (x, (x-zrc(c,b,+1,+1)) \
28 return (1/dt).mean()*(x[-1]-x[0])*2 # 2 because we want int from -inf to inf
29 def theory_residue_thm(a,b) :
35 return 2*pi*i* ( 1/((zpp-zpm)*(zpp-zmp)*(zpp-zmm)) + 1/((zpm-zpp)*(zpm-zmp)*(zpm-zmm)) )
36 def theory_before_plugging_in_roots(a,b) :
42 return pi*i/(zpp**2 - zpm**2) * ( 1/zpp - 1/zpm )
43 def theory_before_mc(a,b) :
51 / ((1+sq)**2 - (1-sq)**2) * ((1-sq) - (1+sq)) \
53 def theory_final(a,b) :
54 return pi/(complex(b)* a**2)
58 PLOT_COMPARISONS = False
61 x = linspace(0,8*a,N-1)
63 if PLOT_COMPARISONS == True :
65 for b in linspace(a/10.0, 8*a, 500) :
66 if PLOT_COMPARISONS == True :
71 nA.append(numeric(a,b,x))
72 tA.append(theory(a,b))
74 plot(nA, 'r.', tA, 'b-')