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

FDf *must* not modify x.