title: Pow() vs. exp() performance
body: <p>I was wondering if <code>exp()</code> is faster than more general <code>pow()</code>. I run fast benchmark on JsPerf <a href="http://jsperf.com/pow-vs-exp" rel="noreferrer">http://jsperf.com/pow-vs-exp</a> and it shown interesting results for me.</p>
  
  <pre><code>Math.exp(logBase * exponent);  // fastest
  Math.exp(Math.log(base) * exponent);  // middle
  Math.pow(base, exponent);  // slowest
  </code></pre>
  
  <p>I know that results will heavily vary on architecture and language but I am also interested in theoretical point of view. Is <code>pow(a, b)</code> implemented as <code>exp(log(a) * b)</code> or is there some more clever way how co compute power "directly" (in C++, C# or JavaScript). Are there CPU instructions for exp, log or pow on some architectures?</p>
  
  <p>As far as I know, both <code>exp()</code> and <code>log()</code> are computed using some Taylor series and are pretty expensive to compute. This makes me believe that for constant base of power, this code</p>
  
  <pre><code>double logBase = log(123.456);
  for (int i = 0; i &lt; 1024; ++i) {
      exp(logBase * 654.321);
  }
  </code></pre>
  
  <p>is better than this</p>
  
  <pre><code>for (int i = 0; i &lt; 1024; ++i) {
      pow(123.456, 654.321);
  }
  </code></pre>
  
  <p>Is that correct assumption?</p>