You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "William Rossi (JIRA)" <ji...@apache.org> on 2010/06/09 01:28:15 UTC

[jira] Created: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

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


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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Roman Werpachowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877100#action_12877100 ] 

Roman Werpachowski commented on MATH-375:
-----------------------------------------

I would feel more comfortable if the source attached attributed copyright to ASF and included the license (Apache License).

> 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Rossi updated MATH-375:
-------------------------------

    Attachment: FastMath.tar.gz

Added license file

> 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Rossi updated MATH-375:
-------------------------------

    Attachment: FastMath.tar.gz

Description of files in the archive:

FastMath.java                  The software itself
FastMathTest.java           TestNG test case
remez/                                Utilities for generating coefficients of the polynomials  used in the software

remez/lib/dfp10.jar          High precision fp lib used for testing, from dfp.sourceforge.net

> 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.


Re: [jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by Luc Maisonobe <Lu...@free.fr>.
Le 09/06/2010 20:19, sebb a écrit :
> On 09/06/2010, Luc Maisonobe <Lu...@free.fr> wrote:
>> Le 09/06/2010 18:59, William Rossi (JIRA) a écrit :
>>
>>>
>>  >     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877132#action_12877132 ]
>>  >
>>  > William Rossi commented on MATH-375:
>>  > ------------------------------------
>>  >
>>  >
>>  > I'm not as well versed in these copyright issues I as I should be, but my
>>  > understanding is that as the copyright holder of the dfp library, I could
>>  > dual license it.  In any event, dfp is not required by the software, its
>>  > only used in the supporting test cases.
>>
>>
>> If it is used in the test cases, it should be included in the source
>>  release (which are what Apache promotes) and hence should be published
>>  with an Apache compatible license like Apache Software License V2 (of
>>  course) but also BSD for example.
>>
> 
> We don't include binaries (jars) in source releases.
> Commons uses Maven, so normally jars are resolved from the Central repo.
> 
> Apache releases can have optional dependencies on LGPL.
> 
> So if there were other tests, then IMO the tests that depend on dfp
> could be made optional.
> 
> But ideally the jar should be licensed using one of the "category A or
> B" licenses in
> 
> http://www.apache.org/legal/resolved.html#category-a
> http://www.apache.org/legal/resolved.html#category-b
> 
>>  >
>>  > Which also why I whould be hesitant to assign copyright to ASF, if I were
>>  > to do that and ASF decides not to persue the project then I'm left with
>>  > nothing.  By maintaining the copyright, I can issue licenses to other
>>  > parties as I see fit.
>>
>>
>> Yes.
>>
>>
>>  >
>>  > The ASF software grant agreement doesn't ask me to assign copyright to
>>  > ASF, but to mearly agree to specific license terms.
>>
>>
>> You are right, the foundation does not ask for the copyright, it only
>>  requires a license allowing it to redistribute the code under the terms
>>  of the Apache Software License V2. The copyright still belongs to you.
>>
>>  One minor glitch is that in the commons projects, we prefer not to have
>>  @author javadoc tags in the source but rather the names placed in the
>>  contributor section of the pom file (and hence publickly acknowledged in
>>  an automatically built page on the component site) and possibly in the
>>  NOTICE.txt file.
> 
> Huh?
> This does not apply to the dfp code - it is a binary library dependency.

I didn't have a look yet, thought it was another java source package.

Luc


Re: [jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by sebb <se...@gmail.com>.
On 09/06/2010, Luc Maisonobe <Lu...@free.fr> wrote:
> Le 09/06/2010 18:59, William Rossi (JIRA) a écrit :
>
> >
>  >     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877132#action_12877132 ]
>  >
>  > William Rossi commented on MATH-375:
>  > ------------------------------------
>  >
>  >
>  > I'm not as well versed in these copyright issues I as I should be, but my
>  > understanding is that as the copyright holder of the dfp library, I could
>  > dual license it.  In any event, dfp is not required by the software, its
>  > only used in the supporting test cases.
>
>
> If it is used in the test cases, it should be included in the source
>  release (which are what Apache promotes) and hence should be published
>  with an Apache compatible license like Apache Software License V2 (of
>  course) but also BSD for example.
>

We don't include binaries (jars) in source releases.
Commons uses Maven, so normally jars are resolved from the Central repo.

Apache releases can have optional dependencies on LGPL.

So if there were other tests, then IMO the tests that depend on dfp
could be made optional.

But ideally the jar should be licensed using one of the "category A or
B" licenses in

http://www.apache.org/legal/resolved.html#category-a
http://www.apache.org/legal/resolved.html#category-b

>  >
>  > Which also why I whould be hesitant to assign copyright to ASF, if I were
>  > to do that and ASF decides not to persue the project then I'm left with
>  > nothing.  By maintaining the copyright, I can issue licenses to other
>  > parties as I see fit.
>
>
> Yes.
>
>
>  >
>  > The ASF software grant agreement doesn't ask me to assign copyright to
>  > ASF, but to mearly agree to specific license terms.
>
>
> You are right, the foundation does not ask for the copyright, it only
>  requires a license allowing it to redistribute the code under the terms
>  of the Apache Software License V2. The copyright still belongs to you.
>
>  One minor glitch is that in the commons projects, we prefer not to have
>  @author javadoc tags in the source but rather the names placed in the
>  contributor section of the pom file (and hence publickly acknowledged in
>  an automatically built page on the component site) and possibly in the
>  NOTICE.txt file.

Huh?
This does not apply to the dfp code - it is a binary library dependency.

Re: [jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by Luc Maisonobe <Lu...@free.fr>.
Le 09/06/2010 18:59, William Rossi (JIRA) a écrit :
> 
>     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877132#action_12877132 ] 
> 
> William Rossi commented on MATH-375:
> ------------------------------------
> 
> 
> I'm not as well versed in these copyright issues I as I should be, but my 
> understanding is that as the copyright holder of the dfp library, I could 
> dual license it.  In any event, dfp is not required by the software, its 
> only used in the supporting test cases.

If it is used in the test cases, it should be included in the source
release (which are what Apache promotes) and hence should be published
with an Apache compatible license like Apache Software License V2 (of
course) but also BSD for example.

> 
> Which also why I whould be hesitant to assign copyright to ASF, if I were 
> to do that and ASF decides not to persue the project then I'm left with 
> nothing.  By maintaining the copyright, I can issue licenses to other 
> parties as I see fit.

Yes.

> 
> The ASF software grant agreement doesn't ask me to assign copyright to 
> ASF, but to mearly agree to specific license terms.

You are right, the foundation does not ask for the copyright, it only
requires a license allowing it to redistribute the code under the terms
of the Apache Software License V2. The copyright still belongs to you.
One minor glitch is that in the commons projects, we prefer not to have
@author javadoc tags in the source but rather the names placed in the
contributor section of the pom file (and hence publickly acknowledged in
an automatically built page on the component site) and possibly in the
NOTICE.txt file.

Luc

> 
> 
> 
> 
>> 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.
> 


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877132#action_12877132 ] 

William Rossi commented on MATH-375:
------------------------------------


I'm not as well versed in these copyright issues I as I should be, but my 
understanding is that as the copyright holder of the dfp library, I could 
dual license it.  In any event, dfp is not required by the software, its 
only used in the supporting test cases.

Which also why I whould be hesitant to assign copyright to ASF, if I were 
to do that and ASF decides not to persue the project then I'm left with 
nothing.  By maintaining the copyright, I can issue licenses to other 
parties as I see fit.

The ASF software grant agreement doesn't ask me to assign copyright to 
ASF, but to mearly agree to specific license terms.




> 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Hain updated MATH-375:
---------------------------

    Attachment: test_fastmath_wr.zip

Jafama tests for William's FastMath


> 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
>             Fix For: 2.2
>
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Rossi updated MATH-375:
-------------------------------

    Attachment: cosh-patch.txt.gz

Hyperbolic functions, cosh, sinh, tanh

> 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
>             Fix For: 2.2
>
>         Attachments: asinacos-patch.txt.gz, atanpatch.txt.gz, cbrt-patch.txt.gz, cosh-patch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Issue Comment Edited: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905210#action_12905210 ] 

Jeff Hain edited comment on MATH-375 at 9/1/10 4:46 PM:
--------------------------------------------------------

Hello.

William, I've also contracted the fast-math disease some time ago, which ended up into some FastMath class as well (http://sourceforge.net/projects/jafama).
Though, your form seems more severe, since you felt the need to stay within about +-0.5 ULP :)

Anyway, I did run my "FastMath" tests on your class (with the patch), and found some troubles with special cases, especially +-Infinity, NaN, or huge values:
see "test_fastmath_wr.zip" 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 ULP
	at FastMathWRTest.testExpAccuracy(FastMathWRTest.java:458)
	at FastMathWRTest.main(FastMathWRTest.java:18)

May it help you improve your treatments!

Regards,

Jeff


      was (Author: jeff):
    Hello.

William, I've also contracted the fast-math disease some time ago, which ended up into some FastMath class as well (http://sourceforge.net/projects/jafama).
Though, your form seems more severe, since you felt the need to stay within about +-0.5 ULP :)

Anyway, I did run my "FastMath" tests on your class, and found some troubles with special cases, especially +-Infinity, NaN, or huge values:
see "test_fastmath_wr.zip" 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 ULP
	at FastMathWRTest.testExpAccuracy(FastMathWRTest.java:458)
	at FastMathWRTest.main(FastMathWRTest.java:18)

May it help you improve your treatments!

Regards,

Jeff

  
> 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
>             Fix For: 2.2
>
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902922#action_12902922 ] 

William Rossi commented on MATH-375:
------------------------------------

I can focus on new functions in that order.  I did send the grant by fax last week. 

> 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
>             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 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Rossi updated MATH-375:
-------------------------------

    Attachment: cbrt-patch.txt.gz

The attached patch implements the cbrt() function.

> 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
>             Fix For: 2.2
>
>         Attachments: asinacos-patch.txt.gz, atanpatch.txt.gz, cbrt-patch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Rossi updated MATH-375:
-------------------------------

    Attachment:     (was: FastMath.tar.gz)

> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12904042#action_12904042 ] 

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

The FastMath class has been added to the subversion repository, as of r990655 for branch 2.X and as r990658 for trunk.
It is now used everywhere in the library (including in tests), in replacement of java.util.Math.
The contributed patch has been edited to match commons-math coding style which is enforced by checkstyle. The corresponding changes are mainly basic formatting (spaces, braces ...), naming conventions, variables declarations on separate lines, javadoc everywhere ... Some javadoc have been marked as "To Be Confirmed" (exp and log), please have a llook at it and check if they are correct.
In order to let users do global search and replace of java.util.Math by the new class, several new methods have been added. For the new functions (sinh, cosh ...) basic implementations have been set up. These implementations should be about 3 ULP accurate and may be slow for now. For consistency, the inverse hyperbolic functions (asinh, acosh and atanh) have been added too, depite they are not present in java.util.Math.
The unit tests have not been committed to the subversion repository yet, we are waiting for the dfp library to be available and integrated too (otherwise the continuous integration process would be broken by the missing dependency). This issue will be marked as resolved when the tests will be committed.

Thanks again for this contribution.

> 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
>             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 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905210#action_12905210 ] 

Jeff Hain commented on MATH-375:
--------------------------------

Hello.

William, I've also contracted the fast-math disease some time ago, which ended up into some FastMath class as well (http://sourceforge.net/projects/jafama).
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 "test_fastmath_wr.zip" 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 ULP
	at FastMathWRTest.testExpAccuracy(FastMathWRTest.java:458)
	at FastMathWRTest.main(FastMathWRTest.java:18)

May it help you improve your treatments!

Regards,

Jeff


> 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
>             Fix For: 2.2
>
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903722#action_12903722 ] 

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

We finally get the grant, thanks.
I have started integrating the patch in our current code base (not committed yet).
I added all missing functions with default implementations (either simple delegates to java.util.Math or basic implementations).
The code has also been edited to comply to our standard code style (indentation, braces, trailing spaces, variables naming, this kind of stuff).

Concerning the unit tests, I cannot commit them due to the external libraries and their license. I will start a discussion on the dev list about it.
Using the existing tests with all their dependencies on my machine, I had to slightly increase the threshold from 0.502 ULP to 0.504 ULP as the initial value lead to random failures. The tests were done on a 64 bits linux computer with Java 6. Are suche random failure expected ?

> 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
>             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 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877148#action_12877148 ] 

William Rossi commented on MATH-375:
------------------------------------


Certainly, I'll do then when I get a chance.




> 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.


[jira] Issue Comment Edited: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905210#action_12905210 ] 

Jeff Hain edited comment on MATH-375 at 9/1/10 7:14 PM:
--------------------------------------------------------

Hello.

William, I checked your treatments (with the patch) using tests of another FastMath class I did some time ago (http://sourceforge.net/projects/jafama), and found some troubles with special cases, especially +-Infinity, NaN, or huge values: see "test_fastmath_wr.zip" 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 ULP
	at FastMathWRTest.testExpAccuracy(FastMathWRTest.java:458)
	at FastMathWRTest.main(FastMathWRTest.java:18)

Regards,

Jeff


      was (Author: jeff):
    Hello.

William, I've also contracted the fast-math disease some time ago, which ended up into some FastMath class as well (http://sourceforge.net/projects/jafama).
Though, your form seems more severe, since you felt the need to stay within about +-0.5 ULP :)

Anyway, I did run my "FastMath" tests on your class (with the patch), and found some troubles with special cases, especially +-Infinity, NaN, or huge values:
see "test_fastmath_wr.zip" 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 ULP
	at FastMathWRTest.testExpAccuracy(FastMathWRTest.java:458)
	at FastMathWRTest.main(FastMathWRTest.java:18)

May it help you improve your treatments!

Regards,

Jeff

  
> 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
>             Fix For: 2.2
>
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877088#action_12877088 ] 

William Rossi commented on MATH-375:
------------------------------------


It hasn't yet been published, I was hoping to get it incorportated into 
larger project such as Commons Math.  With that in mind, I'm willing to 
issue an Apache License for it.

I'm not very familiar with all the procedures of licensing yet, it was 
suggested to me that I post it here and submit a license grant to the 
Apache Foundation separtely.   If that doesn't meet you needs, let me know 
what needs to be done.




> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Roman Werpachowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877139#action_12877139 ] 

Roman Werpachowski commented on MATH-375:
-----------------------------------------

Thanks for the clarification. Could the archive file, then, contain the license information under which it is published?

> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877110#action_12877110 ] 

Sebb commented on MATH-375:
---------------------------

Note that the dfp library is released under LGPL, so cannot be included in any ASF releases.

However it can be used as an optional dependency - which may well be sufficient here.

> 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.


[jira] Issue Comment Edited: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905210#action_12905210 ] 

Jeff Hain edited comment on MATH-375 at 9/1/10 4:44 PM:
--------------------------------------------------------

Hello.

William, I've also contracted the fast-math disease some time ago, which ended up into some FastMath class as well (http://sourceforge.net/projects/jafama).
Though, your form seems more severe, since you felt the need to stay within about +-0.5 ULP :)

Anyway, I did run my "FastMath" tests on your class, and found some troubles with special cases, especially +-Infinity, NaN, or huge values:
see "test_fastmath_wr.zip" 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 ULP
	at FastMathWRTest.testExpAccuracy(FastMathWRTest.java:458)
	at FastMathWRTest.main(FastMathWRTest.java:18)

May it help you improve your treatments!

Regards,

Jeff


      was (Author: jeff):
    Hello.

William, I've also contracted the fast-math disease some time ago, which ended up into some FastMath class as well (http://sourceforge.net/projects/jafama).
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 "test_fastmath_wr.zip" 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 ULP
	at FastMathWRTest.testExpAccuracy(FastMathWRTest.java:458)
	at FastMathWRTest.main(FastMathWRTest.java:18)

May it help you improve your treatments!

Regards,

Jeff

  
> 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
>             Fix For: 2.2
>
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Roman Werpachowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877149#action_12877149 ] 

Roman Werpachowski commented on MATH-375:
-----------------------------------------

Thanks a lot.

> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908340#action_12908340 ] 

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

Thanks Bill!
You're last patch for cubic root and for asin/acos tests has been checked in both trunk and branch 2.X.
It works fine and the cubic root function is pretty fast (about 30% faster than java.util.Math on my computer)

> 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
>             Fix For: 2.2
>
>         Attachments: asinacos-patch.txt.gz, atanpatch.txt.gz, cbrt-patch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903882#action_12903882 ] 

William Rossi commented on MATH-375:
------------------------------------


We can do that.  How do we proceed, do I write up another software grant? 
Its 6K lines of code not counting the example application which is another 
1K lines.




> 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
>             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 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Hain updated MATH-375:
---------------------------

    Comment: was deleted

(was: Jafama tests for William's FastMath
)

> 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
>             Fix For: 2.2
>
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Resolved: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe resolved MATH-375.
--------------------------------

    Resolution: Fixed

The asinacos patch fixing the errors identified by Jeff and adding the asin and acos functions has been committed in the subversion repository as of r992872.
The tests for FastMath depending on the dfp library have also been added as dfp in now a package in commons-math

Thanks for this contribution and the various fixes.

> 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
>             Fix For: 2.2
>
>         Attachments: asinacos-patch.txt.gz, atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12892134#action_12892134 ] 

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

I finally found some time to look at this proposal.
It is very impressive and I really want to include it.
As the code is rather long and has been developed outside of the Apache Software Foundation, could you send a signed Software Grant to the foundation (see [http://www.apache.org/licenses/#grants]) ? As you will see, the softaware grant is simply a license you grant, the intellectual property remains yours.
The best way would be to have it sent by fax or by mail with a detached gpg signature. Please refer to this Jira issue and the attached patch you already submitted.
Thanks a lot for this contribution.

> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Roman Werpachowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877081#action_12877081 ] 

Roman Werpachowski commented on MATH-375:
-----------------------------------------

Hi Bill,

this is a very nice piece of work which I would be happy to use in my project. Did you publish it anywhere under an Open Source license? The archive attached doesn't have any license information.

> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905314#action_12905314 ] 

William Rossi commented on MATH-375:
------------------------------------

Thanks Jeff.  I will take a look at your tests.   As for my test, the last number on the line shows the error in ULPs, so its just outside the threshold.  I may have set the tolerance a bit too tight.

> 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
>             Fix For: 2.2
>
>         Attachments: atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe updated MATH-375:
-------------------------------

    Fix Version/s: 2.2

We need to add this as soon as possible
A patch is available and it includes tests
Setting target version for fix to 2.2

> 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
>             Fix For: 2.2
>
>         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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12904248#action_12904248 ] 

William Rossi commented on MATH-375:
------------------------------------


The parameter "extra" to exp() is extra input percision such that x+extra 
is the input parameter.

The hiPrec[] inputs to exp and log are to return a higher precision output 
such that hiPrec[0] + hiPrec[1] is the desired result.

I'm currently working on implementations of asin and acos.




> 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
>             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 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Rossi updated MATH-375:
-------------------------------

    Attachment: atanpatch.txt.gz

The attached patch fixes the bugs you reported in atan2().  I didn't implement sqrt() because I can't really improve upon Math.sqrt().  The implementation in Math seems to get compiled into a single machine instruction and I can't really compete against that.   It might be reasonable to have FastMath.sqrt() simply call Math.sqrt() though.

As far as other functions go, if there are some that are higher priority than others, please let me know.

> 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
>             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 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902899#action_12902899 ] 

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

Thanks for the fix.
I think we will probably start with all missing functions implemented with a call to the corresponding Math function, This would allow people to simply do global search and replace for Math to FastMath and have a working setup.
>From my personal use, the higher priorities functions to be implemented with fast and accurate versions would be first asin, acos, then cbrt and later sinh, cosh, tanh.
For functions like nextUp, signum and the likes, we could use our own bit twiddling (we should also probably move MathUtil.nextAfter in the FastMath class too).
I still did not see the grant registered in Apache foundation files, did you sent it already ?

> 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
>             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 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908427#action_12908427 ] 

William Rossi commented on MATH-375:
------------------------------------

Thanks Luc,
Glad to hear it is working well for you.  I'll work on the hyperbolic functions next.

> 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
>             Fix For: 2.2
>
>         Attachments: asinacos-patch.txt.gz, atanpatch.txt.gz, cbrt-patch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Updated: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Rossi updated MATH-375:
-------------------------------

    Attachment: asinacos-patch.txt.gz

This patch fixes the issues found in Jeff's tests, and implements the asin() and acos() functions.

> 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
>             Fix For: 2.2
>
>         Attachments: asinacos-patch.txt.gz, atanpatch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917396#action_12917396 ] 

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

Thanks Bill,

Your latest patch for sinh, cosh and tanh has been applied to trunk (r1004044) and to branch 2.X (r1004045).
On my computer the improvement is about 35% faster than java.util.Math and 45% for sinh and tanh.

> 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
>             Fix For: 2.2
>
>         Attachments: asinacos-patch.txt.gz, atanpatch.txt.gz, cbrt-patch.txt.gz, cosh-patch.txt.gz, FastMath.tar.gz, test_fastmath_wr.zip
>
>
> 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903910#action_12903910 ] 

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

Yes, we would need another grant for that because grants are really specific to one piece of code.
It would also be better to open a new Jira issue for this and put a reference to this new issue number in the grant.

> 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
>             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 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903808#action_12903808 ] 

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

OK, then I'll simply raise the threshold a bit.

Offering dfp under a compatible license would help the project. The answer from our legal team concerning this toic can be found here: [http://www.apache.org/legal/resolved.html#category-a]. Here is the appropriate quote concerning LGPL from the previous link,:

{quote}
The LGPL is ineligible primarily due to the restrictions it places on larger works, violating the third license criterion. Therefore, LGPL-licensed works must not be included in Apache products.
{quote}

If you consider offering dfp on a dual license, would you also consider integrating it into commons-math too ? It would be a very nice addition I think.

> 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
>             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 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.


[jira] Commented: (MATH-375) Elementary functions in JDK are slower than necessary and not as accurate as they could be.

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903740#action_12903740 ] 

William Rossi commented on MATH-375:
------------------------------------


Yes, that can happen on occasion.

I'm the author and copyright holder on the dependant library (dfp) as 
well.  Would it help the project if I were to offer it under a dual 
license?   I'm concerned that it would take considerable effort to port 
the tests to another library.




> 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
>             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 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.