A stable quotient-difference algorithm