Make polyroots more robust

This ports the changes from https://github.com/sympy/sympy/pull/7393.

@fredrik-johansson, what kind of tests would you recommend to do? In the SymPy issue we solve 64th order Legendre. Should I export the coefficients and hardwire them into the mpmath test?