 rootfind algorithm 