Average Error: 13.5 → 0.8
Time: 11.8s
Precision: binary64
Cost: 47240
\[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}\;x \leq -5535816155.602623:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.846986576458453 \cdot 10^{-7}:\\ \;\;\;\;10^{-9} + \sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-0.254829592 - \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right) \cdot {\left(e^{x}\right)}^{x}}\\ \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 (<= x -5535816155.602623)
   1.0
   (if (<= x 8.846986576458453e-7)
     (+ 1e-9 (sqrt (* (* x x) 1.2732557730789702)))
     (+
      1.0
      (/
       (-
        -0.254829592
        (/
         (+
          -0.284496736
          (/
           (+
            1.421413741
            (/
             (+ -1.453152027 (/ 1.061405429 (fma 0.3275911 x 1.0)))
             (fma 0.3275911 x 1.0)))
           (fma 0.3275911 x 1.0)))
         (fma 0.3275911 x 1.0)))
       (* (fma 0.3275911 x 1.0) (pow (exp x) 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 (x <= -5535816155.602623) {
		tmp = 1.0;
	} else if (x <= 8.846986576458453e-7) {
		tmp = 1e-9 + sqrt(((x * x) * 1.2732557730789702));
	} else {
		tmp = 1.0 + ((-0.254829592 - ((-0.284496736 + ((1.421413741 + ((-1.453152027 + (1.061405429 / fma(0.3275911, x, 1.0))) / fma(0.3275911, x, 1.0))) / fma(0.3275911, x, 1.0))) / fma(0.3275911, x, 1.0))) / (fma(0.3275911, x, 1.0) * pow(exp(x), x)));
	}
	return tmp;
}
function code(x)
	return Float64(1.0 - Float64(Float64(Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) * Float64(0.254829592 + Float64(Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) * Float64(-0.284496736 + Float64(Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) * Float64(1.421413741 + Float64(Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) * Float64(-1.453152027 + Float64(Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) * 1.061405429))))))))) * exp(Float64(-Float64(abs(x) * abs(x))))))
end
function code(x)
	tmp = 0.0
	if (x <= -5535816155.602623)
		tmp = 1.0;
	elseif (x <= 8.846986576458453e-7)
		tmp = Float64(1e-9 + sqrt(Float64(Float64(x * x) * 1.2732557730789702)));
	else
		tmp = Float64(1.0 + Float64(Float64(-0.254829592 - Float64(Float64(-0.284496736 + Float64(Float64(1.421413741 + Float64(Float64(-1.453152027 + Float64(1.061405429 / fma(0.3275911, x, 1.0))) / fma(0.3275911, x, 1.0))) / fma(0.3275911, x, 1.0))) / fma(0.3275911, x, 1.0))) / Float64(fma(0.3275911, x, 1.0) * (exp(x) ^ x))));
	end
	return tmp
end
code[x_] := N[(1.0 - N[(N[(N[(1.0 / N[(1.0 + N[(0.3275911 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.254829592 + N[(N[(1.0 / N[(1.0 + N[(0.3275911 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.284496736 + N[(N[(1.0 / N[(1.0 + N[(0.3275911 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.421413741 + N[(N[(1.0 / N[(1.0 + N[(0.3275911 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.453152027 + N[(N[(1.0 / N[(1.0 + N[(0.3275911 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.061405429), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := If[LessEqual[x, -5535816155.602623], 1.0, If[LessEqual[x, 8.846986576458453e-7], N[(1e-9 + N[Sqrt[N[(N[(x * x), $MachinePrecision] * 1.2732557730789702), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(-0.254829592 - N[(N[(-0.284496736 + N[(N[(1.421413741 + N[(N[(-1.453152027 + N[(1.061405429 / N[(0.3275911 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.3275911 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.3275911 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.3275911 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(0.3275911 * x + 1.0), $MachinePrecision] * N[Power[N[Exp[x], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
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}\;x \leq -5535816155.602623:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 8.846986576458453 \cdot 10^{-7}:\\
\;\;\;\;10^{-9} + \sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{-0.254829592 - \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right) \cdot {\left(e^{x}\right)}^{x}}\\


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if x < -5535816155.602623

    1. Initial program 0

      \[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|} \]
    2. Applied egg-rr0

      \[\leadsto 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 \color{blue}{\left(1 \cdot \left(1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}\right)\right)}\right)\right)\right) \cdot e^{-\left|x\right| \cdot \left|x\right|} \]
    3. Taylor expanded in x around inf 0

      \[\leadsto \color{blue}{1 - \frac{e^{-{\left(\left|x\right|\right)}^{2}} \cdot \left(\left(0.254829592 + 1.421413741 \cdot \frac{1}{{\left(0.3275911 \cdot \left|x\right| + 1\right)}^{2}}\right) - 0.284496736 \cdot \frac{1}{0.3275911 \cdot \left|x\right| + 1}\right)}{0.3275911 \cdot \left|x\right| + 1}} \]
    4. Simplified0

      \[\leadsto \color{blue}{1 + \frac{\frac{\frac{0.284496736}{\mathsf{fma}\left(0.3275911, x, 1\right)} - \left(0.254829592 + \frac{1.421413741}{{\left(\mathsf{fma}\left(0.3275911, x, 1\right)\right)}^{2}}\right)}{{\left(e^{x}\right)}^{x}}}{\mathsf{fma}\left(0.3275911, x, 1\right)}} \]
    5. Taylor expanded in x around inf 0

      \[\leadsto \color{blue}{1} \]

    if -5535816155.602623 < x < 8.8469865764584534e-7

    1. Initial program 26.4

      \[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|} \]
    2. Applied egg-rr28.4

      \[\leadsto \color{blue}{1 + \frac{0.254829592 + \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)} \cdot \left(-{\left(e^{x}\right)}^{x}\right)} \]
    3. Taylor expanded in x around 0 2.9

      \[\leadsto \color{blue}{10^{-9} + 1.128386358070218 \cdot x} \]
    4. Applied egg-rr1.4

      \[\leadsto 10^{-9} + \color{blue}{\sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}} \]

    if 8.8469865764584534e-7 < x

    1. Initial program 0.2

      \[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|} \]
    2. Simplified0.2

      \[\leadsto \color{blue}{1 + \frac{-0.254829592 - \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)}}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)}}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)}}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)}}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right) \cdot {\left(e^{x}\right)}^{x}}} \]
    3. Applied egg-rr0.2

      \[\leadsto \color{blue}{{\left({\left(1 + \frac{-0.254829592 - \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right) \cdot {\left(e^{x}\right)}^{x}}\right)}^{3}\right)}^{0.3333333333333333}} \]
    4. Applied egg-rr0.2

      \[\leadsto \color{blue}{1 + \frac{-0.254829592 - \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right) \cdot {\left(e^{x}\right)}^{x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5535816155.602623:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.846986576458453 \cdot 10^{-7}:\\ \;\;\;\;10^{-9} + \sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-0.254829592 - \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right) \cdot {\left(e^{x}\right)}^{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error1.0
Cost33672
\[\begin{array}{l} \mathbf{if}\;x \leq -5535816155.602623:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.846986576458453 \cdot 10^{-7}:\\ \;\;\;\;10^{-9} + \sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-0.254829592 - \frac{-0.284496736 + \frac{1.029667143}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right)}}{\mathsf{fma}\left(0.3275911, x, 1\right) \cdot {\left(e^{x}\right)}^{x}}\\ \end{array} \]
Alternative 2
Error1.0
Cost20360
\[\begin{array}{l} \mathbf{if}\;x \leq -5535816155.602623:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.846986576458453 \cdot 10^{-7}:\\ \;\;\;\;10^{-9} + \sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\frac{x \cdot 0.9312849819386102 + -1.391746597}{{\left(e^{x}\right)}^{x}}}{\mathsf{fma}\left(0.3275911, x, 1\right)}\\ \end{array} \]
Alternative 3
Error0.9
Cost7240
\[\begin{array}{l} \mathbf{if}\;x \leq -5535816155.602623:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.8188976769651339:\\ \;\;\;\;10^{-9} + \sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\frac{-0.7778892405807117}{x}}{e^{x \cdot x}}\\ \end{array} \]
Alternative 4
Error0.9
Cost7112
\[\begin{array}{l} \mathbf{if}\;x \leq -5535816155.602623:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.8188976769651339:\\ \;\;\;\;10^{-9} + \sqrt{\left(x \cdot x\right) \cdot 1.2732557730789702}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error1.0
Cost968
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9082811248979866 \cdot 10^{-7}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.8188976769651339:\\ \;\;\;\;\left(10^{-9} + x \cdot 1.128386358070218\right) + \left(x \cdot x\right) \cdot -0.00011824294398844343\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error1.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9082811248979866 \cdot 10^{-7}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.8188976769651339:\\ \;\;\;\;10^{-9} + x \cdot 1.128386358070218\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error2.0
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -5535816155.602623:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.846986576458453 \cdot 10^{-7}:\\ \;\;\;\;10^{-9}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error29.8
Cost64
\[10^{-9} \]

Error

Reproduce

herbie shell --seed 2022228 
(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)))))))