c$Header: /weru/cvs/weps/weps.src/util/math/old.src/gerf.for,v 1.1.1.1 1999-03-12 17:05:32 wagner Exp $ c real function erf i (z) c c + + + PURPOSE + + + c Computes erf(z) via a rational approximation for z>=0 c see 'HANDBOOK OF MATH. FUNCTIONS', c M. Abramowitz & .A.Segun, Dover Publications 1965 c pg 299 equation 7.1.26 c coded by G. Cole. c + + + KEYWORDS + + + c erf, error function c + + + ARGUMENT DECLARATIONS + + + real z c + + + ARGUMENT DEFINITIONS + + + c z - real value for values >= 0 c c + + + LOCAL VARIABLES + + + double precision a(5), b double precision prod, sum, t, x integer i c c + + + END SPECIFICATIONS + + + c c Done to avoid the need for a double precision argument x = z c Initialization a(1)= 0.254829592 a(2)= -0.284496736 a(3)= 1.421413741 a(4)= -1.453152027 a(5)= 1.061405429 b= 0.3275911 c Null Accumulators sum=0.0 prod=1.0 t= 1.0/( 1.0 + b * x) c erf= 1-(a1*t +a2*t**2 +a3*t**3+ a4*t**4 + a5*t**5)* dexp(-x**2) do 10 i=1,5 prod= t * prod sum= a(i) * prod + sum 10 continue erf= 1.0 - sum * dexp(-x**2) return end