BUG: special: fix accuracy issues in complex erf by reimplementing it #340

Closed
wants to merge 14 commits into
from

Conversation

Projects
None yet
2 participants
Owner

pv commented Oct 20, 2012

The reimplementation is in terms of a (shifted) Faddeeva function, falling back to an asymptotic expansion when the Faddeeva exponential scaling factor overflows.

Fixes Trac #1207, Trac #1699 (probably), and addresses the complaint on the mailing list, http://article.gmane.org/gmane.comp.python.scientific.user/32959

Need to also consider submitting these erf/erfc implementations back to the Faddeeva_w.cc authors (needs some minor rewriting in C).

Owner

pv commented Oct 28, 2012

The complex product in exp(-z^2) * w(i z) unfortunately seems to lose precision around the real axis, so this implementation is still not fully ULP accurate for the real and imag parts separately:

>>> from scipy.special import erf
>>> from mpmath import erf as erf2
>>> import mpmath
>>> mpmath.mp.dps = 300
>>> erf(6+1e-30j)
(0.99999999999999989-1.4012984643248171e-45j)
>>> complex(erf2(6+1e-30j))
(0.9999999999999999+2.6173012392492647e-46j)

Needs still some work...

Owner

pv commented Nov 3, 2012

Re-done implementation from Steven G. Johnson.

This seems to work completely fine, and I think we're merge-ready now.
This PR closes Trac #1207, #1699, #1757, #1758, #1759

Owner

pv commented Nov 4, 2012

One more update from upstream. Still looks merge-ready to me.

pv and others added some commits Nov 4, 2012

BLD: fix python 3.x compilation and include missing files in sdist ar…
…chives.

Also include Cython files, we should be shipping those even if they're not
necessary to build scipy at present.
Owner

rgommers commented Nov 4, 2012

Can you include the fix for sdists and py3k from https://github.com/rgommers/scipy/tree/fix-cerf (last commit)? Other than that it looks good to me.

pv added a commit that referenced this pull request Nov 4, 2012

Merge pull request #340 from pv/fix-cerf
BUG: special: fix accuracy issues in complex erf by using a different implementation

This PR changes complex-valued erf family functions to use implementations from
Steven G. Johnson's Faddeeva package. This is more numerically stable than the
previously used implementation.

Closes Trac #1207, #1699, #1757, #1758, #1759
Owner

pv commented Nov 4, 2012

Ok, went ahead and merged.

@pv pv closed this Nov 4, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment