I am trying to use the nonlinear fitting routines of MINPACK for fitting a rather complicated equation of state to a set of experimental data. A subset of the data is fitted fairly well to a simplified form of the EoS, which gives me some confidence that the implementation is, in principle, working. However, it seems to be impossible to fit the entire dataset to the extended form of the EoS, although the dataset is quite smooth and of good quality, and although my initial guesses are close to the expected solution and already give a decent fit.

Here is what irritates me most: The return status of the fit encoded by the INFO parameter is not too elucidating. I have the impression that INFO=1 or 2 is deemed ok; according to the comments in the code it means "algorithm estimates that the relative error in the sum of squares is at most tol= 0.149E-07" or "algorithm estimates that the relative error between x and the solution is at most tol= 0.149E-07", respectively. However, I get this return status for very different solutions (using different starting guesses). Then there is the status INFO=4, "fvec is orthogonal to the columns of the jacobian to machine precision", which I don't really understand. I often get it when there are only 5 iterations (for 4 fitting parameters, where it seems that 4 iterations vary each of the parameters individually by a small amount to probe the local surroundings of the solution). This can happen for different initial guesses, close or not so close to the expected solution for a good fit.

Can somebody explain this behavior and tell me if it possible, for instance, to change the size of those initial test variations of each parameter or to put constraints (bounds) on the range of each parameter? What I do right now is simply to force each parameter to lie between given bounds with max and min statements before each call of the model function by lmdif1.



1 Answer 1


You haven't said which of the MINPACK routines you're using to solver your least squares problem. I'll assume that you're using LMDIF1 (which uses finite difference approximations for the dervatives with an automatically determined step size for the finite difference derivatives.)

This could also be a result of non-smoothness of the user supplied functions on the scale of the step size used in the finite difference approximations. In particular, if your function evaluations involve any approximations (e.g. evaluating an integral to some limited precision or simply by being done in single precision rather than double precision), so that they aren't accurate to full double precision, then this can cause the INFO=4 failure.

if this is your problem, then consider using the LMDIF function and supplying a parameter that tells MINPACK how imprecise your function evaluations are.

  • $\begingroup$ To explain the error message itself: Minpack solves a linear least squares problem at each iteration to compute a proposed step. When fvec is orthogonal to the columns of the Jacobian, then the solution to this least squares problem is 0, and there's simply no where to go. However, other tests of optimality have not been passed, so MINPACK concludes that something went wrong. $\endgroup$ Commented Oct 31, 2013 at 17:12
  • $\begingroup$ Also, if there are values of the parameter for which the functions simply aren't defined, then you can (and should) simply return very large values in all of the entries in fvec (say 1.0e30) This will cause the LM method to shorten its step length and remain within a the feasible range. $\endgroup$ Commented Oct 31, 2013 at 17:24
  • $\begingroup$ I am using LMDIF1, but you are right - with LMDIF I would have more control. I have been trying out a couple of things in the past days, but it turns out that the functional model seems to be of such kind that quite different parameter combinations, many of them clearly unphysical, give fits to the data that are quite good visually. At any rate, thanks for your comments, which gave me some helpful hints what to try next. $\endgroup$
    – TomR
    Commented Nov 2, 2013 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.