Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyperg is wrong for large negative x (Trac #659) #1186

Closed
scipy-gitbot opened this issue Apr 25, 2013 · 6 comments
Closed

hyperg is wrong for large negative x (Trac #659) #1186

scipy-gitbot opened this issue Apr 25, 2013 · 6 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac scipy.special
Milestone

Comments

@scipy-gitbot
Copy link

Original ticket http://projects.scipy.org/scipy/ticket/659 on 2008-04-29 by trac user helias, assigned to unknown.

=== problem ===
The evaluation of hyperg (hyp1f1, real arguments) yields wrong results for large negative x=-30.
The problem appeared with changeset 3012, where Kahan's summation formula was applied. The problem seems to be a too optimistic error estimate in Kahan's summation: The error estimation of hy1f1p (special/cehpes/hyperg.c) is always in the range of machine resolution, but the actual error is much larger due to cancelation in the strongly alternating series (for negative x). Hence, hyperg always returns the result of hy1f1p, even, if hy1f1a would be better (as for large negative x).[[BR]]
Restoring the old error estimation based on the maximum term yields a too high error estimates.

=== possible solution ===
Resorting to the fortran function chgm in specfun/specfun.f also works for negative x=-30.

@scipy-gitbot
Copy link
Author

Attachment added by trac user helias on 2008-04-29: hyp1f1_ticket.py

@scipy-gitbot
Copy link
Author

trac user helias wrote on 2008-05-29

Here is a patch based on revision 4393 made from the scipy root directory (scipy_4393_hyp1f1_chgm.patch).[[BR]]

It replaces the implementation hyperg in special/cephes/hyperg.c with the implementation chgm in special/specfun/specfun.f for the function hyp1f1 (real arguments).

@scipy-gitbot
Copy link
Author

Attachment added by trac user helias on 2008-05-29: scipy_4393_hyp1f1_chgm.patch

@scipy-gitbot
Copy link
Author

Attachment added by trac user helias on 2008-05-29: test_hyp1f1.nb

@scipy-gitbot
Copy link
Author

Attachment added by trac user helias on 2008-05-29: hyp1f1_test.py

@scipy-gitbot
Copy link
Author

@wnbell wrote on 2008-06-24

added in 55c40c5

I found that the maximum relative error was about 5e-5, does that match your expectations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac scipy.special
Projects
None yet
Development

No branches or pull requests

1 participant