fixed error with optimization algorithm

moved to lsqnonlin, which is actually designed for this kind of
challenge. the previous optimizer sent a warning saying that it "can't
solve this kind of problem". this meant that i needed to specify the
gradient but hadn't.