title: What's the algorithm behind Math.pow() in Java
body: <p>I just started with Java and as a first project I am writing a program that finds roots(cube root in this case) of a given number. Presently I am trying out Newton-Ralphson to achieve this. Here is the code- </p>
  
  <pre><code>import java.util.Scanner;
  
  import static java.lang.Math.abs;
  
  public class newClass {
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          System.out.println("Number whose cube root u wanna find:");
          Double number = input.nextDouble();
          Double epsilon = 0.0001;
          Double ans = number/2.00;
          while (abs((abs(number) - abs(Math.pow(ans,3))))&gt;epsilon){
              System.out.println("in loop");
              ans = ans - ((Math.pow(ans,3) - number)/(3*Math.pow(ans,2)));
              System.out.println(ans);
              if ((number - ans)&lt;=epsilon){
                  System.out.println(ans);
              }
          }
          //System.out.println(Math.pow(number,1.0/3.0));
  
  
      }
  }
  </code></pre>
  
  <p>this works only upto 11 digit numbers after that it gets too big for IDE to handle. But if I simply use <code>Math.pow(number,1.0/3.0)</code> it works for much bigger numbers and computes it in no time.</p>
  
  <hr>
  
  <p>So, what is the algorithm that <code>Math.pow()</code> uses that gives an instant answer?
  <em>I understand that my method relies on guessing and I guess <code>math.pow()</code> may actually be calculating the answer, but how?</em></p>