Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I want this:

http://mathworld.wolfram.com/Erfi.html

But apparently scipy does not have this in its extensive special functions library.

http://docs.scipy.org/doc/scipy/reference/special.html

It is not the same as erfinv. Right now I am using an obscure identity involving the hyp1f1 hypergeometric function but I would rather use a nicer function if possible. Also I'll pre-emptively say that I would rather not deal with complex numbers, because the inputs and outputs are all real.

share|improve this question
3  
How about np.real(-1j * sp.special.erf(1j * x))? –  datageist Aug 29 '12 at 2:01

3 Answers 3

up vote 5 down vote accepted

Erfi is available from the mpmath library.

See documentation here: http://mpmath.googlecode.com/svn/trunk/doc/build/functions/expintegrals.html#mpmath.erfi

Here is a link to the library: https://code.google.com/p/mpmath/

share|improve this answer
    
Thanks, I'll accept this because it is a good answer and I didn't mention mpmath in my question. I would still be interested to see a better scipy hack. –  none Aug 29 '12 at 1:35

The correct answer in SciPy is given by datageist in his comment:

(-1.0j)*scipy.special.erf((-1.0j*x))

share|improve this answer

Unfortunately, in SciPy 0.11 or earlier, the erf function is rather inaccurate for complex arguments. However, SciPy 0.12 will contain accurate complex erf support and includes an optimized erfi function. Alternatively, you can use the scipy.special.dawsn function, which computes the Dawson function, a scaled erfi function. erfi(x) is then given by (2/sqrt(pi)) * exp(x^2) * dawsn(x).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.