Average Error: 6.0 → 4.9
Time: 8.0s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.64989068819202057 \cdot 10^{92} \lor \neg \left(z \le 3.12717431505421634 \cdot 10^{-15}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot \sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}}\right) \cdot \left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot z\right) - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}
\begin{array}{l}
\mathbf{if}\;z \le -4.64989068819202057 \cdot 10^{92} \lor \neg \left(z \le 3.12717431505421634 \cdot 10^{-15}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot \sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}}\right) \cdot \left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot z\right) - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\

\end{array}
double f(double x, double y, double z) {
        double r512336 = x;
        double r512337 = 0.5;
        double r512338 = r512336 - r512337;
        double r512339 = log(r512336);
        double r512340 = r512338 * r512339;
        double r512341 = r512340 - r512336;
        double r512342 = 0.91893853320467;
        double r512343 = r512341 + r512342;
        double r512344 = y;
        double r512345 = 0.0007936500793651;
        double r512346 = r512344 + r512345;
        double r512347 = z;
        double r512348 = r512346 * r512347;
        double r512349 = 0.0027777777777778;
        double r512350 = r512348 - r512349;
        double r512351 = r512350 * r512347;
        double r512352 = 0.083333333333333;
        double r512353 = r512351 + r512352;
        double r512354 = r512353 / r512336;
        double r512355 = r512343 + r512354;
        return r512355;
}

double f(double x, double y, double z) {
        double r512356 = z;
        double r512357 = -4.6498906881920206e+92;
        bool r512358 = r512356 <= r512357;
        double r512359 = 3.1271743150542163e-15;
        bool r512360 = r512356 <= r512359;
        double r512361 = !r512360;
        bool r512362 = r512358 || r512361;
        double r512363 = 2.0;
        double r512364 = pow(r512356, r512363);
        double r512365 = x;
        double r512366 = r512364 / r512365;
        double r512367 = y;
        double r512368 = 0.0007936500793651;
        double r512369 = r512368 * r512366;
        double r512370 = 1.0;
        double r512371 = r512370 / r512365;
        double r512372 = log(r512371);
        double r512373 = fma(r512372, r512365, r512365);
        double r512374 = r512369 - r512373;
        double r512375 = fma(r512366, r512367, r512374);
        double r512376 = log(r512365);
        double r512377 = 0.5;
        double r512378 = r512365 - r512377;
        double r512379 = r512367 + r512368;
        double r512380 = cbrt(r512379);
        double r512381 = r512380 * r512380;
        double r512382 = r512380 * r512356;
        double r512383 = r512381 * r512382;
        double r512384 = 0.0027777777777778;
        double r512385 = r512383 - r512384;
        double r512386 = r512385 * r512356;
        double r512387 = 0.083333333333333;
        double r512388 = r512386 + r512387;
        double r512389 = r512388 / r512365;
        double r512390 = 0.91893853320467;
        double r512391 = r512365 - r512390;
        double r512392 = r512389 - r512391;
        double r512393 = fma(r512376, r512378, r512392);
        double r512394 = r512362 ? r512375 : r512393;
        return r512394;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.3
Herbie4.9
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467001 - x\right)\right) + \frac{0.0833333333333329956}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 2 regimes
  2. if z < -4.6498906881920206e+92 or 3.1271743150542163e-15 < z

    1. Initial program 24.2

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified24.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)}\]
    3. Taylor expanded around inf 26.1

      \[\leadsto \color{blue}{\left(7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - \left(x + x \cdot \log \left(\frac{1}{x}\right)\right)}\]
    4. Simplified19.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)}\]

    if -4.6498906881920206e+92 < z < 3.1271743150542163e-15

    1. Initial program 0.7

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified0.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt0.7

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\color{blue}{\left(\left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot \sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}}\right) \cdot \sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}}\right)} \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\]
    5. Applied associate-*l*0.7

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\color{blue}{\left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot \sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}}\right) \cdot \left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot z\right)} - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.64989068819202057 \cdot 10^{92} \lor \neg \left(z \le 3.12717431505421634 \cdot 10^{-15}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot \sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}}\right) \cdot \left(\sqrt[3]{y + 7.93650079365100015 \cdot 10^{-4}} \cdot z\right) - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020039 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))

  (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))