Exponential Functions: Benchmarks, 8 Times Faster Math.pow()

I have updated the code for the Math.pow() approximation, now it is 11 times faster on my Pentium IV. Read Optimized Exponential Functions for Java for more information. Now I can also give you some benchmarks:

Benchmarks

Math.log() — 11.7 times faster

  • 6.233 sec, Math.log(x)
  • 0.531 sec, 6*(x-1)/ (x + 1 + 4*(Math.sqrt(x)))

Math.exp() — 5.3 times faster

  • 5.920 sec, Math.exp(x)
  • 1.108 sec, exp optimized with IEEE 754 trick

Math.pow() — 8.7 times faster

  • 15.967 sec, Math.pow(a, b)
  • 11.014 sec, e^(b * log(a))
  • 7.607 sec, e^(b * log(a)) + IEEE 754 trick
  • 2.109 sec, e^(b * log(a)) + IEEE 754 trick + LOG approximation
  • 1.827 sec, simplified everything, see Optimized Exponential Functions for Java

For accurate measurements I have performed each calculation 20 million times and used a random number generator to prevent optimization. I have measured the overhead of iterating and random number generation (3.969 sec) and substracted this from each measurement so that only the pure functional code is measured.

Related posts

  1. Optimized Exponential Functions for Java
  2. How To Make Firefox Over 40% Faster
  3. Statistical Unit Tests with ensure4j

One thought on “Exponential Functions: Benchmarks, 8 Times Faster Math.pow()

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>