title: How to use scipy.optimize.basinhopping and scipy.optimize.minimum?
body: <p>I've already read the documentation for both but I'm still confused about how to use them (I'm taking an intro CS class for python so I'm not very familiar with programming). Can anyone provide some very basic examples of what the code might look like?</p>
  
  <p>For example, how would I use basin hopping to find the minimum of an equation with two variables such as f(x,y) = x^2*y^2 + cos(x)*sin(y) with x and y in the range -5 &lt; x,y &lt; 5 ?</p>
  
  <p>And for minimize, how might I find the minimum of something like f(x) = x^3 - cos(2*pi*x)?</p>
  
  <p>Please keep the examples as simple as possible! (I really didn't understand the code in the documentation at all, I don't think we learned scipy as in depth as that)</p>
  
  <p>Here are some examples of what I've tried so far:</p>
  
  <p>Basinhopping:</p>
  
  <pre><code>import numpy as np
  import scipy.optimize as spo
  
  def f(xy): #(I don't know what to do for x and y here)  
      return x**2*y**2+np.cos(x)*np.sin(y)
  
  guess = np.array(-5,5)
  result = spo.basinhopping(f, guess)
  print(result)
  </code></pre>
  
  <p>Minimize:</p>
  
  <pre><code>def g(x):
      return x**2 - np.cos(2*np.pi*x)
  
  result2 = spo.minimize(g)  
  print(result2)  
  </code></pre>