MATLAB: Do I get an error message concerning GN not being a descent direction when using FSOLVE

directiongradientOptimization Toolbox

For example, I'll receive:
how =
ERROR- GN not descent direction

Best Answer

This error indicates a problem with the current search direction.
To compute a search direction, the Gauss-Newton method, the default method when using FSOLVE, will solve the following linear system:
search_direction = (J'*J)\(-J'*f)
(It doesn't solve this equation explicitly, but solves an equivalent yet more numerically stable system where f is the vector of function values returned by the user-supplied function and J is the Jacobian of f.)
If J is not a matrix with full column rank, then J'*J may be rank-deficient (singular) and then the resulting search_direction may not be a descent direction.
If the last stepsize was < 1e-8 or the condition number of J > 1e8 then fsolve will switch to the Levenberg-Marquardt method. If neither of these conditions is true, but the resulting search_direction is not be a descent direction then you get the warning 'ERROR- GN not descent direction'.
In this case, one of several things could be happening:
1) Your nonlinear system of equations might be a dependent system, at least around the current point
2) Your functions returned in f are not smooth and so the Jacobian is inaccurate (finite-differencing on say a step function can result in wildly wrong first derivative estimates)
In case 2, you should modify your function to be smooth. In case 1, you should try different starting points, and if you can't find somewhere that gives you a solution without those warnings then you should reconsider the formulation of your problem to remove the dependencies. You might also try using the Levenberg-Marquardt method (call LEASTSQ instead of FSOLVE using the same problem, etc).
Related Question