def _aberth(f, fp, x0, tol=1e-15, maxiter=50):
 N = len(x0)
 x = array(x0, complex)
 beta = np.empty_like(x0)
 for iteration in range(maxiter):
  alpha = ((- f(x)) / fp(x))
  for k in range(N):
   beta[k] = np.sum((1 / (x[k] - x[(k + 1):])))
   beta[k] += np.sum((1 / (x[k] - x[:k])))
  x += (alpha / (1 + (alpha * beta)))
  if (not all(np.isfinite(x))):
   raise RuntimeError('Root-finding calculation failed')
  if all((abs(alpha) <= tol)):
   break
 else:
  raise Exception('Zeros failed to converge')
 return x

def _aberth ( f , fp , x0 , tol = 1e-15 , maxiter = 50 ) : N = len ( x0 ) x = array ( x0 , complex ) beta = np . empty_like ( x0 ) for iteration in range ( maxiter ) : alpha = ( ( - f ( x ) ) / fp ( x ) ) for k in range ( N ) : beta [ k ] = np . sum ( ( 1 / ( x [ k ] - x [ ( k + 1 ) : ] ) ) ) beta [ k ] += np . sum ( ( 1 / ( x [ k ] - x [ : k ] ) ) ) x += ( alpha / ( 1 + ( alpha * beta ) ) ) if ( not all ( np . isfinite ( x ) ) ) : raise RuntimeError ( 'Root-finding calculation failed' ) if all ( ( abs ( alpha ) <= tol ) ) : break else : raise Exception ( 'Zeros failed to converge' ) return x
given a function f .