global name 'sqrt' not defined
Question: I've created a function, `potential(x,K,B,N)`, where `x`,`K`,`B` are `numpy`
arrays and `N` is an integer. I'm trying to test the function in `iPython` but
I keep getting the error `"global name 'sqrt' not defined"`.

Here's a look at my code:

    
    
    def potential(x,K,B,N):
    
        x = x.reshape((3,N),order='F')
    
    U_b = 0.0
    for i in xrange(0,N-1):
        for j in xrange(i+1,N):
            if K[i,j] == 1.0:
                U_b += sum((x[:,i]-x[:,j])**2)
    U_b = 0.5*U_b
    
    U_a = 0.0
    for i in xrange(0,N-2):
        for j in xrange(i+1,N-1):
            for l in xrange(j+1,N):
                if B[i,j,l] == 1.0:
                    U_a += B[i,j,l]*sum((x[:,i]-x[:,j])*(x[:,j]-x[:,l]))/(sqrt(sum((x[:,i]-x[:,j])**2))*sqrt(sum((x[:,j]-x[:,l])**2)))
    U_a = -U_a
    
    U_r = 0.0
    d = 0.0
    for i in xrange(0,N-1):
        for j in xrange(i+1,N):
            d = sqrt(sum((x[:,i]-x[:,j])**2))
            if d > sqrt(0.2):
                U_r += (1.0/6.0)*(1/(d**6))
            else:
                U_r += -0.2**(-7.0/2.0)*d + (7.0/6.0)*(0.2)**(-3)
    
    return U_b + U_a + U_r
    

I've tried using `from math import *` but that doesn't seem to help. Any
suggestions would be greatly appreciated!


Answer: 
    from math import sqrt
    

is all that's missing

> I've tried using `from math import *` but that doesn't seem to help.

(Possibly you did that after defining the function. Anyway, fuhgeddaboutit,
just reload the code in a clean session, it will work.)

