1 - \left(\frac{1}{1 + 0.3275911 \cdot \left|x\right|} \cdot \left(0.254829592 + \frac{1}{1 + 0.3275911 \cdot \left|x\right|} \cdot \left(-0.284496736 + \frac{1}{1 + 0.3275911 \cdot \left|x\right|} \cdot \left(1.421413741 + \frac{1}{1 + 0.3275911 \cdot \left|x\right|} \cdot \left(-1.453152027 + \frac{1}{1 + 0.3275911 \cdot \left|x\right|} \cdot 1.061405429\right)\right)\right)\right)\right) \cdot e^{-\left|x\right| \cdot \left|x\right|}\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2.9221847357607688 \cdot 10^{-19}:\\
\;\;\;\;1.0000000272292198 \cdot 10^{-09} + 1.0000000272292198 \cdot 10^{-09} \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\frac{0.254829592}{1 + \left|x\right| \cdot 0.3275911} + \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{1 + \left|x\right| \cdot 0.3275911}}{1 + \left|x\right| \cdot 0.3275911}}{1 + \left|x\right| \cdot 0.3275911}}{\left(1 + \left|x\right| \cdot 0.3275911\right) \cdot \left(1 + \left|x\right| \cdot 0.3275911\right)}\right) \cdot e^{-\left|x\right| \cdot \left|x\right|}\\
\end{array}(FPCore (x)
:precision binary64
(-
1.0
(*
(*
(/ 1.0 (+ 1.0 (* 0.3275911 (fabs x))))
(+
0.254829592
(*
(/ 1.0 (+ 1.0 (* 0.3275911 (fabs x))))
(+
-0.284496736
(*
(/ 1.0 (+ 1.0 (* 0.3275911 (fabs x))))
(+
1.421413741
(*
(/ 1.0 (+ 1.0 (* 0.3275911 (fabs x))))
(+
-1.453152027
(* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) 1.061405429)))))))))
(exp (- (* (fabs x) (fabs x)))))))(FPCore (x)
:precision binary64
(if (<= (fabs x) 2.9221847357607688e-19)
(+ 1.0000000272292198e-09 (* 1.0000000272292198e-09 (pow x 3.0)))
(-
1.0
(*
(+
(/ 0.254829592 (+ 1.0 (* (fabs x) 0.3275911)))
(/
(+
-0.284496736
(/
(+
1.421413741
(/
(+ -1.453152027 (/ 1.061405429 (+ 1.0 (* (fabs x) 0.3275911))))
(+ 1.0 (* (fabs x) 0.3275911))))
(+ 1.0 (* (fabs x) 0.3275911))))
(* (+ 1.0 (* (fabs x) 0.3275911)) (+ 1.0 (* (fabs x) 0.3275911)))))
(exp (- (* (fabs x) (fabs x))))))))double code(double x) {
return 1.0 - (((1.0 / (1.0 + (0.3275911 * fabs(x)))) * (0.254829592 + ((1.0 / (1.0 + (0.3275911 * fabs(x)))) * (-0.284496736 + ((1.0 / (1.0 + (0.3275911 * fabs(x)))) * (1.421413741 + ((1.0 / (1.0 + (0.3275911 * fabs(x)))) * (-1.453152027 + ((1.0 / (1.0 + (0.3275911 * fabs(x)))) * 1.061405429))))))))) * exp(-(fabs(x) * fabs(x))));
}
double code(double x) {
double tmp;
if (fabs(x) <= 2.9221847357607688e-19) {
tmp = 1.0000000272292198e-09 + (1.0000000272292198e-09 * pow(x, 3.0));
} else {
tmp = 1.0 - (((0.254829592 / (1.0 + (fabs(x) * 0.3275911))) + ((-0.284496736 + ((1.421413741 + ((-1.453152027 + (1.061405429 / (1.0 + (fabs(x) * 0.3275911)))) / (1.0 + (fabs(x) * 0.3275911)))) / (1.0 + (fabs(x) * 0.3275911)))) / ((1.0 + (fabs(x) * 0.3275911)) * (1.0 + (fabs(x) * 0.3275911))))) * exp(-(fabs(x) * fabs(x))));
}
return tmp;
}



Bits error versus x
Results
if (fabs.f64 x) < 2.9221847357607688e-19Initial program 28.0
Taylor expanded around 0 0.2
if 2.9221847357607688e-19 < (fabs.f64 x) Initial program 1.3
rmApplied distribute-rgt-in_binary641.3
Simplified1.3
Simplified1.3
Final simplification0.8
herbie shell --seed 2020268
(FPCore (x)
:name "Jmat.Real.erf"
:precision binary64
(- 1.0 (* (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ 0.254829592 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ -0.284496736 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ 1.421413741 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ -1.453152027 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) 1.061405429))))))))) (exp (- (* (fabs x) (fabs x)))))))