This MATLAB function starts at x0 and tries to solve the equations described in fun.
www.mathworks.com