Solving secular and polynomial equations: A multiprecision algorithm