title: Writing your own exponential power function with decimals
body: <p>So, I want to write a function in code using some sort of algorithm to calculate any number to any power, including decimals. I use JavaScript and it already has an inbuilt pow function:</p>
  
  <pre><code>Math.pow(2, 0.413) // 2^0.413 = 1.331451613236371, took under 1 second.
  </code></pre>
  
  <p>Now I want to write my own like this:</p>
  
  <pre><code>function pow(x, y) {
      // Algorithm
  }
  </code></pre>
  
  <p>This is a function that calculates the square root of any number (x^0.5), and it's very accurate with only 10 loops:</p>
  
  <pre><code>function sqrt(x, p) { // p = precision (accuracy)
      var a = 1;
      var b = x;
  
      while (p--) {
          a = (a + b) / 2
          b = x / a
      }
  
      return a
  }
  </code></pre>
  
  <p>Is there any simple formula to calculate any exponential?</p>
  
  <p>If there isn't a simple one, is there a hard one?</p>
  
  <p>If the solution is slow, how can JavaScript's pow estimate under a single second?</p>