Returns an approximation of the error function:
For abs(x) < 1, DPlot uses the approximation:
and iterates until any additional term is less than 1.E-10 times the current solution. In general the series converges within several steps for small x and takes up to 15 terms before converging to the solution for x close to 1.0.
For abs(x) > 1 DPlot uses an approximating 9th order polynomial that is accurate to +/- 1.E-7 for all values of x:
z = abs(x)
t = 1./(1.+0.5*z)
erf = 1.-t*exp(-z*z -1.26551223 +
t*( 1.00002368 +
t*( 3.7409196E-1 +
t*( 9.678418E-2 +
t*(-1.8628806E-1 +
t*( 2.7886807E-1 +
t*(-1.13520398 +
t*( 1.48851587 +
t*(-8.2215223E-1 +
t* 1.7087277E-1 )))))))))
____________________________
See also: