# What is the best way to get erfi with scipy?

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.

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

Erfi is available from the mpmath library.

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