An implementation of pure python can be found in the mpmath module ( http://code.google.com/p/mpmath/ )
From the document line:
>>> from mpmath import * >>> mp.dps = 15 >>> print erf(0) 0.0 >>> print erf(1) 0.842700792949715 >>> print erf(-1) -0.842700792949715 >>> print erf(inf) 1.0 >>> print erf(-inf) -1.0
For large real x , \mathrm{erf}(x) approaches 1 quickly:
>>> print erf(3) 0.999977909503001 >>> print erf(5) 0.999999999998463
The error function is an odd function:
>>> nprint(chop(taylor(erf, 0, 5))) [0.0, 1.12838, 0.0, -0.376126, 0.0, 0.112838]
: func: erf implements arbitrary precision and supports complex numbers ::
>>> mp.dps = 50 >>> print erf(0.5) 0.52049987781304653768274665389196452873645157575796 >>> mp.dps = 25 >>> print erf(1+j) (1.316151281697947644880271 + 0.1904534692378346862841089j)
Related functions
See also: func: erfc , which is more accurate for large x , and: func: erfi , which gives the primitive \exp(t^2) .
Fresnel integrals: func: fresnels and: func: fresnelc also associated with the error function.
Charles McCreary Jan 20 '09 at 21:44 2009-01-20 21:44
source share