The error function (erf) is defined by the following equation:
The complementary error function (erfc) is defined by the following equation:
To obtain these numerical solutions, use the following equations:
Taylor series:
Continued fraction expansion:
First, Taylor series convergence becomes slow as the absolute value of z increases.
The absolute value of each term is as follows:
The behavior for each z:
The ratio to the next term is less than 1:
The number of terms required to obtain arbitrary precision is as follows:
In addition, in order to obtain the expected value, 128-bit expansion was performed to absorb cancellation.
Next, in Continued fraction expansion, when the absolute value of z is small, the convergence becomes slow.
Replace continued fractions:
The recursive part can be written below:
The fixed points at n = 1 are:
These approximate the true values:
Solve the continued fraction F1 (z) backward with X4 (z) as the initial value.
Let N be the recursion times (Fn+4(z) to Fn(z)), and N until convergence is as follows:
The calculation error is at most 2 epsilons.
C# code
erf result
erfc result
inverse erf result
inverse erfc result
The following is used to approximate the error of machine epsilon in the entire domain.
pade erf precision16
pade erf precision32
pade erfc precision16
pade erfc precision32