scipy/scipy — pull request #130 by yosefm (2012-01-07 10:56:48+00:00)
Title: Options to skip _check_func in scipy.optimize.leastsq

This adds options to scipy.optimize.leastsq to:
1. Supply the number of equations instead of having it automatically determined from running the target function once.
2. Skip jacobian checks.

The use-case is this: a small (say 6-20 variables) problem must be solved O(10,000) times repeatedly with differrent inputs but for the same problem size, e.g. a simulation of the same system for annual performance by repeatedly solving for time-intervals of 15 minutes. In this case I found the proposed change to cut a significant amount of time - in my problem ~18%.

The size of improvement depends on how complicated is the target function. For a different problem, taken from scipy/optimize/tests/minpack, the target function is quite fast and simple, so the improvement was only about 1% for me, (less without using Dfun), but it didn't make it slower.

The trade-off is that if you supply the wrong value, you might get a crash. Still, one might prototype without using these options, then add them for speed when it's all working properly.