Skip to main content

erf

erf (num [, accuracy ])​

The erf function returns the error function of num.

erf⁡(x)=2π∫0xe−t2dt.\displaystyle \operatorname{erf}(x)=\frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^{2}} d t.

Optionally, accuracy can be used to specify the desired fractional accuracy.

In complex expressions the error function is defined by

erf⁡(z)=2zπ1F1(12;32;−z2),\displaystyle \operatorname{erf}(z)=\frac{2 z}{\sqrt{\pi}}{ }_{1} F_{1}\left(\frac{1}{2} ; \frac{3}{2} ;-z^{2}\right),

where

1F1(12;32;−z2)\displaystyle { }_{1} F_{1}\left(\frac{1}{2} ; \frac{3}{2} ;-z^{2}\right)

is the confluent hypergeometric function of the first kind HyperG1F1. In this case the accuracy parameter is ignored.

Details​

The accuracy parameter specifies the fractional accuracy that you desire. That is, if you set accuracy to 1e-7, that means that you wish that the absolute value of (factual-freturned)/factual be less than 10-7.

For backwards compatibility, in the absence of accuracy an alternate calculation method is used that achieves fractional accuracy better than about 2x10-7.

If accuracy is present, erf can achieve fractional accuracy better than 8x10-16 for num as small as 10-3. For smaller num fractional accuracy is better than 5x10-15.

Higher accuracy takes somewhat longer to calculate. With accuracy set to 1e-16 erfc takes about 50% more time than with accuracy set to 1e-7.

See Also​

erfc, erfcw, inverseErf, inverseErfc, dawson