commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Hain (JIRA)" <>
Subject [jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.
Date Wed, 01 Sep 2010 20:38:56 GMT


Jeff Hain commented on MATH-375:


William, I've also contracted the fast-math disease some time ago, which ended up into some
FastMath class as well (
Though, your form seems more severe, since you felt the need to stay within +-0.5 ULP, whereas
my treatments are a bit more sloppy :)

Anyway, I did run my "FastMath" tests on your class, and found some troubles with special
cases, especially +-Infinity, NaN, or huge values:
see "" attachment, which contains test code, and a log of their run.

Also, running your tests, I had this exception:
-19.731458173549257	2.696103718050787E-9	2.6961037180507868E-9	1.534029657343928E-16	0.5025524399680612
Exception in thread "main" java.lang.RuntimeException: exp() had errors in excess of 0.502
	at FastMathWRTest.testExpAccuracy(
	at FastMathWRTest.main(

May it help you improve your treatments!



> Elementary functions in JDK are slower than necessary and not as accurate as they could
> -------------------------------------------------------------------------------------------
>                 Key: MATH-375
>                 URL:
>             Project: Commons Math
>          Issue Type: New Feature
>         Environment: JDK 1.4 - 1.6
>            Reporter: William Rossi
>             Fix For: 2.2
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz,
> I would like to contribute improved versions on exp(), log(), pow(), etc.  to the project.
 Please refer to this discussion thread
> I have developed over the past year a set of elementary functions similar to those in
java.lang.Math, but with the following characteristics:
> * Higher performance.
> * Better accuracy.  Results are accurate to slightly more that +/- 0.5 ULP.
> * Pure Java.  The standard Math class is impleneted via JNI, and thus takes a performance
> Note that some functions such as exp are nearly twice as fast in my implementation.  
I've seen it 3 times faster on different processors.   The preformance varies by the relative
speed of calculation vs memory lookups.
> The functions are implemented as tables of values in extra precision (approx 70 bits),
and then interpolated with a minimax polynomial.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message