The selection of multiple-valued inverses is solved as follows. When there are multiple choices for xi+1 we select the one with minimal distance to xi for convergence reasons. I.e. select the xi+1 which makes | xi+1-xi | minimal. This observation is a crucial one for our algorithm.
E.g. from g(xi+1)2 = h(xi) we derive g(xi+1) = Inverse_square( h(xi), g(xi) ) where
Inverse_square := proc( rhs, lhs ) r := sqrt( rhs ); if abs(r-lhs) <= abs(r+lhs) then r else -r fi end;
A second problem that we have with inverting functions is a domain problem, and it can be illustrated with the equation
Inverse_sqrt := proc( rhs ) a := argument( rhs ); if a <= -Pi/2 or a > Pi/2 then ERROR( `cannot invert sqrt` ) else rhs^2 fi end;