root finding algorithm