package newton;


/** Represents the Newton method.
 * @author Alan Ponte.*/
public class NewtonSolver {
	
	/** Creates a new solver with the Polynoomial P, the 
	 * derivative of the Polynomial, DF, and an initial guess of GUESS.
	 * The solver will run until the TOLERANCE is reached.*/

	public NewtonSolver(Polynomial p, Polynomial df, double guess, double tolerance) {
		_poly = p;
		_guess = guess;
		_df = df;
		_tol = tolerance;
	}
	
	/** Returns the tolerance of THIS solver.*/
	public double getTolerance() {
		return _tol;
	}
	/**Returns the result of applying newton's method.*/
	public double solve() {
		int i = 0;
		double p = 0.0;
		while (true) {
			p = _poly.valueAt(_guess)/_df.valueAt(_guess);
			if (Math.abs(p - _guess) < _tol) {
				break;
			}
			p = _guess;
			i += 1;
		}
		return p;
	}
	
	private Polynomial _poly;
	private Polynomial _df;
	private double _guess;
	private double _tol;

}

@@ -282,17 +282,16 @@
 ched.*/%0A
-%0A
 %09public 
@@ -434,16 +434,445 @@
 e;%0A%09%7D%0A%09%0A
+%09/** Creates a new solver with the Polynoomial P, the %0A%09 * derivative of the Polynomial, DF, and an initial guess of GUESS.%0A%09 * The solver will run until the TOLERANCE is reached, or the maximum number%0A%09 * of iterations. MAXITER is reached.*/%0A%09public NewtonSolver(Polynomial p, Polynomial df, double guess, double tolerance, int maxIter) %7B%0A%09%09_poly = p;%0A%09%09_guess = guess;%0A%09%09_df = df;%0A%09%09_tol = tolerance;%0A%09%09_maxIter = maxIter;%0A%09%7D%0A%0A
 %09/** Ret
@@ -958,16 +958,17 @@
 tol;%0A%09%7D%0A
+%0A
 %09/**Retu
@@ -1092,16 +1092,25 @@
 %7B%0A%09%09%09p =
+ _guess -
  _poly.v
@@ -1145,16 +1145,77 @@
 guess);%0A
+%09%09%09System.out.println(%22P-Value: %22 + p + %22 itration : %22 + i);%0A
 %09%09%09if (M
@@ -1263,26 +1263,26 @@
 %09%09%09%7D%0A%09%09%09
-p = 
 _guess
+ = p
 ;%0A%09%09%09i +
@@ -1383,16 +1383,16 @@
 _guess;%0A
-
 %09private
@@ -1404,12 +1404,35 @@
 le _tol;
+%0A%09private int _maxIter;
 %0A%0A%7D%0A

Update NewtonSolver.java