0

My professor told us to make a program that will materialize the Newton-Raphson method in java code. The thing is that we should use beginners code for this.

*Required: The program should return the value of x1 in each repetition and we must define the accuracy of the solution.(i.e double e=0.000005;)

*x1 = x0 - (f(x0)/f'(x0)) x0 stands for the value we think is close to the solution.

Cœur
  • 37,241
  • 25
  • 195
  • 267
George.K
  • 13
  • 1
  • 8

1 Answers1

-1

Though it's very late, but my answer may help others who are finding implementation of Newton-Raphson method in Java. Below is the function with the implementation.

public static double squareRoot (double num)    {

 double sqrt = x;

 while (sqrt * sqrt/num > 1) {
   sqrt = sqrt - ((sqrt * sqrt - num) / (2 * sqrt));

   if ((sqrt * sqrt) / num == 1)
     break;

 }
 return sqrt;
 }
ihm017
  • 182
  • 9
  • Though there may be other better ways, but it's the simplest implementation i could think of implementing Newton Raphson in Java. – ihm017 Aug 14 '18 at 05:57