Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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 am looking for the numerical approximation of error function, which must be efficient and accurate. Thanks in advance $$\mathrm{erf}(z)=\frac2{\sqrt\pi}\int_0^z e^{-t^2} \,\mathrm dt$$

share|cite|improve this question
Wiki suggests an approximation… – user17762 Jun 3 '11 at 2:37
possible duplicate of Definite integral of Normal Distribution – user17762 Jun 3 '11 at 2:43
Related:… – cardinal Jun 3 '11 at 8:30
possible duplicate of How to accurately calculate erf(x) with a computer? – J. M. Jul 23 '11 at 15:26
You will find implementations in most scientific libraries: cmlib, slatec, nswc, nag, imsl, harwell hsl... Also in gnu gsl, in R, probably octave and Scilab... You can also have a look at ACM TOMS Collected Algorithms. There are plenty of places to look for this. – Jean-Claude Arbaut Aug 27 '14 at 11:40
up vote 2 down vote accepted

"Efficient and accurate" is probably contradictory... Have you tried the one listed in ?

share|cite|improve this answer
yes, I have tried this. Its accuracy is up to 2 decimal places. Do we have more than this? – shaikh Jun 3 '11 at 2:40
@shaikh, C99 has an erf function, which should be quite accurate. – lhf Jun 3 '11 at 2:42
where can I find the derivation of C99 erf...? – shaikh Jun 3 '11 at 2:45
@shaikh, oh, you have to read the code. See for instance the cephes library. – lhf Jun 3 '11 at 2:48
@shaikh: Or boost's implementation – ziyuang Jun 3 '11 at 2:51

How about this: Computation of the error function erf in arbitrary precision with correct rounding

share|cite|improve this answer
I will try this. thx – shaikh Jun 3 '11 at 2:42

I know its an old post, but others stumbling upon this post might find it helpful. You can try the accurate approximate analytical expression for faster numerical evaluation such as this or answers in this post especially by Ron Gordon.

share|cite|improve this answer

It can be computed by using the complex error function (aka the Faddeeva function):


Matlab and C packages for the Faddeeva function are available in the Matlab Central.

share|cite|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.