title: find root of vectorised function in python
body: <p>I've been porting some code from matlab to python.</p>
  
  <p>Part of the code finds the root of a vectorised function, which is expensive to call. </p>
  
  <p>In matlab this is efficiently achieved using the <a href="http://www.mathworks.co.uk/help/optim/ug/fsolve.html" rel="nofollow">JacobPattern</a> option. By using this option the solver is aware that the nth element of the returned vector depends only on the nth element of the argument vector. </p>
  
  <pre><code>    options = optimset('Algorithm','trust-region-reflective','JacobPattern',speye(lengthOfArgument));
      roots = fsolve(@VectorisedFunction, initialGuesses, options);
  </code></pre>
  
  <p>The vectorisation in matlab speeds things up by about a factor of 100 and I expect something similar could be achieved in python. I have been looking at <a href="http://docs.scipy.org/doc/scipy/reference/optimize.html" rel="nofollow">scipy.optimization</a> but cannot find an equivalent of JacobPattern.</p>
  
  <p>So I ask: what are the best approaches to finding the root of a vectorised function in python?</p>