title: Using scipy to minimize a function that also takes non variational parameters
body: <p>I want to use the <code>scipy.optimize</code> module to minimize a function. Let's say my function is <code>f(x,a)</code>:</p>
  
  <pre><code>def f(x,a):
   return a*x**2
  </code></pre>
  
  <p>For a fixed <code>a</code>, I want to minimize <code>f(x,a)</code> with respect to <code>x</code>.</p>
  
  <p>With <code>scipy</code> I can import for example the <code>fmin</code> function (I have an old scipy: v.0.9.0), give an initial value <code>x0</code> and then optimize (<a href="http://docs.scipy.org/doc/scipy-0.9.0/reference/tutorial/optimize.html" rel="nofollow">documentation</a>):</p>
  
  <pre><code>from scipy.optimize import fmin
  x0 = [1]
  xopt = fmin(f, x0, xtol=1e-8)
  </code></pre>
  
  <p>which fails because <code>f</code> takes two arguments and <code>fmin</code> is passing only one (actually, I haven't even defined <code>a</code> yet). If I do:</p>
  
  <pre><code>from scipy.optimize import fmin
  x0 = [1]
  a = 1
  xopt = fmin(f(x,a), x0, xtol=1e-8)
  </code></pre>
  
  <p>the calculation will also fail because "x is not defined". However, if I define <code>x</code> then there is no variational parameter to optimize.</p>
  
  <p>How do I allow non-variational parameters to be used as function arguments here?</p>