title: Python brute force for a function of 2 variables
body: <p>I have the following function: </p>
  
  <pre><code>((sin(((x-8)**2+y**2)**0.5))/((((x-8)**2+y**2)**0.5)))+0.8*((sin(((x+8)**2+y**2)**0.5))/(((x+8)**2+y**2)**0.5))
  </code></pre>
  
  <p>I want to find the global maxima and minima of this function using brute force approach in Python. I have looked on scipy.optimize.brute but I am not sure on how to do the same for a function of 2 variables. </p>
  
  <pre><code>   y = np.linspace(-20,20,1000)
  x = np.linspace(-20,20,1000)
  def f(x,y):
      return (((sin(((x-8)**2+y**2)**0.5))/((((x-8)**2+y**2)**0.5)))+0.8*((sin(((x+8)**2+y**2)**0.5))/(((x+8)**2+y**2)**0.5)))
  rranges = (slice(-4, 4, 0.25), slice(-4, 4, 0.25))
  val  = scipy.optimize.brute(f, rranges, finish=optimize.fmin)
  </code></pre>
  
  <p>This is my code so far. It gives an error :</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/Aravind_Sampathkumar/Desktop/PY/Bruteforce.py", line 11, in &lt;module&gt;
      val  = scipy.optimize.brute(f, rranges, finish=optimize.fmin)
    File "C:\Python27\lib\site-packages\scipy\optimize\optimize.py", line 2825, in brute
      Jout = vecfunc(*grid)
    File "C:\Python27\lib\site-packages\numpy\lib\function_base.py", line 2755, in __call__
      return self._vectorize_call(func=func, args=vargs)
    File "C:\Python27\lib\site-packages\numpy\lib\function_base.py", line 2834, in _vectorize_call
      res = array(outputs, copy=False, subok=True, dtype=otypes[0])
  ValueError: setting an array element with a sequence.
  </code></pre>
  
  <p>Any help is appreciated</p>