 rootfind algorithm 2 