I use matlab build-in function 'fminunc' to run some optimization for my image registration problem. I set the options as:
options = optimset('LargeScale', 'off', 'Display', 'iter-detailed', 'TolX', 0.0001, 'TolFun', 0.001, 'GradObj', 'off', 'DerivativeCheck', 'off';
I think it then uses Quasi-Newton (L-BFGS) method to do the optimization.
When the 'GradObj' is 'off', then the 'fminunc' calculate the gradient of the parameters need to be optimzed for me. (I suppose the Matlab use finite difference method to get the gradient)
I also try to provide the gradient by myself using finite difference method as well, then I set 'GradObj' is 'on'.
However, I always got much better results when I use the Matlab's calculation (When 'GradObj' is 'off').
May I ask where can I find the codes the matlab build-in function calculating the gradient please? I wish to compare with my own implementation to find the mistakes I might make.
Thanks very much and have a nice day.