optim_nm function

Optimization with Nelder-Mead