commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Maisonobe (JIRA)" <j...@apache.org>
Subject [jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.
Date Sun, 25 Jul 2010 19:31:50 GMT

    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12892135#action_12892135
] 

Luc Maisonobe commented on MATH-375:
------------------------------------

Adding one technical comment now.
It seems to me the atan2 function does not behave as expected for some special inputs with
one tiny (or zero) parameter and the other very large (or infinite). For example the following
codes:
{code}
double y1 = 1.2713504628280707e10;
double x1 = -5.674940885228782e-10;
System.out.println("Math: " + Math.atan2(y1, x1) + ", FastMath: " + FastMath.atan2(y1, x1));
double y2 = 0.0;
double x2 = Double.POSITIVE_INFINITY;
System.out.println("Math: " + Math.atan2(y2, x2) + ", FastMath: " + FastMath.atan2(y2, x2));
{code}

prints these results:

{code}
Math: 1.5707963267948968, FastMath: -1.5707963267948966
Math: 0.0, FastMath: Infinity
{code}

It would also be very useful to have a few more functions, the main missing one being sqrt.
However, thes functions can be added later on.

> Elementary functions in JDK are slower than necessary and not as accurate as they could
be.
> -------------------------------------------------------------------------------------------
>
>                 Key: MATH-375
>                 URL: https://issues.apache.org/jira/browse/MATH-375
>             Project: Commons Math
>          Issue Type: New Feature
>         Environment: JDK 1.4 - 1.6
>            Reporter: William Rossi
>         Attachments: FastMath.tar.gz
>
>
> I would like to contribute improved versions on exp(), log(), pow(), etc.  to the project.
 Please refer to this discussion thread http://markmail.org/message/zyeoguw6gwtofm62.
> 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
hit.
> 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.


Mime
View raw message