It is hard to say without more context, but probably because w
and x
are both defined both inside and outside of your function sum()
.
Also note that the two lines are not the same:
pprint(w*exp(-((((b-a)/2.0)*x)+((a+b)/2.0))**2))
pprint(w*np.exp(-((((b-a)/2.0)*x)+((a+b)/2.0))**2))