public static double Erf(double v0) {
// Calculate the error function using the approximation method outlined in
// W. J. Cody's "Rational Chebyshev Approximations for the Error Function"
if (v0 >= 10.0) {
return 1.0;
} else if (v0 <= -10.0) {
return -1.0;
}
if (v0 > 0.47 || v0 < -0.47) {
return 1.0 - ErfComplement(v0);
}
double sq = v0 * v0;
double numer = EvalPolynomial(sq, ErfNumerCoeffs);
double denom = EvalPolynomial(sq, ErfDenomCoeffs);
return v0 * numer / denom;
}