title: SciPy curve_fit not working when one of the parameters to fit is a power
body: <p>I'm trying to fit my data to a user defined function using SciPy curve_fit, which works when fitting to a function with a fixed power (func1). But curve_fit does not work when the function contains a power as a parameter to fit to (func2). </p>
  
  <p>Curve_fit still does not work if I provide an initial guess for the parameters usins the keyword <em>p0</em>. I can not use the <em>bounds</em> keyword as the version of SciPy which I have does not have it.</p>
  
  <p>This script illustrates the point:</p>
  
  <pre><code>import scipy
  from scipy.optimize import curve_fit
  import sys
  
  print 'scipy version: ', scipy.__version__
  print 'np.version:    ', np.__version__
  print sys.version_info
  
  def func1(x,a):
      return (x-a)**3.0 
  
  def func2(x,a,b):  
      return (x-a)**b
  
  x_train = np.linspace(0, 12, 50)
  y       = func2(x_train, 0.5, 3.0)
  y_train = y + np.random.normal(size=len(x_train))
  
  print 'dtype of x_train: ', x_train.dtype
  print 'dtype of y_train: ', y_train.dtype
  
  popt1, pcov1 = curve_fit( func1, x_train, y_train, p0=[0.6] )
  popt2, pcov2 = curve_fit( func2, x_train, y_train, p0=[0.6, 4.0] )
  
  print 'Function 1: ', popt1, pcov1
  print 'Function 2: ', popt2, pcov2
  </code></pre>
  
  <p>Which outputs the following:</p>
  
  <pre><code>scipy version:  0.14.0
  np.version:     1.8.2
  sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
  dtype of x_train:  float64
  dtype of y_train:  float64
  stack_overflow.py:14: RuntimeWarning: invalid value encountered in power
  return (x-a)**b
  Function 1:  [ 0.50138759] [[  3.90044196e-07]]
  Function 2:  [ nan  nan] [[ inf  inf]
   [ inf  inf]]
  </code></pre>