Average Error: 2.9 → 0.0
Time: 11.1s
Precision: 64
\[x + \frac{y}{1.128379167095512558560699289955664426088 \cdot e^{z} - x \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;e^{z} \le 3.092591263638519174288646452015294168288 \cdot 10^{-306}:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\mathsf{fma}\left(-x, y, 1.128379167095512558560699289955664426088 \cdot e^{z}\right)}\\ \end{array}\]
x + \frac{y}{1.128379167095512558560699289955664426088 \cdot e^{z} - x \cdot y}
\begin{array}{l}
\mathbf{if}\;e^{z} \le 3.092591263638519174288646452015294168288 \cdot 10^{-306}:\\
\;\;\;\;x - \frac{1}{x}\\

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

\end{array}
double f(double x, double y, double z) {
        double r273160 = x;
        double r273161 = y;
        double r273162 = 1.1283791670955126;
        double r273163 = z;
        double r273164 = exp(r273163);
        double r273165 = r273162 * r273164;
        double r273166 = r273160 * r273161;
        double r273167 = r273165 - r273166;
        double r273168 = r273161 / r273167;
        double r273169 = r273160 + r273168;
        return r273169;
}

double f(double x, double y, double z) {
        double r273170 = z;
        double r273171 = exp(r273170);
        double r273172 = 3.092591263638519e-306;
        bool r273173 = r273171 <= r273172;
        double r273174 = x;
        double r273175 = 1.0;
        double r273176 = r273175 / r273174;
        double r273177 = r273174 - r273176;
        double r273178 = y;
        double r273179 = -r273174;
        double r273180 = 1.1283791670955126;
        double r273181 = r273180 * r273171;
        double r273182 = fma(r273179, r273178, r273181);
        double r273183 = r273178 / r273182;
        double r273184 = r273174 + r273183;
        double r273185 = r273173 ? r273177 : r273184;
        return r273185;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original2.9
Target0.0
Herbie0.0
\[x + \frac{1}{\frac{1.128379167095512558560699289955664426088}{y} \cdot e^{z} - x}\]

Derivation

  1. Split input into 2 regimes
  2. if (exp z) < 3.092591263638519e-306

    1. Initial program 7.7

      \[x + \frac{y}{1.128379167095512558560699289955664426088 \cdot e^{z} - x \cdot y}\]
    2. Taylor expanded around inf 0.0

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

    if 3.092591263638519e-306 < (exp z)

    1. Initial program 1.3

      \[x + \frac{y}{1.128379167095512558560699289955664426088 \cdot e^{z} - x \cdot y}\]
    2. Taylor expanded around inf 1.3

      \[\leadsto x + \frac{y}{\color{blue}{1.128379167095512558560699289955664426088 \cdot e^{z} - x \cdot y}}\]
    3. Simplified0.0

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

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

Reproduce

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

  :herbie-target
  (+ x (/ 1 (- (* (/ 1.12837916709551256 y) (exp z)) x)))

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