Jmat.Real.erf

?

Percentage Accurate: 58.6% → 98.2%
Time: 1.3min
Precision: binary64
Cost: 98628

?

\[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} t_0 := \mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\\ \mathbf{if}\;\left|x\right| \leq 4 \cdot 10^{-13}:\\ \;\;\;\;\frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - x \cdot 1.128386358070218}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{e^{x \cdot \left(-x\right)}}{t_0} \cdot \left(0.254829592 + \left(\frac{1.421413741}{{t_0}^{2}} + \left(\left(\frac{-0.284496736}{t_0} + \frac{-1.453152027}{{t_0}^{3}}\right) + \frac{1.061405429}{{t_0}^{4}}\right)\right)\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
 (let* ((t_0 (fma 0.3275911 (fabs x) 1.0)))
   (if (<= (fabs x) 4e-13)
     (/
      (- 1e-18 (* (* x x) 1.2732557730789702))
      (- 1e-9 (* x 1.128386358070218)))
     (-
      1.0
      (*
       (/ (exp (* x (- x))) t_0)
       (+
        0.254829592
        (+
         (/ 1.421413741 (pow t_0 2.0))
         (+
          (+ (/ -0.284496736 t_0) (/ -1.453152027 (pow t_0 3.0)))
          (/ 1.061405429 (pow t_0 4.0))))))))))
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 t_0 = fma(0.3275911, fabs(x), 1.0);
	double tmp;
	if (fabs(x) <= 4e-13) {
		tmp = (1e-18 - ((x * x) * 1.2732557730789702)) / (1e-9 - (x * 1.128386358070218));
	} else {
		tmp = 1.0 - ((exp((x * -x)) / t_0) * (0.254829592 + ((1.421413741 / pow(t_0, 2.0)) + (((-0.284496736 / t_0) + (-1.453152027 / pow(t_0, 3.0))) + (1.061405429 / pow(t_0, 4.0))))));
	}
	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)
	t_0 = fma(0.3275911, abs(x), 1.0)
	tmp = 0.0
	if (abs(x) <= 4e-13)
		tmp = Float64(Float64(1e-18 - Float64(Float64(x * x) * 1.2732557730789702)) / Float64(1e-9 - Float64(x * 1.128386358070218)));
	else
		tmp = Float64(1.0 - Float64(Float64(exp(Float64(x * Float64(-x))) / t_0) * Float64(0.254829592 + Float64(Float64(1.421413741 / (t_0 ^ 2.0)) + Float64(Float64(Float64(-0.284496736 / t_0) + Float64(-1.453152027 / (t_0 ^ 3.0))) + Float64(1.061405429 / (t_0 ^ 4.0)))))));
	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_] := Block[{t$95$0 = N[(0.3275911 * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 4e-13], N[(N[(1e-18 - N[(N[(x * x), $MachinePrecision] * 1.2732557730789702), $MachinePrecision]), $MachinePrecision] / N[(1e-9 - N[(x * 1.128386358070218), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(N[Exp[N[(x * (-x)), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(0.254829592 + N[(N[(1.421413741 / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-0.284496736 / t$95$0), $MachinePrecision] + N[(-1.453152027 / N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.061405429 / N[Power[t$95$0, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
t_0 := \mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\\
\mathbf{if}\;\left|x\right| \leq 4 \cdot 10^{-13}:\\
\;\;\;\;\frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - x \cdot 1.128386358070218}\\

\mathbf{else}:\\
\;\;\;\;1 - \frac{e^{x \cdot \left(-x\right)}}{t_0} \cdot \left(0.254829592 + \left(\frac{1.421413741}{{t_0}^{2}} + \left(\left(\frac{-0.284496736}{t_0} + \frac{-1.453152027}{{t_0}^{3}}\right) + \frac{1.061405429}{{t_0}^{4}}\right)\right)\right)\\


\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 8 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Derivation?

  1. Split input into 2 regimes
  2. if (fabs.f64 x) < 4.0000000000000001e-13

    1. Initial program 57.8%

      \[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-rr57.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-\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)}}{{\left(e^{x}\right)}^{x} \cdot \mathsf{fma}\left(0.3275911, x, 1\right)}\right)}} \]
      Step-by-step derivation

      [Start]57.8%

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

      add-exp-log [=>]57.8%

      \[ \color{blue}{e^{\log \left(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|}\right)}} \]

      sub-neg [=>]57.8%

      \[ e^{\log \color{blue}{\left(1 + \left(-\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|}\right)\right)}} \]
    3. Simplified57.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{-0.254829592 - \frac{-0.284496736 + \frac{1.421413741 + \frac{-1.453152027 + \frac{1.061405429}{\mathsf{fma}\left(x, 0.3275911, 1\right)}}{\mathsf{fma}\left(x, 0.3275911, 1\right)}}{\mathsf{fma}\left(x, 0.3275911, 1\right)}}{\mathsf{fma}\left(x, 0.3275911, 1\right)}}{\mathsf{fma}\left(x, 0.3275911, 1\right) \cdot e^{x \cdot x}}\right)}} \]
      Step-by-step derivation

      [Start]57.8%

      \[ e^{\mathsf{log1p}\left(-\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)}}{{\left(e^{x}\right)}^{x} \cdot \mathsf{fma}\left(0.3275911, x, 1\right)}\right)} \]

      distribute-neg-frac [=>]57.8%

      \[ e^{\mathsf{log1p}\left(\color{blue}{\frac{-\left(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)}\right)}{{\left(e^{x}\right)}^{x} \cdot \mathsf{fma}\left(0.3275911, x, 1\right)}}\right)} \]
    4. Taylor expanded in x around 0 99.8%

      \[\leadsto \color{blue}{10^{-9} + 1.128386358070218 \cdot x} \]
    5. Simplified99.8%

      \[\leadsto \color{blue}{10^{-9} + x \cdot 1.128386358070218} \]
      Step-by-step derivation

      [Start]99.8%

      \[ 10^{-9} + 1.128386358070218 \cdot x \]

      *-commutative [=>]99.8%

      \[ 10^{-9} + \color{blue}{x \cdot 1.128386358070218} \]
    6. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{10^{-18} - \left(x \cdot 1.128386358070218\right) \cdot \left(x \cdot 1.128386358070218\right)}{10^{-9} - x \cdot 1.128386358070218}} \]
      Step-by-step derivation

      [Start]99.8%

      \[ 10^{-9} + x \cdot 1.128386358070218 \]

      flip-+ [=>]99.8%

      \[ \color{blue}{\frac{10^{-9} \cdot 10^{-9} - \left(x \cdot 1.128386358070218\right) \cdot \left(x \cdot 1.128386358070218\right)}{10^{-9} - x \cdot 1.128386358070218}} \]

      metadata-eval [=>]99.8%

      \[ \frac{\color{blue}{10^{-18}} - \left(x \cdot 1.128386358070218\right) \cdot \left(x \cdot 1.128386358070218\right)}{10^{-9} - x \cdot 1.128386358070218} \]
    7. Simplified99.8%

      \[\leadsto \color{blue}{\frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - 1.128386358070218 \cdot x}} \]
      Step-by-step derivation

      [Start]99.8%

      \[ \frac{10^{-18} - \left(x \cdot 1.128386358070218\right) \cdot \left(x \cdot 1.128386358070218\right)}{10^{-9} - x \cdot 1.128386358070218} \]

      swap-sqr [=>]99.8%

      \[ \frac{10^{-18} - \color{blue}{\left(x \cdot x\right) \cdot \left(1.128386358070218 \cdot 1.128386358070218\right)}}{10^{-9} - x \cdot 1.128386358070218} \]

      metadata-eval [=>]99.8%

      \[ \frac{10^{-18} - \left(x \cdot x\right) \cdot \color{blue}{1.2732557730789702}}{10^{-9} - x \cdot 1.128386358070218} \]

      *-commutative [=>]99.8%

      \[ \frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - \color{blue}{1.128386358070218 \cdot x}} \]

    if 4.0000000000000001e-13 < (fabs.f64 x)

    1. Initial program 71.6%

      \[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. Taylor expanded in x around 0 70.9%

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

      \[\leadsto \color{blue}{1 - \frac{e^{-{\left(\left|x\right|\right)}^{2}}}{\frac{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)}{0.254829592 + \left(\left(\frac{1.061405429}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{4}} + \frac{1.421413741}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{2}}\right) - \left(\frac{0.284496736}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)} + \frac{1.453152027}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{3}}\right)\right)}}} \]
      Step-by-step derivation

      [Start]70.9%

      \[ 1 - \frac{e^{-{\left(\left|x\right|\right)}^{2}} \cdot \left(\left(0.254829592 + \left(1.061405429 \cdot \frac{1}{{\left(0.3275911 \cdot \left|x\right| + 1\right)}^{4}} + 1.421413741 \cdot \frac{1}{{\left(1 + 0.3275911 \cdot \left|x\right|\right)}^{2}}\right)\right) - \left(1.453152027 \cdot \frac{1}{{\left(1 + 0.3275911 \cdot \left|x\right|\right)}^{2} \cdot \left(0.3275911 \cdot \left|x\right| + 1\right)} + 0.284496736 \cdot \frac{1}{1 + 0.3275911 \cdot \left|x\right|}\right)\right)}{1 + 0.3275911 \cdot \left|x\right|} \]
    4. Taylor expanded in x around 0 70.9%

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

      \[\leadsto 1 - \color{blue}{\frac{e^{-x \cdot x}}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)} \cdot \left(0.254829592 + \left(\frac{1.421413741}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{2}} + \left(\left(\frac{-0.284496736}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)} + \frac{-1.453152027}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{3}}\right) + \frac{1.061405429}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{4}}\right)\right)\right)} \]
      Step-by-step derivation

      [Start]70.9%

      \[ 1 - \frac{e^{-{\left(\left|x\right|\right)}^{2}} \cdot \left(\left(0.254829592 + \left(1.061405429 \cdot \frac{1}{{\left(1 + 0.3275911 \cdot \left|x\right|\right)}^{4}} + 1.421413741 \cdot \frac{1}{{\left(0.3275911 \cdot \left|x\right| + 1\right)}^{2}}\right)\right) - \left(1.453152027 \cdot \frac{1}{{\left(1 + 0.3275911 \cdot \left|x\right|\right)}^{2} \cdot \left(0.3275911 \cdot \left|x\right| + 1\right)} + 0.284496736 \cdot \frac{1}{1 + 0.3275911 \cdot \left|x\right|}\right)\right)}{1 + 0.3275911 \cdot \left|x\right|} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 4 \cdot 10^{-13}:\\ \;\;\;\;\frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - x \cdot 1.128386358070218}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{e^{x \cdot \left(-x\right)}}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)} \cdot \left(0.254829592 + \left(\frac{1.421413741}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{2}} + \left(\left(\frac{-0.284496736}{\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)} + \frac{-1.453152027}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{3}}\right) + \frac{1.061405429}{{\left(\mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\right)}^{4}}\right)\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy98.2%
Cost98628
\[\begin{array}{l} t_0 := \mathsf{fma}\left(0.3275911, \left|x\right|, 1\right)\\ \mathbf{if}\;\left|x\right| \leq 4 \cdot 10^{-13}:\\ \;\;\;\;\frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - x \cdot 1.128386358070218}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{e^{x \cdot \left(-x\right)}}{t_0} \cdot \left(0.254829592 + \left(\frac{1.421413741}{{t_0}^{2}} + \left(\left(\frac{-0.284496736}{t_0} + \frac{-1.453152027}{{t_0}^{3}}\right) + \frac{1.061405429}{{t_0}^{4}}\right)\right)\right)\\ \end{array} \]
Alternative 2
Accuracy98.2%
Cost48516
\[\begin{array}{l} t_0 := 1 + \left|x\right| \cdot 0.3275911\\ t_1 := \frac{1}{t_0}\\ \mathbf{if}\;\left|x\right| \leq 4 \cdot 10^{-13}:\\ \;\;\;\;\frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - x \cdot 1.128386358070218}\\ \mathbf{else}:\\ \;\;\;\;1 + e^{x \cdot \left(-x\right)} \cdot \left(t_1 \cdot \left(\left(-0.284496736 + t_1 \cdot \left(1.421413741 + t_1 \cdot \left(-1.453152027 + 1.061405429 \cdot t_1\right)\right)\right) \cdot \frac{-1}{t_0} - 0.254829592\right)\right)\\ \end{array} \]
Alternative 3
Accuracy98.2%
Cost48388
\[\begin{array}{l} t_0 := 1 + \left|x\right| \cdot 0.3275911\\ t_1 := \frac{1}{t_0}\\ \mathbf{if}\;\left|x\right| \leq 4 \cdot 10^{-13}:\\ \;\;\;\;\frac{10^{-18} - \left(x \cdot x\right) \cdot 1.2732557730789702}{10^{-9} - x \cdot 1.128386358070218}\\ \mathbf{else}:\\ \;\;\;\;1 + t_1 \cdot \left(e^{x \cdot \left(-x\right)} \cdot \left(\left(-0.284496736 + t_1 \cdot \left(1.421413741 + t_1 \cdot \left(-1.453152027 + \frac{1.061405429}{t_0}\right)\right)\right) \cdot \frac{-1}{t_0} - 0.254829592\right)\right)\\ \end{array} \]
Alternative 4
Accuracy97.4%
Cost41988
\[\begin{array}{l} t_0 := 1 + \left|x\right| \cdot 0.3275911\\ t_1 := \frac{1}{t_0}\\ t_2 := x \cdot \left(1.128386358070218 + x \cdot -0.00011824294398844343\right)\\ \mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{10^{-18} - {t_2}^{2}}{10^{-9} - t_2}\\ \mathbf{else}:\\ \;\;\;\;1 + t_1 \cdot \left(e^{x \cdot \left(-x\right)} \cdot \left(\left(-0.284496736 + t_1 \cdot \left(1.421413741 + \left(-1.453152027 + \frac{1.061405429}{t_0}\right) \cdot \frac{1}{1 + x \cdot 0.3275911}\right)\right) \cdot \frac{-1}{t_0} - 0.254829592\right)\right)\\ \end{array} \]
Alternative 5
Accuracy96.4%
Cost7680
\[\begin{array}{l} t_0 := x \cdot \left(1.128386358070218 + x \cdot -0.00011824294398844343\right)\\ \frac{10^{-18} - {t_0}^{2}}{10^{-9} - t_0} \end{array} \]
Alternative 6
Accuracy96.4%
Cost576
\[10^{-9} + x \cdot \left(1.128386358070218 + x \cdot -0.00011824294398844343\right) \]
Alternative 7
Accuracy96.2%
Cost320
\[10^{-9} + x \cdot 1.128386358070218 \]
Alternative 8
Accuracy94.8%
Cost64
\[10^{-9} \]

Reproduce?

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