# efficient and accurate approximation of error function

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$$

-
Wiki suggests an approximation en.wikipedia.org/wiki/… – user17762 Jun 3 '11 at 2:37
possible duplicate of Definite integral of Normal Distribution – user17762 Jun 3 '11 at 2:43
– 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

"Efficient and accurate" is probably contradictory... Have you tried the one listed in http://en.wikipedia.org/wiki/Error_function#Approximation_with_elementary_functions ?

-
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

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

$$1-{\rm{erf}}(z)=e^{-z^2}w(iz)$$

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

-

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.

-
-
I will try this. thx – shaikh Jun 3 '11 at 2:42