Average Error: 3.1 → 1.1
Time: 2.6s
Precision: binary64
\[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 6.79382622630013 \cdot 10^{-310}:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\mathsf{fma}\left(1.1283791670955126, e^{z}, -x \cdot y\right)}\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
(FPCore (x y z)
 :precision binary64
 (if (<= (exp z) 6.79382622630013e-310)
   (+ x (/ -1.0 x))
   (+ x (/ y (fma 1.1283791670955126 (exp z) (- (* x y)))))))
double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
double code(double x, double y, double z) {
	double tmp;
	if (exp(z) <= 6.79382622630013e-310) {
		tmp = x + (-1.0 / x);
	} else {
		tmp = x + (y / fma(1.1283791670955126, exp(z), -(x * y)));
	}
	return tmp;
}
function code(x, y, z)
	return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y))))
end
function code(x, y, z)
	tmp = 0.0
	if (exp(z) <= 6.79382622630013e-310)
		tmp = Float64(x + Float64(-1.0 / x));
	else
		tmp = Float64(x + Float64(y / fma(1.1283791670955126, exp(z), Float64(-Float64(x * y)))));
	end
	return tmp
end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[N[Exp[z], $MachinePrecision], 6.79382622630013e-310], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(1.1283791670955126 * N[Exp[z], $MachinePrecision] + (-N[(x * y), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 6.79382622630013 \cdot 10^{-310}:\\
\;\;\;\;x + \frac{-1}{x}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\mathsf{fma}\left(1.1283791670955126, e^{z}, -x \cdot y\right)}\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original3.1
Target0.0
Herbie1.1
\[x + \frac{1}{\frac{1.1283791670955126}{y} \cdot e^{z} - x} \]

Derivation

  1. Split input into 2 regimes
  2. if (exp.f64 z) < 6.793826226300134e-310

    1. Initial program 8.0

      \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
    2. Simplified8.0

      \[\leadsto \color{blue}{x + \frac{y}{\mathsf{fma}\left(1.1283791670955126, e^{z}, -x \cdot y\right)}} \]
    3. Taylor expanded in y around inf 0.0

      \[\leadsto x + \color{blue}{\frac{-1}{x}} \]

    if 6.793826226300134e-310 < (exp.f64 z)

    1. Initial program 1.5

      \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
    2. Simplified1.5

      \[\leadsto \color{blue}{x + \frac{y}{\mathsf{fma}\left(1.1283791670955126, e^{z}, -x \cdot y\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{z} \leq 6.79382622630013 \cdot 10^{-310}:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\mathsf{fma}\left(1.1283791670955126, e^{z}, -x \cdot y\right)}\\ \end{array} \]

Reproduce

herbie shell --seed 2022152 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (+ x (/ 1.0 (- (* (/ 1.1283791670955126 y) (exp z)) x)))

  (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))