title: Least squares fit in python for 3d surface
body: <p>I would like to fit my surface equation to some data. I already tried scipy.optimize.leastsq but as I cannot specify the bounds it gives me an unusable results. I also tried scipy.optimize.least_squares but it gives me an error:</p>
  
  <pre><code>ValueError: too many values to unpack
  </code></pre>
  
  <p>My equation is:</p>
  
  <pre><code>f(x,y,z)=(x-A+y-B)/2+sqrt(((x-A-y+B)/2)^2+C*z^2)
  </code></pre>
  
  <p>parameters A, B, C should be found so that the equation above would be as close as possible to zero when the following points are used for x,y,z:</p>
  
  <pre><code>    [
     [-0.071, -0.85, 0.401],
     [-0.138, -1.111, 0.494],
     [-0.317, -0.317, -0.317],
     [-0.351, -2.048, 0.848]
     ]
  </code></pre>
  
  <p>The bounds would be A > 0, B > 0, C > 1 </p>
  
  <p>How I should obtain such a fit? What is the best tool in python to do that. I searched for examples on how to fit 3d surfaces but most of examples involving function fitting is about line or flat surface fits.</p>