title: Finding complex roots from set of non-linear equations in python
body: <p>I have been testing an algorithm that has been published in literature that involves solving a set of 'm' non-linear equations in both Matlab and Python.  The set of non-linear equations involves input variables that contain complex numbers, and therefore the resulting solutions should also be complex.  As of now, I have been able to get pretty good results in Matlab by using the following lines of code:</p>
  
  <pre><code>lambdas0 = ones(1,m)*1e-5;
  options = optimset('Algorithm','levenberg-marquardt',...
  'MaxFunEvals',1000000,'MaxIter',10000,'TolX',1e-20,...
  'TolFun',1e-20);
  
  Eq = @(lambda)maxentfun(lambda,m,h,g);
  [lambdasf]  = fsolve(Eq,lambdas0,options);
  </code></pre>
  
  <p>where h and g are a complex matrix and vector, respectively. The solution converges very well for a wide range of initial values.  </p>
  
  <p>I have been trying to mimic these results in Python with very little success however. The numerical solvers seem to be set up much differently, and the 'levenburg-marquardt' algorithm exists under the function root. In python this algorithm cannot handle complex roots, and when I run the following lines:</p>
  
  <pre><code>lambdas0 = np.ones(m)*1e-5
  
  sol = root(maxentfun, lambdas0, args = (m,h,g), method='lm', tol = 1e-20, options = {'maxiter':10000, 'xtol':1e-20})
  
  lambdasf = sol.x
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>minpack.error: Result from function call is not a proper array of floats.
  </code></pre>
  
  <p>I have tried using some of the other algorithms, such as 'broyden2' and 'anderson', but they are much inferior to Matlab, and only give okay results after playing around with the initial conditions. The function 'fsolve' also cannot handle complex variables either. </p>
  
  <p>I was wondering if there is something I am applying incorrectly, and if anybody has an idea on maybe how to properly solve complex non-linear equations in Python. </p>
  
  <p>Thank you very much</p>