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

Math.exp() — 5.3 times faster

Math.pow() — 8.7 times faster

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.

One Response to “Exponential Functions: Benchmarks, 8 Times Faster Math.pow()”

  1. Roy van Rijn on February 15th, 2007 8:50 pm

    Nice work :) I used approximation before in J2ME applications, worked like a charm.

    This one is also very nice, you might have seen it before:
    http://www.beyond3d.com/articles/fastinvsqrt/

    btw, I started a little side-project too, a general selection API for Java JDBC (no over-the-top Hibernate stuff).
    http://www.redcode.nl/blog11.html

Leave a Reply