Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want this:

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

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
How about np.real(-1j * sp.special.erf(1j * x))? – datageist Aug 29 '12 at 2:01
up vote 5 down vote accepted

Erfi is available from the mpmath library.

See documentation here:

Here is a link to the library:

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:


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


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.