def dfdr(r,theta): out = np.sin(theta)*(np.exp(-r/2.) - (1./2.)*r*np.exp(-r/2.)) out[-1] = 0 return out