public static double refineRoot( Polynomial poly, double root , int maxIterations ) {

//		for( int i = 0; i < maxIterations; i++ ) {
//
//			double v = poly.c[poly.size-1];
//			double d = v*(poly.size-1);
//
//			for( int j = poly.size-1; j > 0; j-- ) {
//				v = poly.c[j] + v*root;
//				d = poly.c[j]*j + d*root;
//			}
//			v = poly.c[0] + v*root;
//
//			if( d == 0 )
//				return root;
//
//			root -= v/d;
//		}
//
//		return root;

		Polynomial deriv = new Polynomial(poly.size());
		derivative(poly,deriv);

		for( int i = 0; i < maxIterations; i++ ) {

			double v = poly.evaluate(root);
			double d = deriv.evaluate(root);

			if( d == 0 )
				return root;

			root -= v/d;
		}

		return root;
	}
public static double refineRoot ( Polynomial poly , double root , int maxIterations ) { Polynomial deriv = new Polynomial ( poly . size ( ) ) ; derivative ( poly , deriv ) ; for ( int i = 0 ; i < maxIterations ; i ++ ) { double v = poly . evaluate ( root ) ; double d = deriv . evaluate ( root ) ; if ( d == 0 ) return root ; root -= v / d ; } return root ; }
TODO try using a linear search alg here