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

I would vote for panic - it is a user's mistake or bug, not our error.