How does Matlab optimization tools works? It just gets the error function and doesn't need Jacobian (first derivatives) or Hessian (second derivatives)? How it is possible? If it is finite difference how it determines the value of dx for different degree of freedom?
How Matlab optimization works without Jacobian or Hessian
optimization;matlab;jacobian
The answer depends very much on what optimization function in MATLAB you're talking about.  The base MATLAB system includes a function fminsearch that uses the simplex method (not the simplex method for LP but rather the Nelder-Mead-Lagarias algorithm of the same name.)  This method does not make use of derivatives.  The functions of the optimization toolbox use a variety of different methods depending on the nature of the problem and its size.   There are different options for problems ranging from small sized to very large, and there are different options depending on the nature of the problem (e.g. constrained vs. unconstraints.)  For unconstrained nonlinear optimization of problems up to medium size, the toolbox uses the BFGS quasi-Newton method and can automatically compute finite difference approximations.