MEX file for cost function and its compiled version on Mac Book Pro.
Nelder-Mead Simplex method is added as an alternative optimization routine.