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

Arg! Missed one. Done.