Initial commit of functions from github.com/btracey/optimize

Update these (order and spelling) to match the consts.