Newton's Method

Newton's Method
f(x) returns the function value at x, and fp(x) returns the derivative at x. There is no error checking, so be careful that fp(x) doesn't return 0. import java.util.*; public class NewtonRaphson { 	public static void main(String args[]) { 		//Starting guess double x = 100000.0; double nextx = 0; while(true) { 			nextx = x - f(x)/fp(x); if (Math.abs(nextx-x) < 0.000000001) break; x = nextx; } 		System.out.println("Root at " + nextx); } 	public static double f(double x) 	{ return (x*x + 1)*(x-3); } 	public static double fp(double x) 	{ return 3*x*x - 6*x + 1; } }