Average Error: 2.6 → 1.9
Time: 4.5s
Precision: 64
\[x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y} \le 1.8133598671607465 \cdot 10^{283}:\\ \;\;\;\;x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\mathsf{fma}\left(1.12837916709551256, z, \mathsf{fma}\left(0.564189583547756279, {z}^{2}, 1.12837916709551256\right)\right)}\\ \end{array}\]
x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y}
\begin{array}{l}
\mathbf{if}\;x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y} \le 1.8133598671607465 \cdot 10^{283}:\\
\;\;\;\;x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\mathsf{fma}\left(1.12837916709551256, z, \mathsf{fma}\left(0.564189583547756279, {z}^{2}, 1.12837916709551256\right)\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r393245 = x;
        double r393246 = y;
        double r393247 = 1.1283791670955126;
        double r393248 = z;
        double r393249 = exp(r393248);
        double r393250 = r393247 * r393249;
        double r393251 = r393245 * r393246;
        double r393252 = r393250 - r393251;
        double r393253 = r393246 / r393252;
        double r393254 = r393245 + r393253;
        return r393254;
}

double f(double x, double y, double z) {
        double r393255 = x;
        double r393256 = y;
        double r393257 = 1.1283791670955126;
        double r393258 = z;
        double r393259 = exp(r393258);
        double r393260 = r393257 * r393259;
        double r393261 = r393255 * r393256;
        double r393262 = r393260 - r393261;
        double r393263 = r393256 / r393262;
        double r393264 = r393255 + r393263;
        double r393265 = 1.8133598671607465e+283;
        bool r393266 = r393264 <= r393265;
        double r393267 = 0.5641895835477563;
        double r393268 = 2.0;
        double r393269 = pow(r393258, r393268);
        double r393270 = fma(r393267, r393269, r393257);
        double r393271 = fma(r393257, r393258, r393270);
        double r393272 = r393256 / r393271;
        double r393273 = r393255 + r393272;
        double r393274 = r393266 ? r393264 : r393273;
        return r393274;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))) < 1.8133598671607465e+283

    1. Initial program 0.9

      \[x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y}\]

    if 1.8133598671607465e+283 < (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y))))

    1. Initial program 35.9

      \[x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y}\]
    2. Taylor expanded around 0 21.1

      \[\leadsto x + \frac{y}{\color{blue}{1.12837916709551256 \cdot z + \left(0.564189583547756279 \cdot {z}^{2} + 1.12837916709551256\right)}}\]
    3. Simplified21.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y} \le 1.8133598671607465 \cdot 10^{283}:\\ \;\;\;\;x + \frac{y}{1.12837916709551256 \cdot e^{z} - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\mathsf{fma}\left(1.12837916709551256, z, \mathsf{fma}\left(0.564189583547756279, {z}^{2}, 1.12837916709551256\right)\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020089 +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.1283791670955126 y) (exp z)) x)))

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