Source: http://cda.psych.uiuc.edu/matlab_pdf/optim_tb.pdf