Just to set things straight: The error message "Error in nleqslv(xstart, fun) : Length of fn result <> length of x!" is issued by the underlying nleqslv C function. <fn> refers to the second argument of function nleqslv which is named fn. It is not issued by R itself. Other have already pointed out how to resolve the error. Berend Hasselman